def test_filter_only(self): exp = (["intel", "scsi"], ["intel", "virtio"]) tree_yaml_path = os.path.join(BASEDIR, "tests/.data/mux-selftest.yaml") tree_yaml_url = f"/:{tree_yaml_path}" act = yaml_to_mux.create_from_yaml([tree_yaml_url]) act = mux.apply_filters(act, ("/hw/cpu/intel", "/distro/fedora", "/hw")) act = tuple(mux.MuxTree(act)) self.assertEqual(act, exp)
def test_filter_only(self): exp = (['intel', 'scsi'], ['intel', 'virtio']) tree_yaml_path = os.path.join(BASEDIR, 'tests/.data/mux-selftest.yaml') tree_yaml_url = f'/:{tree_yaml_path}' act = yaml_to_mux.create_from_yaml([tree_yaml_url]) act = mux.apply_filters(act, ('/hw/cpu/intel', '/distro/fedora', '/hw')) act = tuple(mux.MuxTree(act)) self.assertEqual(act, exp)
def setUp(self): yaml_path = os.path.join(BASEDIR, "tests/.data/mux-selftest-params.yaml") yaml_url = f"/:{yaml_path}" yamls = yaml_to_mux.create_from_yaml([yaml_url]) self.yamls = iter(mux.MuxTree(yamls)) self.params1 = parameters.AvocadoParams(next(self.yamls), ["/ch0/*", "/ch1/*"]) next(self.yamls) # Skip 2nd next(self.yamls) # and 3rd self.params2 = parameters.AvocadoParams(next(self.yamls), ["/ch1/*", "/ch0/*"])
def test_empty(self): act = tuple(mux.MuxTree(mux.MuxTreeNode())) self.assertEqual( act, ( [ "", ], ), )
def test_partial(self): exp = ( ["intel", "scsi"], ["intel", "virtio"], ["amd", "scsi"], ["amd", "virtio"], ["arm", "scsi"], ["arm", "virtio"], ) act = tuple(mux.MuxTree(self.mux_tree.children[0])) self.assertEqual(act, exp)
def setUp(self): yaml_path = os.path.join(BASEDIR, 'tests/.data/mux-selftest-params.yaml') yaml_url = '/:%s' % yaml_path yamls = yaml_to_mux.create_from_yaml([yaml_url]) self.yamls = iter(mux.MuxTree(yamls)) self.params1 = parameters.AvocadoParams(next(self.yamls), ['/ch0/*', '/ch1/*']) next(self.yamls) # Skip 2nd next(self.yamls) # and 3rd self.params2 = parameters.AvocadoParams(next(self.yamls), ['/ch1/*', '/ch0/*'])
def test_filter_out(self): tree_yaml_path = os.path.join(BASEDIR, 'tests/.data/mux-selftest.yaml') tree_yaml_url = f'/:{tree_yaml_path}' act = yaml_to_mux.create_from_yaml([tree_yaml_url]) act = mux.apply_filters(act, None, ('/hw/cpu/intel', '/distro/fedora', '/distro')) act = tuple(mux.MuxTree(act)) self.assertEqual(len(act), 4) self.assertEqual(len(act[0]), 3) str_act = str(act) self.assertIn('amd', str_act) self.assertIn('prod', str_act) self.assertNotIn('intel', str_act) self.assertNotIn('fedora', str_act)
def test_filter_out(self): tree_yaml_path = os.path.join(BASEDIR, "tests/.data/mux-selftest.yaml") tree_yaml_url = f"/:{tree_yaml_path}" act = yaml_to_mux.create_from_yaml([tree_yaml_url]) act = mux.apply_filters( act, None, ("/hw/cpu/intel", "/distro/fedora", "/distro") ) act = tuple(mux.MuxTree(act)) self.assertEqual(len(act), 4) self.assertEqual(len(act[0]), 3) str_act = str(act) self.assertIn("amd", str_act) self.assertIn("prod", str_act) self.assertNotIn("intel", str_act) self.assertNotIn("fedora", str_act)
def test_create_variants(self): tree_yaml_path = os.path.join(BASEDIR, 'tests/.data/mux-selftest.yaml') tree_yaml_url = f'/:{tree_yaml_path}' from_file = yaml_to_mux.create_from_yaml([tree_yaml_url]) from_file = mux.MuxTree(from_file) self.assertEqual(self.mux_full, tuple(from_file))
def test_partial(self): exp = (['intel', 'scsi'], ['intel', 'virtio'], ['amd', 'scsi'], ['amd', 'virtio'], ['arm', 'scsi'], ['arm', 'virtio']) act = tuple(mux.MuxTree(self.mux_tree.children[0])) self.assertEqual(act, exp)
def setUp(self): tree_yaml_path = os.path.join(BASEDIR, 'tests/.data/mux-selftest.yaml') tree_yaml_url = f'/:{tree_yaml_path}' self.mux_tree = yaml_to_mux.create_from_yaml([tree_yaml_url]) self.mux_full = tuple(mux.MuxTree(self.mux_tree))