コード例 #1
0
    def test_update_bundle(self, mock_etl_dss_bundles, mock_rmtree):
        handler = NotificationHandler(self.bundle_uuid, self.bundle_version,
                                      "CREATE")
        handler.update_bundle()
        query = {
            "query": {
                "bool": {
                    "must": [{
                        "term": {
                            "uuid": self.bundle_uuid
                        }
                    }]
                }
            }
        }

        mock_rmtree.assert_called_once_with("/tmp/output", ignore_errors=True)
        mock_etl_dss_bundles.assert_called_once_with(
            query=query,
            content_type_patterns=mock.ANY,
            filename_patterns=mock.ANY,
            transformer_cb=mock.ANY,
            finalizer_cb=mock.ANY,
            staging_directory="/tmp",
            deployment_stage=os.environ['DEPLOYMENT_STAGE'],
            max_workers=mock.ANY,
            dispatcher_executor_class=concurrent.futures.ThreadPoolExecutor)
コード例 #2
0
    def test_invalid_event(self, mock_update_bundle, mock_remove_bundle,
                           mock_error):
        handler = NotificationHandler(self.bundle_uuid, self.bundle_version,
                                      "INVALID")
        handler.run()

        self.assertFalse(mock_update_bundle.called)
        self.assertFalse(mock_remove_bundle.called)
        self.assertTrue(mock_error.called)
コード例 #3
0
ファイル: app.py プロジェクト: ambrosejcarr/matrix-service
def notification_handler(event, context):
    notification = json.loads(event["Records"][0]["body"])
    assert ('bundle_uuid' in notification and 'bundle_version' in notification
            and 'event_type' in notification)

    bundle_uuid = notification["bundle_uuid"]
    bundle_version = notification["bundle_version"]
    event_type = notification["event_type"]

    notification_handler = NotificationHandler(bundle_uuid, bundle_version,
                                               event_type)
    notification_handler.run()
コード例 #4
0
    def test_update_bundle(self, mock_etl_dss_bundle, mock_rmtree):
        handler = NotificationHandler(self.bundle_uuid, self.bundle_version,
                                      "CREATE")
        handler.update_bundle()

        mock_rmtree.assert_called_once_with("/tmp/output", ignore_errors=True)
        mock_etl_dss_bundle.assert_called_once_with(
            bundle_uuid=self.bundle_uuid,
            bundle_version=self.bundle_version,
            content_type_patterns=mock.ANY,
            filename_patterns=mock.ANY,
            transformer_cb=mock.ANY,
            finalizer_cb=mock.ANY,
            staging_directory="/tmp",
            deployment_stage=os.environ['DEPLOYMENT_STAGE'])
コード例 #5
0
    def test_remove_bundle(self, mock_transaction):
        handler = NotificationHandler(self.bundle_uuid, self.bundle_version,
                                      "TOMBSTONE")
        handler.remove_bundle()

        mock_transaction.assert_called_once_with([
            NotificationHandler.DELETE_EXPRESSION_QUERY_TEMPLATE.format(
                bundle_uuid=self.bundle_uuid,
                bundle_version=self.bundle_version),
            NotificationHandler.DELETE_CELL_QUERY_TEMPLATE.format(
                bundle_uuid=self.bundle_uuid,
                bundle_version=self.bundle_version),
            NotificationHandler.DELETE_ANALYSIS_QUERY_TEMPLATE.format(
                bundle_uuid=self.bundle_uuid,
                bundle_version=self.bundle_version)
        ])
コード例 #6
0
    def test_tombstone_event(self, mock_remove_bundle):
        handler = NotificationHandler(self.bundle_uuid, self.bundle_version,
                                      "TOMBSTONE")
        handler.run()

        mock_remove_bundle.assert_called_once_with()
コード例 #7
0
    def test_delete_event(self, mock_remove_bundle):
        handler = NotificationHandler(self.bundle_uuid, self.bundle_version,
                                      "DELETE")
        handler.run()

        mock_remove_bundle.assert_called_once_with()
コード例 #8
0
    def test_update_event(self, mock_update_bundle):
        handler = NotificationHandler(self.bundle_uuid, self.bundle_version,
                                      "UPDATE")
        handler.run()

        mock_update_bundle.assert_called_once_with()