Coverage for tests/objects/test_classification.py: 100%
35 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-31 11:24 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-31 11:24 +0000
1from qubalab.objects.classification import Classification
4def test_name():
5 expected_name = "name"
6 classification = Classification(expected_name)
8 name = classification.name
10 assert expected_name == name
13def test_color():
14 expected_color = (2, 20, 56)
15 classification = Classification(None, expected_color)
17 color = classification.color
19 assert expected_color == color
22def test_cache_when_None_name_provided():
23 classification = Classification.get_cached_classification(None)
25 assert classification == None
28def test_cache_when_empty():
29 name = "name"
30 color = (2, 20, 56)
32 classification = Classification.get_cached_classification(name, color)
34 assert classification == Classification(name, color)
37def test_cache_when_not_empty_and_same_name():
38 cached_name = "name"
39 cached_color = (2, 20, 56)
40 other_name = cached_name
41 other_color = (4, 65, 7)
42 cached_classification = Classification.get_cached_classification(cached_name, cached_color)
44 classification = Classification.get_cached_classification(other_name, other_color)
46 assert classification != Classification(other_name, other_color) and classification == cached_classification
49def test_cache_when_not_empty_and_different_name():
50 cached_name = "name"
51 cached_color = (2, 20, 56)
52 other_name = "other name"
53 other_color = (4, 65, 7)
54 cached_classification = Classification.get_cached_classification(cached_name, cached_color)
56 classification = Classification.get_cached_classification(other_name, other_color)
58 assert classification == Classification(other_name, other_color) and classification != cached_classification