Skip to content

Commit a3c3d09

Browse files
authored
Merge pull request #903 from cderici/share-test-constants-and-utils
#903 #### Description This is a small forward-port that brings 138e53a, which moves the test utilities/constants into a separate file to be shared across all the integration tests (it used to be only in `integration/test_model.py`). #### QA Steps This is a simple move, no functionality change, however, the tests use those constants (some of are paths etc) so we should probably make sure no test in the CI is failing because of that.
2 parents 112bfc6 + 905bf79 commit a3c3d09

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

tests/integration/test_model.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import time
66
import uuid
77
from concurrent.futures import ThreadPoolExecutor
8-
from pathlib import Path
98

109
import mock
1110
import paramiko
@@ -19,13 +18,7 @@
1918
from juju.utils import block_until, run_with_interrupt, wait_for_bundle, base_channel_to_series
2019

2120
from .. import base
22-
23-
MB = 1
24-
GB = 1024
25-
SSH_KEY = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsYMJGNGG74HAJha3n2CFmWYsOOaORnJK6VqNy86pj0MIpvRXBzFzVy09uPQ66GOQhTEoJHEqE77VMui7+62AcMXT+GG7cFHcnU8XVQsGM6UirCcNyWNysfiEMoAdZScJf/GvoY87tMEszhZIUV37z8PUBx6twIqMdr31W1J0IaPa+sV6FEDadeLaNTvancDcHK1zuKsL39jzAg7+LYjKJfEfrsQP+lj/EQcjtKqlhVS5kzsJVfx8ZEd0xhW5G7N6bCdKNalS8mKCMaBXJpijNQ82AiyqCIDCRrre2To0/i7pTjRiL0U9f9mV3S4NJaQaokR050w/ZLySFf6F7joJT mathijs@Qrama-Mathijs' # noqa
26-
HERE_DIR = Path(__file__).absolute().parent # tests/integration
27-
TESTS_DIR = HERE_DIR.parent # tests/
28-
OVERLAYS_DIR = HERE_DIR / 'bundle' / 'test-overlays'
21+
from ..utils import MB, GB, TESTS_DIR, OVERLAYS_DIR, SSH_KEY, INTEGRATION_TEST_DIR
2922

3023

3124
@base.bootstrapped
@@ -81,7 +74,7 @@ async def test_deploy_local_bundle_file(event_loop):
8174
@base.bootstrapped
8275
@pytest.mark.asyncio
8376
async def test_deploy_bundle_local_resource_relative_path(event_loop):
84-
bundle_file_path = HERE_DIR / 'bundle-file-resource.yaml'
77+
bundle_file_path = INTEGRATION_TEST_DIR / 'bundle-file-resource.yaml'
8578

8679
async with base.CleanModel() as model:
8780
await model.deploy(str(bundle_file_path))
@@ -134,7 +127,7 @@ async def test_deploy_by_revision_validate_flags(event_loop):
134127
@base.bootstrapped
135128
@pytest.mark.asyncio
136129
async def test_deploy_local_bundle_include_file(event_loop):
137-
bundle_dir = TESTS_DIR / 'integration' / 'bundle'
130+
bundle_dir = INTEGRATION_TEST_DIR / 'bundle'
138131
bundle_yaml_path = bundle_dir / 'bundle-include-file.yaml'
139132

140133
async with base.CleanModel() as model:
@@ -151,7 +144,7 @@ async def test_deploy_local_bundle_include_file(event_loop):
151144
@base.bootstrapped
152145
@pytest.mark.asyncio
153146
async def test_deploy_local_bundle_include_base64(event_loop):
154-
bundle_dir = TESTS_DIR / 'integration' / 'bundle'
147+
bundle_dir = INTEGRATION_TEST_DIR / 'bundle'
155148
bundle_yaml_path = bundle_dir / 'bundle-include-base64.yaml'
156149

157150
async with base.CleanModel() as model:
@@ -167,7 +160,7 @@ async def test_deploy_local_bundle_include_base64(event_loop):
167160
@base.bootstrapped
168161
@pytest.mark.asyncio
169162
async def test_deploy_bundle_local_charms(event_loop):
170-
bundle_path = TESTS_DIR / 'integration' / 'bundle' / 'local.yaml'
163+
bundle_path = INTEGRATION_TEST_DIR / 'bundle' / 'local.yaml'
171164

172165
async with base.CleanModel() as model:
173166
await model.deploy(bundle_path)
@@ -211,7 +204,7 @@ async def test_deploy_charm_assumes(event_loop):
211204
@base.bootstrapped
212205
@pytest.mark.asyncio
213206
async def test_deploy_local_charm_base_charmcraft_yaml(event_loop):
214-
charm_path = HERE_DIR / 'charm-base-charmcraft-yaml'
207+
charm_path = INTEGRATION_TEST_DIR / 'charm-base-charmcraft-yaml'
215208

216209
async with base.CleanModel() as model:
217210
await model.deploy(str(charm_path))
@@ -739,7 +732,7 @@ async def test_local_oci_image_resource_charm(event_loop):
739732
@base.bootstrapped
740733
@pytest.mark.asyncio
741734
async def test_local_file_resource_charm(event_loop):
742-
charm_path = TESTS_DIR / 'integration' / 'file-resource-charm'
735+
charm_path = INTEGRATION_TEST_DIR / 'file-resource-charm'
743736
async with base.CleanModel() as model:
744737
resources = {"file-res": "test.file"}
745738
app = await model.deploy(str(charm_path), resources=resources)
@@ -777,7 +770,7 @@ async def test_attach_resource(event_loop):
777770
async def test_store_resources_bundle(event_loop):
778771
pytest.skip('test_store_resources_bundle intermittent test failure')
779772
async with base.CleanModel() as model:
780-
bundle = str(Path(__file__).parent / 'bundle')
773+
bundle = INTEGRATION_TEST_DIR / 'bundle'
781774
await model.deploy(bundle)
782775
assert 'ghost' in model.applications
783776
ghost = model.applications['ghost']
@@ -799,7 +792,7 @@ async def test_store_resources_bundle(event_loop):
799792
async def test_store_resources_bundle_revs(event_loop):
800793
pytest.skip('test_store_resources_bundle_revs intermittent test failure')
801794
async with base.CleanModel() as model:
802-
bundle = str(Path(__file__).parent / 'bundle/bundle-resource-rev.yaml')
795+
bundle = INTEGRATION_TEST_DIR / 'bundle/bundle-resource-rev.yaml'
803796
await model.deploy(bundle)
804797
assert 'ghost' in model.applications
805798
ghost = model.applications['ghost']

tests/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from pathlib import Path
2+
3+
# Utilities for tests
4+
5+
MB = 1
6+
GB = 1024
7+
SSH_KEY = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsYMJGNGG74HAJha3n2CFmWYsOOaORnJK6VqNy86pj0MIpvRXBzFzVy09uPQ66GOQhTEoJHEqE77VMui7+62AcMXT+GG7cFHcnU8XVQsGM6UirCcNyWNysfiEMoAdZScJf/GvoY87tMEszhZIUV37z8PUBx6twIqMdr31W1J0IaPa+sV6FEDadeLaNTvancDcHK1zuKsL39jzAg7+LYjKJfEfrsQP+lj/EQcjtKqlhVS5kzsJVfx8ZEd0xhW5G7N6bCdKNalS8mKCMaBXJpijNQ82AiyqCIDCRrre2To0/i7pTjRiL0U9f9mV3S4NJaQaokR050w/ZLySFf6F7joJT mathijs@Qrama-Mathijs' # noqa
8+
HERE_DIR = Path(__file__).absolute() # tests/integration
9+
TESTS_DIR = HERE_DIR.parent # tests/
10+
INTEGRATION_TEST_DIR = TESTS_DIR / 'integration'
11+
UNIT_TEST_DIR = TESTS_DIR / 'unit'
12+
OVERLAYS_DIR = INTEGRATION_TEST_DIR / 'bundle' / 'test-overlays'

0 commit comments

Comments
 (0)