Beispiel #1
0
    def test_destroy_source_and_provider_source_db_errort(self, mock_destory_provider, mock_destroy_source):
        """Test that destroys source where database error occurs."""
        aws_source = Sources.objects.get(source_type="AWS")
        aws_provider = Provider.objects.get(type="AWS-local")

        # Associate models
        aws_source.source_uuid = aws_provider.uuid
        aws_source.koku_uuid = aws_provider.uuid
        aws_source.save()

        source_id = aws_source.source_id
        source_uuid = aws_source.source_uuid

        delete_source_and_provider(source_id, source_uuid, aws_source.auth_header)
        self.assertTrue(Sources.objects.filter(source_id=source_id).exists())
Beispiel #2
0
    def test_destroy_source_and_provider_no_provider(self, mock_destory_provider):
        """Test that destroys source with no provider."""
        aws_source = Sources.objects.get(source_type="AWS")
        aws_provider = Provider.objects.get(type="AWS-local")

        # Associate models
        aws_source.koku_uuid = aws_provider.uuid
        aws_source.save()

        source_id = aws_source.source_id
        source_uuid = uuid4()  # Use incorrect UUID to simulate no provider.

        delete_source_and_provider(source_id, source_uuid, aws_source.auth_header)
        self.assertFalse(Sources.objects.filter(source_id=source_id).exists())
        mock_destory_provider.assert_not_called()
Beispiel #3
0
    def test_destroy_source_and_provider_source_does_not_exist(self, mock_destory_provider):
        """Test that destroys source where source does not exist."""
        aws_source = Sources.objects.get(source_type="AWS")
        aws_provider = Provider.objects.get(type="AWS-local")

        # Associate models
        aws_source.source_uuid = aws_provider.uuid
        aws_source.koku_uuid = aws_provider.uuid
        aws_source.save()

        non_existent_source_id = 1
        while Sources.objects.filter(source_id=non_existent_source_id).exists():
            non_existent_source_id += 1

        source_id = non_existent_source_id
        source_uuid = aws_source.source_uuid

        delete_source_and_provider(source_id, source_uuid, aws_source.auth_header)
        mock_destory_provider.assert_called()