Skip to content

Commit

Permalink
update test with single module per family
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMainguy committed Nov 15, 2023
1 parent 265518d commit 1be04d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ppanggolin/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def __delitem__(self, name):
raise KeyError(f"There isn't gene family with the name {name} in the module")
else:
del self._families_getter[name]
fam._modules.remove(self) # TODO define method to remove a module from family
fam._module = None # TODO define method to remove a module from family

def add(self, family: GeneFamily):
"""Add a family to the module.
Expand Down
12 changes: 6 additions & 6 deletions tests/test_genefamily.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def test_construct_gene_family(self, family):
"""
assert isinstance(family, GeneFamily)
assert all(attr in ["ID", "name", "_edges", "_genePerOrg", "_genes_getter", "removed", "sequence", "partition",
"_spots", "_modules", "bitarray", "_metadata_getter"] for attr in
"_spots", "_module", "bitarray", "_metadata_getter"] for attr in
family.__dict__) # Check that no attribute was added else it should be tested
assert all(hasattr(family, attr) for attr in ["ID", "name", "_edges", "_genePerOrg", "_genes_getter", "removed",
"sequence", "partition", "_spots", "_modules",
"sequence", "partition", "_spots", "_module",
"bitarray"]) # Check that no attribute was removed else it should be tested
assert family.ID == 1
assert family.name == 'test'
Expand All @@ -40,7 +40,7 @@ def test_construct_gene_family(self, family):
assert family.sequence == ""
assert family.partition == ""
assert family._spots == set()
assert family._modules == set()
assert family._module is None
assert family.bitarray is None

@pytest.mark.parametrize("partition, name",
Expand Down Expand Up @@ -300,13 +300,13 @@ def test_add_module_to_gene_family(self, family):
"""Tests that a Module object can be added to a GeneFamily object
"""
module = Module(1)
family.add_module(module)
assert module in family.modules
family.set_module(module)
assert module == family.module

def test_add_non_module_as_module_in_family(self, family):
"""Tests that a non-module object cannot be added to Gene Family
"""
with pytest.raises(TypeError):
family.add_module(323)
family.set_module(323)

# TODO test mk_bitarray
2 changes: 1 addition & 1 deletion tests/test_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def test_delete_family(self, module, family):
"""Tests that a gene family can be deleted from the module
"""
module[family.name] = family
del module['family']
del module[family.name]
assert len(module) == 0

def test_delete_family_which_does_not_exist(self, module):
Expand Down

0 comments on commit 1be04d6

Please sign in to comment.