def test_set_comments(self): filename = "c37a3efa-593c-4bab-b49c-bee0613c4fb2" expected = "Comments.zip" meta_data = MetaWrapper(filename) meta_data.set_comments(self.test_bytes) actual = meta_data.get_description() self.assertEqual(expected, actual) self.assertEqual(f'{filename}:ftp', meta_data.filename)
def test_set_feedback(self): filename = "c37a3efa-593c-4bab-b49c-bee0613c4fb2" expected = "009 feedback response for period 2019 sample unit 49900108249D" meta_data = MetaWrapper(filename) meta_data.set_feedback(self.test_survey, self.test_bytes) actual = meta_data.get_description() self.assertEqual(expected, actual) self.assertEqual(f'{filename}:ftp', meta_data.filename)
def test_set_seft(self): filename = "c37a3efa-593c-4bab-b49c-bee0613c4fb2" expected = "057 seft response for period 202009 sample unit 20210121143526" meta_data = MetaWrapper(filename) meta_data.set_seft(self.test_seft) actual = meta_data.get_description() self.assertEqual(expected, actual) self.assertEqual(f'{filename}:ftp', meta_data.filename)
def test_set_feedback(self, mock_time): mock_time.return_value = 1629452867.587326 filename = "c37a3efa-593c-4bab-b49c-bee0613c4fb2" expected = "009 feedback response for period 2019 sample unit 49900108249D" meta_data = MetaWrapper(filename) meta_data.set_feedback(self.test_survey) actual = meta_data.get_description() self.assertEqual(expected, actual) self.assertEqual(f'{filename}-fb-1629452867:ftp', meta_data.filename)
def test_set_seft(self): filename = "11110000004H_202103_074_20210622072550.xlsx.gpg" expected = "057 seft response for period 202009 sample unit 20210121143526" meta_data = MetaWrapper(filename) meta_data.set_seft(self.test_seft) actual = meta_data.get_description() self.assertEqual(expected, actual) self.assertEqual('11110000004H_202103_074_20210622072550.xlsx.gpg:ftp', meta_data.filename)
def create_message_data(meta_data: MetaWrapper) -> str: """ Generates PubSub message using MetaWrapper """ if meta_data.output_type == OutputType.COMMENTS: dataset = "sdx_comments" iteration1 = None else: dataset = meta_data.survey_id iteration1 = meta_data.period message_data = { 'version': '1', 'files': [{ 'name': meta_data.filename, 'sizeBytes': meta_data.sizeBytes, 'md5sum': meta_data.md5sum }], 'sensitivity': CONFIG.DATA_SENSITIVITY, 'sourceName': CONFIG.PROJECT_ID, 'manifestCreated': get_formatted_current_utc(), 'description': meta_data.get_description(), 'dataset': dataset, 'schemaversion': '1' } if iteration1 is not None: message_data['iterationL1'] = iteration1 logger.info("Created pubsub message") str_dap_message = json.dumps(message_data) return str_dap_message