Skip to content

Commit d666306

Browse files
committed
fix feature unit test and enable all unit tests
1 parent 83d4dee commit d666306

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

pytest.ini

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
11
[pytest]
22
pythonpath = .
33
addopts = -rf
4-
testpaths =
5-
# slowly add tests, until all tests are added
6-
test/test_siibra.py
7-
test/retrieval/
8-
test/core/
9-
test/volumes/
10-
test/features/external/
11-
test/features/test_cells.py
12-
test/features/test_connectivity.py
13-
test/features/test_genes.py
14-
test/features/test_receptors.py
15-
test/features/test_voi.py
16-
test/features/test_anchor.py
17-
# eventually, only use the below ini
18-
# test/
4+
testpaths = test/

siibra/features/feature.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,25 @@ def _wrap_livequery_feature(feature: 'Feature', fid: str):
624624
625625
See docstring of serialize_query_context for further context.
626626
"""
627-
class ProxyFeature(feature.__class__, do_not_index=True):
627+
class ProxyFeature(feature.__class__):
628628

629629
# override __class__ property
630630
# some instances of features accesses inst.__class__
631631
@property
632632
def __class__(self):
633633
return self.inst.__class__
634634

635+
def __init_subclass__(
636+
cls,
637+
configuration_folder=None,
638+
category=None,
639+
do_not_index=True,
640+
**kwargs,
641+
):
642+
return super().__init_subclass__(
643+
configuration_folder, category, do_not_index, **kwargs
644+
)
645+
635646
def __init__(self, inst: Feature, fid: str):
636647
self.inst = inst
637648
self.fid = fid

test/features/test_feature.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class FooFeatureBase:
1313
def __init__(self, id) -> None:
1414
self.id = id
1515
self.other = "bla"
16+
self.category = None
1617

1718

1819
class FooFeature(FooFeatureBase):
@@ -67,7 +68,7 @@ def test_serialize_query_context(feature, concept, ExCls, expected_id):
6768

6869
@pytest.fixture
6970
def mock_parse_featuretype():
70-
with patch.object(Feature, "parse_featuretype") as mock:
71+
with patch.object(Feature, "_parse_featuretype") as mock:
7172
mock.return_value = [FooFeature, FooFeatureBase]
7273
yield mock
7374

@@ -104,12 +105,12 @@ def mock_all(
104105

105106

106107
def test_mock_featuretype(mock_parse_featuretype):
107-
feature_types = Feature.parse_featuretype()
108+
feature_types = Feature._parse_featuretype()
108109
mock_parse_featuretype.assert_called_once()
109110
assert feature_types == [FooFeature, FooFeatureBase]
110111

111112
mock_parse_featuretype.return_value = "foo"
112-
feature_types = Feature.parse_featuretype()
113+
feature_types = Feature._parse_featuretype()
113114
assert feature_types == "foo"
114115

115116

@@ -245,7 +246,8 @@ def test_deserialize_query_context(
245246

246247

247248
def test_wrap_feature():
248-
new_feat = Feature._wrap_livequery_feature(feature_inst, "helloworld")
249+
feature_inst.category = "vategory_before_wrapping"
250+
new_feat = Feature._wrap_livequery_feature(feature_inst, fid="helloworld")
249251
assert new_feat.other == feature_inst.other
250252
assert new_feat.id != feature_inst.id
251253
assert new_feat.id == "helloworld"

0 commit comments

Comments
 (0)