Ejemplo n.º 1
0
    async def test_creation_request_options_era_being_called(self):
        # pylint: disable=protected-access
        test_config = CosmosDbConfig(
            endpoint="https://localhost:8081",
            masterkey=
            "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
            database="test-db",
            container="bot-storage",
            database_creation_options={"OfferThroughput": 1000},
            container_creation_options={"OfferThroughput": 500},
        )

        test_id = "1"
        client = get_mock_client(identifier=test_id)
        storage = CosmosDbStorage(test_config, client)
        storage.database = test_id

        assert storage._get_or_create_database(doc_client=client,
                                               id=test_id), test_id
        client.CreateDatabase.assert_called_with(
            {"id": test_id}, test_config.database_creation_options)
        assert storage._get_or_create_container(doc_client=client,
                                                container=test_id), test_id
        client.CreateContainer.assert_called_with(
            "dbs/" + test_id, {"id": test_id},
            test_config.container_creation_options)
Ejemplo n.º 2
0
    async def test_creation_request_options_era_being_called(self):
        test_config = CosmosDbConfig(
            endpoint='https://localhost:8081',
            masterkey=
            'C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==',
            database='test-db',
            container='bot-storage',
            database_creation_options={'OfferThroughput': 1000},
            container_creation_options={'OfferThroughput': 500})

        test_id = '1'
        client = get_mock_client(id=test_id)
        storage = CosmosDbStorage(test_config, client)
        storage.db = test_id

        assert storage._get_or_create_database(doc_client=client,
                                               id=test_id), test_id
        client.CreateDatabase.assert_called_with(
            {'id': test_id}, test_config.database_creation_options)
        assert storage._get_or_create_container(doc_client=client,
                                                container=test_id), test_id
        client.CreateContainer.assert_called_with(
            'dbs/' + test_id, {'id': test_id},
            test_config.container_creation_options)