def test_filter_sources_through_cluster_links(self, robot, indirect_links_sketch): robot.cli('web load computation.web / b .. / save filtered.web') sketch = Sketch.from_file(robot.cwd / 'filtered.web') assert sketch.cluster_by_name.keys() == set('bcd') assert len(sketch.cluster_by_name['c']) == 2
def test_rewire(self, robot, renamed_e_web_file, remap_e_to_renamed_e_json): robot.cli( f'web load {renamed_e_web_file} rewire {remap_e_to_renamed_e_json} save rewired.web' ) sketch = Sketch.from_file(robot.cwd / 'rewired.web') [f] = [b for b in sketch.beads if b.name == 'f'] assert f.input_map == {'e': 'renamed_e'}, f assert 'WARNING' in robot.stderr assert "Selected name 'renamed_e'" in robot.stderr
def test_new_version_marks_older_superseded(): sketcher = Sketcher() sketcher.define('a1 b1 c1') sketcher.compile(""" a1 -> b1 a1 -:survivor:-> c1 """) sketch = sketcher.sketch orig_beads = sketch.beads sketch = Sketch(beads=orig_beads, edges=tuple(e for e in sketch.edges if e.label == 'survivor')) sketch = sketch.drop_deleted_inputs() assert orig_beads != sketch.beads assert len(sketch.edges) == 1 assert len(bead(sketch, 'a1').inputs) == 0 assert len(bead(sketch, 'b1').inputs) == 0 assert len(bead(sketch, 'c1').inputs) == 1 assert bead(sketch, 'c1').inputs[0].name == 'survivor'
def test_autofix(self, robot, renamed_e_web_file): robot.cli( f'web load {renamed_e_web_file} auto-rewire color / .. f / save auto.web' ) result = Sketch.from_file(robot.cwd / 'auto.web') # f has inputs, which are not phantom assert len(result.beads) > 1 assert all(bead.is_not_phantom for bead in result.beads) # we get a WARNING for ambiguity assert 'WARNING' in robot.stderr # selected either renamed_e or another_e_copy, we do not know assert "Selected name '" in robot.stderr
def sketch(self) -> Sketch: return Sketch.from_beads(self.beads)
def test_load_save_phantom(self, robot, renamed_e_web_file): # this is not a rewire test, but an issue with load come up during writing rewire tests # and here we already have the fixture robot.cli(f'web load {renamed_e_web_file} save load-save.web') beads = Sketch.from_file(robot.cwd / 'load-save.web').beads self.assert_e_is_phantom(beads)
def test_fixture(self, renamed_e_web_file): beads = Sketch.from_file(renamed_e_web_file).beads self.assert_e_is_phantom(beads)
def test_filter_filtered_out_sink(self, robot, indirect_links_sketch): # f1 is unreachable from sources {b, c}, so it will be not a reachable sink robot.cli('web load computation.web / b c .. c f / save filtered.web') sketch = Sketch.from_file(robot.cwd / 'filtered.web') assert sketch.cluster_by_name.keys() == set('bc')
def test_filter(self, robot, sketch): robot.cli('web load computation.web / b c .. c f / save filtered.web') sketch = Sketch.from_file(robot.cwd / 'filtered.web') assert sketch.cluster_by_name.keys() == set('bcef')