Adjust archive tests for get_is_covered
@@ -28,14 +28,11 @@ def objectives() -> OrderedSet[ff.TestCaseFitnessFunction]:
)
-# TODO add tests that use get_is_covered
-
-
@pytest.fixture
def short_chromosome() -> tcc.TestCaseChromosome:
chromosome = MagicMock(tcc.TestCaseChromosome)
chromosome.size.return_value = 2
- chromosome.get_fitness_for.return_value = 0.0
+ chromosome.get_is_covered.return_value = True
return chromosome
@@ -43,13 +40,13 @@ def short_chromosome() -> tcc.TestCaseChromosome:
def long_chromosome() -> tcc.TestCaseChromosome:
chromosome = MagicMock(tcc.TestCaseChromosome)
chromosome.size.return_value = 42
- chromosome.get_fitness_for.return_value = 42.0
+ chromosome.get_is_covered.return_value = False
return chromosome
@pytest.fixture
def chromosomes(short_chromosome, long_chromosome) -> List[tcc.TestCaseChromosome]:
- return [short_chromosome, long_chromosome]
+ return [long_chromosome, short_chromosome]
def test_uncovered_goals(objectives):
@@ -69,7 +66,13 @@ def test_update_solution(objectives, chromosomes):
archive = CoverageArchive(objectives)
archive.update(chromosomes)
solution = archive.solutions
- assert solution == OrderedSet([chromosomes[0]])
+ assert solution == OrderedSet([chromosomes[1]])
+ assert chromosomes[0].get_fitness_for.call_count == 0
+ assert chromosomes[1].get_fitness_for.call_count == 0
+ # Called in assertion in archive again.
+ assert chromosomes[0].get_is_covered.call_count == 2
+ # Called in assertion in archive again.
+ assert chromosomes[1].get_is_covered.call_count == 4
def test_population_pair():
