Skip to content

Commit 755d6dd

Browse files
committed
Configuring Coveralls
🐛 Coveralls over covering and including files made by Travis. Trying to get coveralls to ignore travisci home/ dir from coverage as it's not something that needs coverage.
1 parent 91eb096 commit 755d6dd

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[report]
2+
omit =
3+
*home/*

process_tracker/extract_tracker.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,9 @@ def __init__(self, process_run, filename, location=None, location_name=None, loc
6969

7070
self.extract_process = self.retrieve_extract_process()
7171

72-
if status is not None and self.extract_status_types[status]:
73-
self.logger.info('Setting extract status to %s' % status)
74-
self.extract.extract_status_id = self.extract_status_types[status]
75-
self.extract_process.extract_process_status_id = self.extract_status_types[status]
72+
if status is not None:
73+
self.change_extract_status(new_status=status)
7674
else:
77-
if status is not None:
78-
self.logger.error('Provided status %s is not in extract_status_types_lkup. '
79-
'Setting to initializing.' % status)
8075
self.extract.extract_status_id = self.extract_status_initializing
8176

8277
self.session.commit()
@@ -86,10 +81,13 @@ def change_extract_status(self, new_status):
8681
Change an extract record status.
8782
:return:
8883
"""
84+
8985
status_date = datetime.now()
90-
new_status = self.extract_status_types[new_status]
86+
if new_status in self.extract_status_types:
87+
self.logger.info('Setting extract status to %s' % new_status)
88+
89+
new_status = self.extract_status_types[new_status]
9190

92-
if new_status:
9391
self.extract.extract_status_id = new_status
9492

9593
self.extract_process.extract_process_status_id = new_status

tests/test_extract_tracker.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ def tearDown(self):
5757
self.session.query(Location).delete()
5858
self.session.commit()
5959

60+
def test_initialization_no_location_no_location_path(self):
61+
"""
62+
Testing that if no location or location path is set, an error is thrown.
63+
:return:
64+
"""
65+
66+
with self.assertRaises(Exception) as context:
67+
# Running registration a second time to mimic job being run twice
68+
ExtractTracker(process_run=self.process_run
69+
, filename='test_extract_filename.csv')
70+
71+
return self.assertTrue('A location object or location_path must be provided.' in str(context.exception))
72+
6073
def test_change_extract_status(self):
6174
"""
6275
Testing that when changing the extract status, the extract record and extract process record updates
@@ -77,6 +90,19 @@ def test_change_extract_status(self):
7790

7891
self.assertEqual(expected_result, given_result)
7992

93+
def test_change_extract_status_invalid_type(self):
94+
"""
95+
When trying to change a extract's status and the status is an invalid type, throw and error.
96+
:return:
97+
"""
98+
99+
with self.assertRaises(Exception) as context:
100+
# Running registration a second time to mimic job being run twice
101+
self.extract.change_extract_status(new_status='blarg')
102+
103+
return self.assertTrue('blarg is not a valid extract status type. '
104+
'Please add the status to extract_status_lkup' in str(context.exception))
105+
80106
def test_change_extract_status_initialization(self):
81107
"""
82108
Testing that when the extract is first being worked on by a process, the status is set to 'initializing'

0 commit comments

Comments
 (0)