Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sambles committed Jan 17, 2024
1 parent e7b4deb commit 77c41e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
26 changes: 9 additions & 17 deletions src/server/oasisapi/analyses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,16 +529,12 @@ def generate_and_run(self, initiator, version):
errors['settings_file'] = ['Must not be null']
if not self.portfolio.location_file:
errors['portfolio'] = ['"location_file" must not be null']

# get loc lines (replace with func?)
try:
loc_lines = self.portfolio.location_file_len()
except Exception as e:
raise ValidationError(f"Failed to read location file size for chunking: {e}")
if not isinstance(loc_lines, int):
errors['portfolio'] = [
f'Failed to read "location_file" size, content_type={self.portfolio.location_file.content_type} might not be supported']
else:
# get loc lines
try:
loc_lines = self.portfolio.location_file_len()
except Exception as e:
errors['portfolio'] = [f"Failed to read location file size for chunking: {e}"]
if loc_lines < 1:
errors['portfolio'] = ['"location_file" must at least one row']

Expand Down Expand Up @@ -624,14 +620,10 @@ def generate_inputs(self, initiator, version):
try:
loc_lines = self.portfolio.location_file_len()
except Exception as e:
raise ValidationError(f"Failed to read location file size for chunking: {e}")
if not isinstance(loc_lines, int):
errors['portfolio'] = [
f'Failed to read "location_file" size, content_type={self.portfolio.location_file.content_type} might not be supported']

else:
if loc_lines < 1:
errors['portfolio'] = ['"location_file" must at least one row']
errors['portfolio'] = [f"Failed to read location file size for chunking: {e}"]
if loc_lines < 1:
errors['portfolio'] = ['"location_file" must at least one row']

if errors:
raise ValidationError(errors)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ def test_state_is_ready___run_is_started(self, status, task_gen_id, task_run_id)

with patch('src.server.oasisapi.analyses.models.Analysis.v2_start_input_and_loss_generation_signature', PropertyMock(return_value=task_sig)):
analysis.generate_and_run(initiator, version='v2')
loc_lines = 4
events = None

task_sig.on_error.assert_called_once()
task_sig.apply_async.assert_called_with(
args=[analysis.pk, initiator.pk],
args=[analysis.pk, initiator.pk, loc_lines, events],
priority=4
)

Expand Down

0 comments on commit 77c41e5

Please sign in to comment.