Skip to content

Commit cfca24e

Browse files
committed
Update tests
1 parent 7722344 commit cfca24e

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

tests/test_imports.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,19 @@ class TestVecInfImports(unittest.TestCase):
1111
def test_imports(self):
1212
"""Test that all modules can be imported."""
1313
try:
14-
# API imports
15-
import vec_inf.api
16-
import vec_inf.api._helper
17-
import vec_inf.api._models
18-
import vec_inf.api.client
19-
2014
# CLI imports
2115
import vec_inf.cli
2216
import vec_inf.cli._cli
2317
import vec_inf.cli._helper
2418

25-
# Shared imports
26-
import vec_inf.shared
27-
import vec_inf.shared._config
28-
import vec_inf.shared._exceptions
29-
import vec_inf.shared._helper
30-
import vec_inf.shared._models
31-
import vec_inf.shared._utils
32-
import vec_inf.shared._vars # noqa: F401
19+
# Client imports
20+
import vec_inf.client
21+
import vec_inf.client._config
22+
import vec_inf.client._exceptions
23+
import vec_inf.client._helper
24+
import vec_inf.client._models
25+
import vec_inf.client._utils
26+
import vec_inf.client._vars # noqa: F401
3327

3428
except ImportError as e:
3529
pytest.fail(f"Import failed: {e}")

tests/vec_inf/cli/test_cli.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def base_patches(test_paths, mock_truediv, debug_helper):
229229
patch("pathlib.Path.iterdir", return_value=[]), # Mock empty directory listing
230230
patch("json.dump"),
231231
patch("pathlib.Path.touch"),
232-
patch("vec_inf.shared._utils.Path", return_value=test_paths["weights_dir"]),
232+
patch("vec_inf.client._utils.Path", return_value=test_paths["weights_dir"]),
233233
patch(
234234
"pathlib.Path.home", return_value=Path("/home/user")
235235
), # Mock home directory
@@ -251,7 +251,7 @@ def test_launch_command_success(runner, mock_launch_output, path_exists, debug_h
251251
test_log_dir = Path("/tmp/test_vec_inf_logs")
252252

253253
with (
254-
patch("vec_inf.shared._utils.run_bash_command") as mock_run,
254+
patch("vec_inf.client._utils.run_bash_command") as mock_run,
255255
patch("pathlib.Path.mkdir"),
256256
patch("builtins.open", debug_helper.tracked_mock_open),
257257
patch("pathlib.Path.open", debug_helper.tracked_mock_open),
@@ -282,7 +282,7 @@ def test_launch_command_with_json_output(
282282
"""Test JSON output format for launch command."""
283283
test_log_dir = Path("/tmp/test_vec_inf_logs")
284284
with (
285-
patch("vec_inf.shared._utils.run_bash_command") as mock_run,
285+
patch("vec_inf.client._utils.run_bash_command") as mock_run,
286286
patch("pathlib.Path.mkdir"),
287287
patch("builtins.open", debug_helper.tracked_mock_open),
288288
patch("pathlib.Path.open", debug_helper.tracked_mock_open),
@@ -340,7 +340,7 @@ def test_launch_command_model_not_in_config_with_weights(
340340
for patch_obj in base_patches:
341341
stack.enter_context(patch_obj)
342342
# Apply specific patches for this test
343-
mock_run = stack.enter_context(patch("vec_inf.shared._utils.run_bash_command"))
343+
mock_run = stack.enter_context(patch("vec_inf.client._utils.run_bash_command"))
344344
stack.enter_context(patch("pathlib.Path.exists", new=custom_path_exists))
345345

346346
expected_job_id = "14933051"
@@ -381,7 +381,7 @@ def custom_path_exists(p):
381381

382382
# Mock Path to return the weights dir path
383383
stack.enter_context(
384-
patch("vec_inf.shared._utils.Path", return_value=test_paths["weights_dir"])
384+
patch("vec_inf.client._utils.Path", return_value=test_paths["weights_dir"])
385385
)
386386

387387
result = runner.invoke(cli, ["launch", "unknown-model"])
@@ -417,9 +417,9 @@ def test_metrics_command_pending_server(
417417
):
418418
"""Test metrics command when server is pending."""
419419
with (
420-
patch("vec_inf.shared._utils.run_bash_command") as mock_run,
420+
patch("vec_inf.client._utils.run_bash_command") as mock_run,
421421
patch("pathlib.Path.exists", new=path_exists),
422-
patch("vec_inf.shared._utils.get_base_url", return_value="URL NOT FOUND"),
422+
patch("vec_inf.client._utils.get_base_url", return_value="URL NOT FOUND"),
423423
):
424424
job_id = 12345
425425
mock_run.return_value = (mock_status_output(job_id, "PENDING"), "")
@@ -441,9 +441,9 @@ def test_metrics_command_server_not_ready(
441441
):
442442
"""Test metrics command when server is running but not ready."""
443443
with (
444-
patch("vec_inf.shared._utils.run_bash_command") as mock_run,
444+
patch("vec_inf.client._utils.run_bash_command") as mock_run,
445445
patch("pathlib.Path.exists", new=path_exists),
446-
patch("vec_inf.shared._utils.get_base_url", return_value="Server not ready"),
446+
patch("vec_inf.client._utils.get_base_url", return_value="Server not ready"),
447447
):
448448
job_id = 12345
449449
mock_run.return_value = (mock_status_output(job_id, "RUNNING"), "")
@@ -481,9 +481,9 @@ def test_metrics_command_server_ready(
481481
mock_response.status_code = 200
482482

483483
with (
484-
patch("vec_inf.shared._utils.run_bash_command") as mock_run,
484+
patch("vec_inf.client._utils.run_bash_command") as mock_run,
485485
patch("pathlib.Path.exists", new=path_exists),
486-
patch("vec_inf.shared._utils.get_base_url", return_value="http://test:8000/v1"),
486+
patch("vec_inf.client._utils.get_base_url", return_value="http://test:8000/v1"),
487487
patch("time.sleep", side_effect=KeyboardInterrupt), # Break the infinite loop
488488
):
489489
job_id = 12345
@@ -507,9 +507,9 @@ def test_metrics_command_request_failed(
507507
mock_get.side_effect = requests.exceptions.RequestException("Connection refused")
508508

509509
with (
510-
patch("vec_inf.shared._utils.run_bash_command") as mock_run,
510+
patch("vec_inf.client._utils.run_bash_command") as mock_run,
511511
patch("pathlib.Path.exists", new=path_exists),
512-
patch("vec_inf.shared._utils.get_base_url", return_value="http://test:8000/v1"),
512+
patch("vec_inf.client._utils.get_base_url", return_value="http://test:8000/v1"),
513513
patch("time.sleep", side_effect=KeyboardInterrupt), # Break the infinite loop
514514
):
515515
job_id = 12345

0 commit comments

Comments
 (0)