Skip to content

Commit 138e53a

Browse files
committed
Move test utilites into a separate module
1 parent e2e60ae commit 138e53a

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
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
@@ -68,7 +61,7 @@ async def test_deploy_local_bundle_file(event_loop):
6861
@base.bootstrapped
6962
@pytest.mark.asyncio
7063
async def test_deploy_bundle_local_resource_relative_path(event_loop):
71-
bundle_file_path = HERE_DIR / 'bundle-file-resource.yaml'
64+
bundle_file_path = INTEGRATION_TEST_DIR / 'bundle-file-resource.yaml'
7265

7366
async with base.CleanModel() as model:
7467
await model.deploy(str(bundle_file_path))
@@ -82,7 +75,7 @@ async def test_deploy_bundle_local_resource_relative_path(event_loop):
8275
@base.bootstrapped
8376
@pytest.mark.asyncio
8477
async def test_deploy_local_bundle_include_file(event_loop):
85-
bundle_dir = TESTS_DIR / 'integration' / 'bundle'
78+
bundle_dir = INTEGRATION_TEST_DIR / 'bundle'
8679
bundle_yaml_path = bundle_dir / 'bundle-include-file.yaml'
8780

8881
async with base.CleanModel() as model:
@@ -99,7 +92,7 @@ async def test_deploy_local_bundle_include_file(event_loop):
9992
@base.bootstrapped
10093
@pytest.mark.asyncio
10194
async def test_deploy_local_bundle_include_base64(event_loop):
102-
bundle_dir = TESTS_DIR / 'integration' / 'bundle'
95+
bundle_dir = INTEGRATION_TEST_DIR / 'bundle'
10396
bundle_yaml_path = bundle_dir / 'bundle-include-base64.yaml'
10497

10598
async with base.CleanModel() as model:
@@ -115,7 +108,7 @@ async def test_deploy_local_bundle_include_base64(event_loop):
115108
@base.bootstrapped
116109
@pytest.mark.asyncio
117110
async def test_deploy_bundle_local_charms(event_loop):
118-
bundle_path = TESTS_DIR / 'integration' / 'bundle' / 'local.yaml'
111+
bundle_path = INTEGRATION_TEST_DIR / 'bundle' / 'local.yaml'
119112

120113
async with base.CleanModel() as model:
121114
await model.deploy(bundle_path)
@@ -665,7 +658,7 @@ async def test_local_oci_image_resource_charm(event_loop):
665658
@base.bootstrapped
666659
@pytest.mark.asyncio
667660
async def test_local_file_resource_charm(event_loop):
668-
charm_path = TESTS_DIR / 'integration' / 'file-resource-charm'
661+
charm_path = INTEGRATION_TEST_DIR / 'file-resource-charm'
669662
async with base.CleanModel() as model:
670663
resources = {"file-res": "test.file"}
671664
app = await model.deploy(str(charm_path), resources=resources)
@@ -703,7 +696,7 @@ async def test_attach_resource(event_loop):
703696
async def test_store_resources_bundle(event_loop):
704697
pytest.skip('test_store_resources_bundle intermittent test failure')
705698
async with base.CleanModel() as model:
706-
bundle = str(Path(__file__).parent / 'bundle')
699+
bundle = INTEGRATION_TEST_DIR / 'bundle'
707700
await model.deploy(bundle)
708701
assert 'ghost' in model.applications
709702
ghost = model.applications['ghost']
@@ -725,7 +718,7 @@ async def test_store_resources_bundle(event_loop):
725718
async def test_store_resources_bundle_revs(event_loop):
726719
pytest.skip('test_store_resources_bundle_revs intermittent test failure')
727720
async with base.CleanModel() as model:
728-
bundle = str(Path(__file__).parent / 'bundle/bundle-resource-rev.yaml')
721+
bundle = INTEGRATION_TEST_DIR / 'bundle/bundle-resource-rev.yaml'
729722
await model.deploy(bundle)
730723
assert 'ghost' in model.applications
731724
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)