def test_existing_jobs(self): ai = AlgorithmImageFactory() cis = ComponentInterfaceFactory.create_batch(2) ai.algorithm.inputs.set(cis) civs = [ComponentInterfaceValueFactory(interface=c) for c in cis] j = AlgorithmJobFactory(algorithm_image=ai) j.inputs.set(civs) civ_sets = [ civs, # Job already exists { # New values ComponentInterfaceValueFactory(interface=cis[0]), ComponentInterfaceValueFactory(interface=cis[1]), }, { # Changed values civs[0], ComponentInterfaceValueFactory(interface=cis[1]), }, ] filtered_civ_sets = filter_civs_for_algorithm(civ_sets=civ_sets, algorithm_image=ai) assert filtered_civ_sets == civ_sets[1:]
def test_unmatched_interface_filter(self): ai = AlgorithmImageFactory() cis = ComponentInterfaceFactory.create_batch(2) ai.algorithm.inputs.set(cis) civ_sets = [ {}, # No interfaces {ComponentInterfaceValueFactory(interface=cis[0]) }, # Missing interface { # OK ComponentInterfaceValueFactory(interface=cis[0]), ComponentInterfaceValueFactory(interface=cis[1]), }, { # Unmatched interface ComponentInterfaceValueFactory(interface=cis[0]), ComponentInterfaceValueFactory( interface=ComponentInterfaceFactory()), }, ] filtered_civ_sets = filter_civs_for_algorithm(civ_sets=civ_sets, algorithm_image=ai) assert filtered_civ_sets == [civ_sets[2]]
def test_unmatched_interface_filter_subset(self): ai = AlgorithmImageFactory() cis = ComponentInterfaceFactory.create_batch(2) ai.algorithm.inputs.set(cis) civ_sets = [{ # Extra interface ComponentInterfaceValueFactory(interface=cis[0]), ComponentInterfaceValueFactory(interface=cis[1]), ComponentInterfaceValueFactory( interface=ComponentInterfaceFactory()), }] filtered_civ_sets = filter_civs_for_algorithm(civ_sets=civ_sets, algorithm_image=ai) assert len(filtered_civ_sets) == 1 assert {civ.interface for civ in filtered_civ_sets[0]} == {*cis}