コード例 #1
0
    def test_start_capture_db_nothing_to_start(self, mock_boto):
        for stage in STAGES:
            os.environ['STAGE'] = stage
            result = handler.start_capture_db(self.initial_event, self.context)
            assert result['statusCode'] == 200
            assert result['message'] == f"Started the {stage} db: False"

        os.environ['STAGE'] = 'UNKNOWN'
        with self.assertRaises(Exception) as context:
            handler.start_capture_db(self.initial_event, self.context)
コード例 #2
0
    def test_start_capture_db_something_to_start(self, mock_boto, mock_enable_triggers):
        mock_enable_triggers.return_value = True
        mock_client = mock.Mock()
        mock_boto.return_value = mock_client
        my_mock_db_clusters = self.mock_db_clusters

        for stage in STAGES:
            my_mock_db_clusters['DBClusters'][0]['DBClusterIdentifier'] = DB[stage]
            mock_client.describe_db_clusters.return_value = my_mock_db_clusters
            mock_client.start_db_cluster.return_value = {DB[stage]}
            mock_client.get_queue_url.return_value = {'QueueUrl': 'queue'}
            mock_client.list_event_source_mappings.return_value = self.mock_event_source_mapping
            os.environ['STAGE'] = stage
            result = handler.start_capture_db(self.initial_event, self.context)
            assert result['statusCode'] == 200
            assert result['message'] == f"Started the {stage} db: True"

        os.environ['STAGE'] = 'UNKNOWN'
        with self.assertRaises(Exception) as context:
            handler.start_capture_db(self.initial_event, self.context)