Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard committed Feb 23, 2024
1 parent 3dcaace commit 7665a82
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions tests/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import yaml
from ebi_eva_common_pyutils.config import WritableConfig

from eva_sub_cli import SUB_CLI_CONFIG_FILE
from eva_sub_cli import SUB_CLI_CONFIG_FILE, is_submission_dir_writable
from eva_sub_cli.validators.validator import READY_FOR_SUBMISSION_TO_EVA
from eva_sub_cli.submit import StudySubmitter, SUB_CLI_CONFIG_KEY_SUBMISSION_ID, SUB_CLI_CONFIG_KEY_SUBMISSION_UPLOAD_URL

Expand Down Expand Up @@ -43,7 +43,6 @@ def test_submit(self):
with patch('eva_sub_cli.submit.requests.post', return_value=mock_initiate_response) as mock_post, \
patch('eva_sub_cli.submit.requests.put', return_value=mock_uploaded_response) as mock_put, \
patch.object(StudySubmitter, '_upload_submission'), \
patch.object(StudySubmitter, 'verify_submission_dir'), \
patch.object(self.submitter, 'submission_dir', self.test_sub_dir):

self.submitter.sub_config.set(READY_FOR_SUBMISSION_TO_EVA, value=True)
Expand All @@ -68,7 +67,7 @@ def test_submit_with_config(self):
mock_uploaded_response = MagicMock()
mock_uploaded_response.status_code = 200

self.submitter.verify_submission_dir(self.test_sub_dir)
assert is_submission_dir_writable(self.test_sub_dir)
sub_config = WritableConfig(self.config_file, version='version1.0')
sub_config.set(READY_FOR_SUBMISSION_TO_EVA, value=True)
sub_config.write()
Expand All @@ -88,12 +87,8 @@ def test_submit_with_config(self):
assert sub_config_data[SUB_CLI_CONFIG_KEY_SUBMISSION_ID] == "mock_submission_id"
assert sub_config_data[SUB_CLI_CONFIG_KEY_SUBMISSION_UPLOAD_URL] == "directory to use for upload"

def test_verify_submission_dir(self):
self.submitter.verify_submission_dir(self.test_sub_dir)
assert os.path.exists(self.test_sub_dir)

def test_sub_config_file_creation(self):
self.submitter.verify_submission_dir(self.test_sub_dir)
assert is_submission_dir_writable(self.test_sub_dir)
self.submitter.sub_config.set('test_key', value='test_value')
self.submitter.sub_config.write()

Expand All @@ -102,9 +97,9 @@ def test_sub_config_file_creation(self):

def test_sub_config_passed_as_param(self):
with patch('eva_sub_cli.submit.get_auth', return_value=Mock(token=self.token)):
assert is_submission_dir_writable(self.test_sub_dir)
sub_config = WritableConfig(self.config_file)
with StudySubmitter(self.test_sub_dir, vcf_files=None, metadata_file=None, submission_config=sub_config) as submitter:
submitter.verify_submission_dir(self.test_sub_dir)
submitter.sub_config.set('test_key', value='test_value')

assert os.path.exists(self.config_file)
Expand Down

0 comments on commit 7665a82

Please sign in to comment.