예제 #1
0
 def __init__(self):
     super(MetadataEntryResource, self).__init__()
     self._elastic_search = Elasticsearch(
         '{}:{}'.format(self._config.elastic.elastic_hostname,
                        self._config.elastic.elastic_port))
     self._parser = MetadataIndexingTransformer()
     self._dataset_delete = DataSetRemover()
     self._notifier = CFNotifier(self._config)
예제 #2
0
    def test_notify_correctMessgeSend(self, mock_connection):
        message = 'message'
        guid = 'guid'
        mock_con_val = mock_connection.return_value

        notifier = CFNotifier(self._config)
        notifier.notify(message, guid)

        self.assertTrue(mock_con_val.connect.called)
        self.assertTrue(mock_con_val.publish.called)

        subject = mock_con_val.publish.call_args[0][0]
        self.assertEquals(subject, self._config.services_url.nats_subject)

        publish_json = mock_con_val.publish.call_args[0][1]
        publish_data = json.loads(publish_json)
        self.assertEquals(message, publish_data['Message'])
        self.assertEquals(guid, publish_data['OrgGuid'])
        self.assertIn('Timestamp', publish_data.keys())