Exemple #1
0
    def test_get_client_time_to_live_called(
        self,
        mock_set_table_ttl,
        mock_validate_ttl_methods,
        mock_get_or_create_table,
        mock_boto_client,
    ):
        backend = DynamoDBBackend(
            app=self.app, url='dynamodb://*****:*****@test?ttl_seconds=30')
        backend._get_client()

        mock_validate_ttl_methods.assert_called_once()
        mock_set_table_ttl.assert_called_once()
Exemple #2
0
 def test_get_client_local(self):
     table_creation_path = \
         'celery.backends.dynamodb.DynamoDBBackend._get_or_create_table'
     with patch('boto3.client') as mock_boto_client, \
             patch(table_creation_path):
         backend = DynamoDBBackend(app=self.app,
                                   url='dynamodb://@localhost:8000')
         client = backend._get_client()
         assert backend.client is client
         mock_boto_client.assert_called_once_with(
             'dynamodb',
             endpoint_url='http://localhost:8000',
             region_name='us-east-1')
         assert backend.endpoint_url == 'http://localhost:8000'
Exemple #3
0
 def test_get_client_credentials(self):
     table_creation_path = \
         'celery.backends.dynamodb.DynamoDBBackend._get_or_create_table'
     with patch('boto3.client') as mock_boto_client, \
             patch(table_creation_path):
         backend = DynamoDBBackend(app=self.app,
                                   url='dynamodb://*****:*****@test')
         client = backend._get_client()
         assert client is backend.client
         mock_boto_client.assert_called_once_with(
             'dynamodb',
             aws_access_key_id='key',
             aws_secret_access_key='secret',
             region_name='test')
         assert backend.aws_region == 'test'
Exemple #4
0
    def test_get_client_explicit_endpoint(self):
        table_creation_path = \
            'celery.backends.dynamodb.DynamoDBBackend._get_or_create_table'
        with patch('boto3.client') as mock_boto_client, \
                patch(table_creation_path):

            self.app.conf.dynamodb_endpoint_url = 'http://my.domain.com:666'
            backend = DynamoDBBackend(app=self.app,
                                      url='dynamodb://@us-east-1')
            client = backend._get_client()
            assert backend.client is client
            mock_boto_client.assert_called_once_with(
                'dynamodb',
                endpoint_url='http://my.domain.com:666',
                region_name='us-east-1')
            assert backend.endpoint_url == 'http://my.domain.com:666'
Exemple #5
0
 def test_get_client_local(self):
     table_creation_path = \
         'celery.backends.dynamodb.DynamoDBBackend._get_or_create_table'
     with patch('boto3.client') as mock_boto_client, \
             patch(table_creation_path):
         backend = DynamoDBBackend(
             app=self.app,
             url='dynamodb://@localhost:8000'
         )
         client = backend._get_client()
         assert backend.client is client
         mock_boto_client.assert_called_once_with(
             'dynamodb',
             endpoint_url='http://localhost:8000',
             region_name='us-east-1'
         )
         assert backend.endpoint_url == 'http://localhost:8000'
Exemple #6
0
 def test_get_client_credentials(self):
     table_creation_path = \
         'celery.backends.dynamodb.DynamoDBBackend._get_or_create_table'
     with patch('boto3.client') as mock_boto_client, \
             patch(table_creation_path):
         backend = DynamoDBBackend(
             app=self.app,
             url='dynamodb://*****:*****@test'
         )
         client = backend._get_client()
         assert client is backend.client
         mock_boto_client.assert_called_once_with(
             'dynamodb',
             aws_access_key_id='key',
             aws_secret_access_key='secret',
             region_name='test'
         )
         assert backend.aws_region == 'test'
Exemple #7
0
    def test_get_client_explicit_endpoint(self):
        table_creation_path = \
            'celery.backends.dynamodb.DynamoDBBackend._get_or_create_table'
        with patch('boto3.client') as mock_boto_client, \
                patch(table_creation_path):

            self.app.conf.dynamodb_endpoint_url = 'http://my.domain.com:666'
            backend = DynamoDBBackend(
                app=self.app,
                url='dynamodb://@us-east-1'
            )
            client = backend._get_client()
            assert backend.client is client
            mock_boto_client.assert_called_once_with(
                'dynamodb',
                endpoint_url='http://my.domain.com:666',
                region_name='us-east-1'
            )
            assert backend.endpoint_url == 'http://my.domain.com:666'