/
conftest.py
49 lines (37 loc) · 1.71 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
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (c) 2017-2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
from concurrent.futures.thread import ThreadPoolExecutor
from typing import Generator
from dazl import testing
import pytest
@pytest.fixture(scope="session", params=["1", "2"])
def sandbox(request, sandbox_v1, sandbox_v2) -> "Generator[str, None, None]":
"""
Run an instance of the Sandbox, or use one configured through environment variables.
Some environment variables change the nature of the Sandbox used in these tests:
* DAZL_TEST_DAML_LEDGER_URL: If set, it is assumed to be an already-running ledger, and we
merely return that URL instead of starting up our own sandbox. This is the way that the tests
run in CI.
* DAML_SDK_VERSION: If set AND DAZL_TEST_DAML_LEDGER_URL is not specified, this controls the
version of the Sandbox that is launched through this wrapper. This value can be overridden
to test dazl against newer (or older) versions of the SDK without making code changes:
```
DAML_SDK_VERSION=1.0.0 make test
```
"""
if request.param == "1":
yield sandbox_v1
else:
yield sandbox_v2
@pytest.fixture(scope="session")
def sandbox_v1() -> "Generator[str, None, None]":
with testing.sandbox(project_root=None, version="1.18.1") as sb:
yield sb.url
@pytest.fixture(scope="session")
def sandbox_v2() -> "Generator[str, None, None]":
with testing.sandbox(project_root=None, version="2.0.0") as sb:
yield sb.url
@pytest.fixture()
def executor() -> "Generator[ThreadPoolExecutor, None, None]":
with ThreadPoolExecutor(3) as executor:
yield executor