Skip to content

Commit

Permalink
Update Namespace tests to handle exceptions
Browse files Browse the repository at this point in the history
- Modified tests to expect ValueError when invalid paths are provided.
  • Loading branch information
basicthinker committed Aug 28, 2023
1 parent 177e0ea commit aa17a6a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/test_namespace.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pytest
from devchat.engine import Namespace


Expand Down Expand Up @@ -79,7 +80,8 @@ def test_list_files(tmp_path):
assert namespace.list_files('a.b.c') == [file_path]

# Test case 2: a path that doesn't exist
assert namespace.list_files('d.e.f') is None
with pytest.raises(ValueError):
namespace.list_files('d.e.f')

# Test case 3: a path exists but has no files
os.makedirs(os.path.join(tmp_path, 'org', 'd', 'e', 'f'), exist_ok=True)
Expand Down Expand Up @@ -123,8 +125,8 @@ def test_list_names(tmp_path):
assert commands == ['a.b', 'a.b.c', 'a.b.d', 'a.e']

# Test listing commands of an invalid name
commands = namespace.list_names('b')
assert commands is None
with pytest.raises(ValueError):
namespace.list_names('b')

# Test listing commands when there are no commands
commands = namespace.list_names('a.e')
Expand Down

0 comments on commit aa17a6a

Please sign in to comment.