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

FUIS (738) update #71

Merged
merged 1 commit into from
Oct 31, 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
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.6
2.0.7
5 changes: 1 addition & 4 deletions app/meta_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,17 @@ class MetaWrapperAdhoc(MetaWrapper):
"""
def __init__(self, filename: str):
super().__init__(filename)
self.original_id = None

def _from_survey(self, survey_dict: dict):
self.tx_id = _get_field(survey_dict, 'tx_id')
survey_id = _get_field(survey_dict, 'survey_metadata', 'survey_id')
self.original_id = survey_id
if survey_id == "739":
self.filename = f'739-{self.filename}'
elif survey_id == "738":
self.filename = f'738-{self.filename}'
survey_id = "739"
self.survey_id = survey_id
self.period = None
self.ru_ref = None

def get_description(self) -> str:
return f"{self.original_id} survey response for adhoc survey"
return f"{self.survey_id} survey response for adhoc survey"
2 changes: 1 addition & 1 deletion app/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def create_message_data(meta_data: MetaWrapper) -> str:
if meta_data.output_type == OutputType.COMMENTS:
dataset = "sdx_comments"
iteration1 = None
elif meta_data.survey_id == "739":
elif meta_data.survey_id == "739" or meta_data.survey_id == "738":
dataset = "covid_resp_inf_surv_response"
source_name = "ons"
iteration1 = "prod" if CONFIG.PROJECT_ID == "ons-sdx-prod" else "test"
Expand Down
46 changes: 44 additions & 2 deletions tests/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def test_create_message_for_adhoc_prod(self, mock_config, mock_time):
self.meta_data = MetaWrapperAdhoc('test_file_name')
self.meta_data.output_type = OutputType.DAP
self.meta_data.survey_id = "739"
self.meta_data.original_id = "739"
self.meta_data.period = None
self.meta_data.ru_ref = None
self.meta_data.sizeBytes = len(b"bytes")
Expand All @@ -163,7 +162,6 @@ def test_create_message_for_adhoc_preprod(self, mock_config, mock_time):
self.meta_data = MetaWrapperAdhoc('test_file_name')
self.meta_data.output_type = OutputType.DAP
self.meta_data.survey_id = "739"
self.meta_data.original_id = "739"
self.meta_data.period = None
self.meta_data.ru_ref = None
self.meta_data.sizeBytes = len(b"bytes")
Expand All @@ -178,3 +176,47 @@ def test_create_message_for_adhoc_preprod(self, mock_config, mock_time):

actual = create_message_data(self.meta_data)
self.assertEqual(json.dumps(self.expected), actual)

@patch('app.publish.get_formatted_current_utc', return_value="2021-10-10T08:42:24.737Z")
@patch('app.publish.CONFIG')
def test_create_message_for_wcis(self, mock_config, mock_time):
mock_config.PROJECT_ID = "ons-sdx-prod"
mock_config.DATA_SENSITIVITY = "High"
self.meta_data = MetaWrapperAdhoc('test_file_name')
self.meta_data.output_type = OutputType.DAP
self.meta_data.survey_id = "739"
self.meta_data.period = None
self.meta_data.ru_ref = None
self.meta_data.sizeBytes = len(b"bytes")
self.meta_data.md5sum = hashlib.md5(b"bytes").hexdigest()

self.expected['manifestCreated'] = mock_time.return_value
self.expected['sourceName'] = "ons"
self.expected['dataset'] = "covid_resp_inf_surv_response"
self.expected['description'] = "739 survey response for adhoc survey"
self.expected['iterationL1'] = "prod"

actual = create_message_data(self.meta_data)
self.assertEqual(json.dumps(self.expected), actual)

@patch('app.publish.get_formatted_current_utc', return_value="2021-10-10T08:42:24.737Z")
@patch('app.publish.CONFIG')
def test_create_message_for_fuis(self, mock_config, mock_time):
mock_config.PROJECT_ID = "ons-sdx-prod"
mock_config.DATA_SENSITIVITY = "High"
self.meta_data = MetaWrapperAdhoc('test_file_name')
self.meta_data.output_type = OutputType.DAP
self.meta_data.survey_id = "738"
self.meta_data.period = None
self.meta_data.ru_ref = None
self.meta_data.sizeBytes = len(b"bytes")
self.meta_data.md5sum = hashlib.md5(b"bytes").hexdigest()

self.expected['manifestCreated'] = mock_time.return_value
self.expected['sourceName'] = "ons"
self.expected['dataset'] = "covid_resp_inf_surv_response"
self.expected['description'] = "738 survey response for adhoc survey"
self.expected['iterationL1'] = "prod"

actual = create_message_data(self.meta_data)
self.assertEqual(json.dumps(self.expected), actual)
Loading