Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vertefra committed Aug 29, 2024
1 parent 51d131d commit 986ad7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
23 changes: 9 additions & 14 deletions tests/unit/qcog/pytorch/discover/test_discover_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from qcog_python_client.qcog.pytorch.discover import DiscoverCommand, DiscoverHandler
from qcog_python_client.qcog.pytorch.discover.discoverhandler import (
_maybe_model_module,
_maybe_monitor_service_import_module,
_is_model_module,
_is_service_import_module
)
from qcog_python_client.qcog.pytorch.types import QFile
from qcog_python_client.qcog.pytorch.validate.validatehandler import ValidateCommand
Expand Down Expand Up @@ -66,8 +66,8 @@ async def test_maybe_model_module_positive(mock_model_dir, discover_handler):
pkg_name=None,
)
discover_handler.model_path = mock_model_dir
result = await _maybe_model_module(discover_handler, f)
assert result is f
result = await _is_model_module(discover_handler, f)
assert result is True


@pytest.mark.asyncio
Expand All @@ -84,9 +84,8 @@ async def test_maybe_model_module_negative(mock_model_dir, discover_handler):
)

discover_handler.model_path = mock_model_dir
result = await _maybe_model_module(discover_handler, f)
assert result is None

result = await _is_model_module(discover_handler, f)
assert result is False

@pytest.mark.asyncio
async def test_maybe_monitor_service_import_module(mock_model_dir, discover_handler):
Expand All @@ -102,8 +101,7 @@ async def test_maybe_monitor_service_import_module(mock_model_dir, discover_hand
)

discover_handler.model_path = mock_model_dir
result = await _maybe_monitor_service_import_module(discover_handler, f)
assert result is f
assert await _is_service_import_module(discover_handler, f)


@pytest.mark.asyncio
Expand All @@ -126,7 +124,7 @@ async def test_maybe_monitor_service_import_module_wrong_import(

discover_handler.model_path = mock_model_dir
with pytest.raises(ValueError) as exc_info:
await _maybe_monitor_service_import_module(discover_handler, f)
await _is_service_import_module(discover_handler, f)
assert (
"You cannot import anything from qcog_python_client other than monitor."
in str(exc_info.value)
Expand All @@ -152,10 +150,7 @@ async def test_maybe_monitor_service_import_module_with_alias(
)

discover_handler.model_path = mock_model_dir
result = await _maybe_monitor_service_import_module(discover_handler, f)

assert result is f

assert await _is_service_import_module(discover_handler, f)

@pytest.mark.asyncio
async def test_revert(discover_handler):
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/qcog/pytorch/validate/test_setup_monitor_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_setup_monitor_import_directory_update(
mock_handler,
mock_relevant_file,
mock_training_package,
monitor_package_folder_path_getter=lambda: monitor_package_folder_path,
monitor_package_folder_path=monitor_package_folder_path,
folder_content_getter=lambda folder_path: mock_monitor_package,
)

Expand Down Expand Up @@ -167,8 +167,8 @@ def dummy_function():
mock_handler,
file,
mock_training_package,
monitor_package_folder_path_getter=lambda: monitor_package_folder_path,
folder_content_getter=lambda folder_path: mock_monitor_package,
monitor_package_folder_path=monitor_package_folder_path,
folder_content_getter=lambda folder_path: mock_monitor_package
)

exc_info == "Only one import is allowed from the qcog_python_client package."

0 comments on commit 986ad7e

Please sign in to comment.