Skip to content

Commit 3fa2cb4

Browse files
committed
Move test utilites into a separate module
1 parent c7d0a10 commit 3fa2cb4

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

tests/integration/test_model.py

Lines changed: 8 additions & 15 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)
@@ -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)