Skip to content

Commit

Permalink
chore: cleanup tests and hook nits
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Dec 16, 2023
1 parent 7772e8e commit 3568dcc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion hooks/tests/test_provider_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from tackle import tackle, get_hook, Context

PROVIDERS_PATH = os.path.join('..', '..', 'providers')
PROVIDERS_PATH = os.path.join(os.path.dirname(__file__), '..', '..', 'providers')


def get_provider_paths(provider_name: str = None):
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


@pytest.mark.parametrize("input_string,output", INPUT_SOURCES)
def test_cli_parse_args(mocker, change_base_dir, input_string, output):
def test_cli_parse_args(mocker, cd_base_dir, input_string, output):
"""Mock the main call and verify the args get passed in right through the CLI."""
mock = mocker.patch("tackle.main.parse_context", autospec=True)
main(input_string.split(' '))
Expand All @@ -56,7 +56,7 @@ def test_cli_parse_args(mocker, change_base_dir, input_string, output):
("--directory foo", "directory", "foo"),
("--find-in-parent", "find_in_parent", True),
])
def test_cli_parse_args_vars(mocker, change_base_dir, input_string, output_keys, output):
def test_cli_parse_args_vars(mocker, cd_base_dir, input_string, output_keys, output):
"""Mock the main call and verify the args get passed in right through the CLI."""
mock = mocker.patch("tackle.cli.tackle", autospec=True)
main(input_string.split(' '))
Expand Down
9 changes: 7 additions & 2 deletions tests/factory/source/test_factory_source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import tempfile
from pathlib import Path
import pytest
import shutil
Expand Down Expand Up @@ -194,6 +195,12 @@ def test_factory_source_new_source_exceptions_parameterized(args, kwargs):
new_source(context=context, **kwargs)


@pytest.fixture(scope='function')
def run_in_temp_dir(cd):
temp_dir = tempfile.mkdtemp()
cd(temp_dir)


def test_factory_source_new_source_exception_no_arg_temp_di(run_in_temp_dir):
"""
When no arg is supplied it tries to find in parent. This test is run in temp dir
Expand Down Expand Up @@ -224,5 +231,3 @@ def test_factory_source_new_source_exception_find_in_parent_repo_does_not_exist(
main.tackle('definitely-not-a-valid-repo-dir')

assert 'definitely-not-a-valid-repo-dir' in info.value.message


21 changes: 0 additions & 21 deletions tests/imports/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,6 @@ def f(provider):

return f


@pytest.mark.slow
def test_providers_released(remove_provider):
"""
Check that when we call a released provider, that we only use commits from the
latest release and not anything that was added after the release. Check the external
fixture for details.
"""
remove_provider("robcxyz/tackle-fixture-released")
o = tackle("robcxyz/tackle-fixture-released")

assert 'released_added_later' not in o


@pytest.mark.slow
def test_providers_released_latest(remove_provider):
"""
Expand All @@ -173,13 +159,6 @@ def test_providers_released_latest(remove_provider):
latest=True,
)
assert o['hooks_dir_hook']['foo'] == 'bar'
assert 'released_added_later' in o

# TODO: Ditch this? It is hard to maintain
# What it is asserting is each time I release the fixture it doesn't have that key
# # Then test that when we run the provider again that it uses the latest release.
# o = tackle("robcxyz/tackle-fixture-released")
# # assert 'released_added_later' not in o


@pytest.mark.slow
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ def test_is_file(file, is_file_result, mocker):


@pytest.mark.parametrize("repo,is_repo_result", REPO_FIXTURES)
def test_is_repo_url(repo, is_repo_result, change_base_dir):
def test_is_repo_url(repo, is_repo_result, cd_base_dir):
"""Validate is_repo_url regex."""
assert is_repo_url(repo) == is_repo_result
2 changes: 0 additions & 2 deletions tests/utils/test_utils_data_crud.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""Tests for tackle.utils.dicts"""
import pytest
from ruyaml import YAML

Expand All @@ -8,7 +7,6 @@
nested_set,
nested_get,
nested_delete,
set_key,
cleanup_unquoted_strings,
)

Expand Down

0 comments on commit 3568dcc

Please sign in to comment.