-
Notifications
You must be signed in to change notification settings - Fork 15
/
conftest.py
36 lines (27 loc) · 1.18 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from typing import Iterator
import pytest
from pctasks.dev.cosmosdb import temp_cosmosdb_if_emulator
from pctasks.core.cosmos.database import CosmosDBDatabase, CosmosDBSettings
@pytest.fixture
def temp_cosmosdb_containers() -> Iterator[CosmosDBDatabase]:
"""
Temporary Cosmos DB containers for testing.
"""
with temp_cosmosdb_if_emulator() as db:
yield db
@pytest.fixture(scope="session")
def cosmosdb_containers() -> Iterator[CosmosDBDatabase]:
"""
CosmosDBDatabase for *existing* Cosmos DB containers.
This does not create / destroy containers. If you're relying on Azure Functions
to run in response to Cosmos DB updates, you should ensure that the following
environment variables are consistent between your Azure Functions container
(started through `./scripts/server` and your test process)
* ``PCTASKS__COSMOSDB__URL``
* ``PCTASKS__COSMOSDB__TEST_CONTAINER_SUFFIX``
You should also ensure that the Cosmos DB containers already exist before starting
the Azure Functions or tests, otherwise the Azure Functions will fail to monitor
the container.
"""
settings = CosmosDBSettings.get()
yield CosmosDBDatabase(settings)