Skip to content

Commit

Permalink
Try move ssh fixture to classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZiminski committed Apr 22, 2024
1 parent 1b9d105 commit e86aa27
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
17 changes: 0 additions & 17 deletions tests/tests_integration/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import os
import platform
import subprocess
import warnings

import pytest
import ssh_test_utils
import test_utils

from datashuttle.datashuttle import DataShuttle
Expand Down Expand Up @@ -60,17 +57,3 @@ def clean_project_name(self):
test_utils.delete_project_if_it_exists(project_name)
yield project_name
test_utils.delete_project_if_it_exists(project_name)

@pytest.fixture(
scope="class",
)
def setup_ssh_container(self):
# Annoying session scope does not seem to actually work
container_name = "running_ssh_tests"
ssh_test_utils.setup_ssh_container(container_name)
yield

sudo = "sudo " if platform.system() == "Linux" else ""

subprocess.run(f"{sudo}docker stop {container_name}", shell=True)
subprocess.run(f"{sudo}rm {container_name}", shell=True)
17 changes: 17 additions & 0 deletions tests/tests_integration/test_ssh_setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import platform
import subprocess

import pytest
import ssh_test_utils
import test_utils
Expand All @@ -11,6 +14,20 @@
@pytest.mark.skipif("not TEST_SSH", reason="TEST_SSH is false")
class TestSSHSetup(BaseTest):

@pytest.fixture(
scope="class",
)
def setup_ssh_container(self):
# Annoying session scope does not seem to actually work
container_name = "running_ssh_tests"
ssh_test_utils.setup_ssh_container(container_name)
yield

sudo = "sudo " if platform.system() == "Linux" else ""

subprocess.run(f"{sudo}docker stop {container_name}", shell=True)
subprocess.run(f"{sudo}rm {container_name}", shell=True)

@pytest.fixture(scope="function")
def project(test, tmp_path, setup_ssh_container):
"""
Expand Down
16 changes: 16 additions & 0 deletions tests/tests_integration/test_ssh_transfer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import platform
import shutil
import subprocess

import paramiko
import pytest
Expand All @@ -14,6 +16,20 @@
@pytest.mark.skipif("not TEST_SSH", reason="TEST_SSH is false")
class TestSSHTransfer(BaseTransfer):

@pytest.fixture(
scope="class",
)
def setup_ssh_container(self):
# Annoying session scope does not seem to actually work
container_name = "running_ssh_tests"
ssh_test_utils.setup_ssh_container(container_name)
yield

sudo = "sudo " if platform.system() == "Linux" else ""

subprocess.run(f"{sudo}docker stop {container_name}", shell=True)
subprocess.run(f"{sudo}rm {container_name}", shell=True)

@pytest.fixture(
scope="class",
)
Expand Down

0 comments on commit e86aa27

Please sign in to comment.