Skip to content

Commit

Permalink
fix artificial cell testsing, fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Helveg committed Dec 11, 2023
1 parent 23581b1 commit 7fefe01
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion glia/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def compile():
),
)
click.echo("Testing assets ...")
test(*_manager.resolver.index.keys(), standalone_mode=False)
test(_manager.resolver.index.keys(), standalone_mode=False)


@glia.command("list")
Expand Down
8 changes: 6 additions & 2 deletions glia/_glia.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def start(self):
self.compile(check_cache=True)

@_requires_install
def package(self, name):
def package(self, name) -> Package:
for pkg in self.packages:
if pkg.name == name:
return pkg
Expand Down Expand Up @@ -262,7 +262,11 @@ def test_mechanism(self, mechanism):
"""
try:
s = self.h.Section()
self.insert(s, mechanism)
mod = self._resolve_mod(mechanism)
if mod.is_artificial_cell:
getattr(self.h, mod.mod_name)
else:
self.insert(s, mechanism)
except ValueError as e:
if str(e).find("argument not a density mechanism name") != -1:
raise LibraryError(mechanism + " mechanism could not be inserted.")
Expand Down
3 changes: 0 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def import_tmp_package(path):
spec = importlib.util.spec_from_file_location("__test_package__", path)
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
print(Path(m.__file__).read_text())
print("module?", m, dir(m), m.__file__)
return m.package


Expand Down Expand Up @@ -59,7 +57,6 @@ def test_compile_nopkg(self):

def test_list(self):
result = run_cli_command(["list"])
print(result.output, result.exit_code, result.exception)
self.assertEqual(0, result.exit_code)

@_shared.skipUnlessTestMods
Expand Down
13 changes: 6 additions & 7 deletions tests/test_glia.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@ class TestPackageDiscovery(unittest.TestCase):
def test_discovery(self):
self.assertGreater(len(glia._manager.packages), 0)

def test_caching(self):
cache = read_cache()
# Check whether the directory hash for `glia_test_mods` is present.
self.assertTrue(
any(["glia_test_mods" in hash for hash in cache["mod_hashes"].keys()])
)


class TestCompilation(unittest.TestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
glia.compile()

def test_caching(self):
# Test whether the compilation was cached
cache = read_cache()
pkg = glia._manager.package("glia_test_mods")
self.assertEqual(pkg.mod_hash, cache["mod_hashes"].get(pkg.hash))

def test_compilation(self):
# Check that the library files exist
for path in glia._manager.get_libraries():
Expand Down

0 comments on commit 7fefe01

Please sign in to comment.