Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit to existing project accession #177

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions eva_submission/ENA_submission/xlsx_to_ENA_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,12 @@ def _add_analysis(self, root, analysis_row, project_row, sample_rows, file_rows)

def _create_submission_xml(self, files_to_submit, action, project_row, eload):
root = Element('SUBMISSION_SET')
if self.is_existing_project:
submission_alias = self.existing_project + '_' + eload
else:
submission_alias = eload
submission_elemt = add_element(root, 'SUBMISSION',
alias=eload,
alias=submission_alias,
center_name=project_row.get('Center'))
actions_elemt = add_element(submission_elemt, 'ACTIONS')
for file_dict in files_to_submit:
Expand All @@ -315,8 +319,12 @@ def _create_submission_xml(self, files_to_submit, action, project_row, eload):

def _create_submission_single_xml(self, action, project_row, eload):
root = Element('SUBMISSION_SET')
if self.is_existing_project:
submission_alias = self.existing_project + '_' + eload
else:
submission_alias = eload
submission_elemt = add_element(root, 'SUBMISSION',
alias=eload,
alias=submission_alias,
center_name=project_row.get('Center'))
actions_elemt = add_element(submission_elemt, 'ACTIONS')
action_elemt = add_element(actions_elemt, 'ACTION')
Expand Down
8 changes: 5 additions & 3 deletions tests/test_xlsx_to_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from datetime import datetime
from unittest import TestCase
import xml.etree.ElementTree as ET
from unittest.mock import patch, Mock

from unittest.mock import patch, Mock, PropertyMock
from eva_submission import ROOT_DIR
from eva_submission.ENA_submission.xlsx_to_ENA_xml import EnaXlsxConverter

Expand Down Expand Up @@ -250,12 +249,15 @@ def test_create_submission_files(self):

def test_create_submission_files_for_existing_project(self):
# When the project already exist not PROJECT XML will be generated
with patch.object(EnaXlsxConverter, 'is_existing_project', return_value=True):
with patch.object(EnaXlsxConverter, 'existing_project', new_callable=PropertyMock(return_value='PRJEB00001')):
submission_file, project_file, analysis_file = self.converter.create_submission_files('ELOAD_1')
assert os.path.exists(submission_file)
assert project_file is None
assert os.path.exists(analysis_file)
assert not os.path.exists(self.converter.project_file)
with open(submission_file) as open_file:
root = ET.fromstring(open_file.read())
assert list(root)[0].attrib['alias'] == 'PRJEB00001_ELOAD_1'

def test_create_single_submission_files(self):
self.converter.create_single_submission_file('ELOAD_1')
Expand Down
Loading