Skip to content

Commit

Permalink
chore: use helper fixtures for test directories
Browse files Browse the repository at this point in the history
  • Loading branch information
nejch committed Sep 15, 2020
1 parent 27109ca commit 40ec2f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions tools/functional/conftest.py
Expand Up @@ -10,10 +10,6 @@
import gitlab


TEMP_DIR = tempfile.gettempdir()
TEST_DIR = Path(__file__).resolve().parent


def reset_gitlab(gl):
# previously tools/reset_gitlab.py
for project in gl.projects.list():
Expand All @@ -27,8 +23,8 @@ def reset_gitlab(gl):
user.delete()


def set_token(container):
set_token_rb = TEST_DIR / "fixtures" / "set_token.rb"
def set_token(container, rootdir):
set_token_rb = rootdir / "fixtures" / "set_token.rb"

with open(set_token_rb, "r") as f:
set_token_command = f.read().strip()
Expand All @@ -47,8 +43,18 @@ def set_token(container):


@pytest.fixture(scope="session")
def docker_compose_file():
return TEST_DIR / "fixtures" / "docker-compose.yml"
def temp_dir():
return Path(tempfile.gettempdir())


@pytest.fixture(scope="session")
def test_dir(pytestconfig):
return pytestconfig.rootdir / "tools" / "functional"


@pytest.fixture(scope="session")
def docker_compose_file(test_dir):
return test_dir / "fixtures" / "docker-compose.yml"


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -78,15 +84,15 @@ def _check(container):


@pytest.fixture(scope="session")
def gitlab_config(check_is_alive, docker_ip, docker_services):
config_file = Path(TEMP_DIR) / "python-gitlab.cfg"
def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, test_dir):
config_file = temp_dir / "python-gitlab.cfg"
port = docker_services.port_for("gitlab", 80)

docker_services.wait_until_responsive(
timeout=180, pause=5, check=lambda: check_is_alive("gitlab-test")
)

token = set_token("gitlab-test")
token = set_token("gitlab-test", rootdir=test_dir)

config = f"""[global]
default = local
Expand Down
2 changes: 1 addition & 1 deletion tools/functional/python_test_v4.py
Expand Up @@ -57,7 +57,7 @@
qG2ZdhHHmSK2LaQLFiSprUkikStNU9BqSQ==
=5OGa
-----END PGP PUBLIC KEY BLOCK-----"""
AVATAR_PATH = Path(__file__).resolve().parent / "fixtures" / "avatar.png"
AVATAR_PATH = Path(__file__).parent / "fixtures" / "avatar.png"
TEMP_DIR = Path(tempfile.gettempdir())

# token authentication from config file
Expand Down

0 comments on commit 40ec2f5

Please sign in to comment.