def test_holder1(false_plugin): """Test the capabilities of the ManufacturersHolder. """ d = [create_driver_infos(m+s, model=m, serie=s, manufacturer=man, kind='Lock-in' if m == 'm1' else 'Other') for man in ('man1', 'man2') for s in ('s', 's2', '') for m in ('m1', 'm2', 'm2') ] h = ManufacturersHolder(plugin=false_plugin) h.update_manufacturers(d) assert len(h.manufacturers) == 2 h.kind = 'Lock-in' for m in h.manufacturers: assert m.kind == h.kind h.use_series = not h.use_series for m in h.manufacturers: assert m.use_series == h.use_series h.kind = 'All' # Remove some drivers h.update_manufacturers(d[:6]+d[9:], removed=True) assert len(h.manufacturers) == 1 assert not h.manufacturers[0]._series # Remove all drivers h.update_manufacturers(d, removed=True) assert not h.manufacturers
def false_plugin_with_holder(false_plugin): """False instrument plugin to test the profile infos. """ p = false_plugin h = ManufacturersHolder(plugin=false_plugin) d = [create_driver_infos(m, model=m, serie='' if m != 'm2' else 'S', manufacturer=man, kind='Lock-in' if m == 'm2' else 'Other') for man in ('manufacturer', 'man2') for m in ('model', 'm2', 'm2') ] h.update_manufacturers(d) p._manufacturers = h return p
def test_holder2(false_plugin): """Test the automatic handling of aliases by ManufacturersHolder. """ d = [create_driver_infos(m+s, model=m, serie=s, manufacturer=man, kind='Lock-in' if m == 'm1' else 'Other') for man in ('man1', 'man2') for s in ('s', 's2', '') for m in ('m1', 'm2', 'm2') ] false_plugin._aliases.contributions = {'man1': ManufacturerAlias(aliases=['man2'])} h = ManufacturersHolder(plugin=false_plugin) h.update_manufacturers(d) assert len(h.manufacturers) == 1
def false_plugin_with_holder(false_plugin): """False instrument plugin to test the profile infos. """ p = false_plugin h = ManufacturersHolder(plugin=false_plugin) d = [ create_driver_infos(m, model=m, serie='' if m != 'm2' else 'S', manufacturer=man, kind='Lock-in' if m == 'm2' else 'Other') for man in ('manufacturer', 'man2') for m in ('model', 'm2', 'm2') ] h.update_manufacturers(d) p._manufacturers = h return p
def test_holder2(false_plugin): """Test the automatic handling of aliases by ManufacturersHolder. """ d = [ create_driver_infos(m + s, model=m, serie=s, manufacturer=man, kind='Lock-in' if m == 'm1' else 'Other') for man in ('man1', 'man2') for s in ('s', 's2', '') for m in ('m1', 'm2', 'm2') ] false_plugin._aliases.contributions = { 'man1': ManufacturerAlias(aliases=['man2']) } h = ManufacturersHolder(plugin=false_plugin) h.update_manufacturers(d) assert len(h.manufacturers) == 1
def test_holder1(false_plugin): """Test the capabilities of the ManufacturersHolder. """ d = [ create_driver_infos(m + s, model=m, serie=s, manufacturer=man, kind='Lock-in' if m == 'm1' else 'Other') for man in ('man1', 'man2') for s in ('s', 's2', '') for m in ('m1', 'm2', 'm2') ] h = ManufacturersHolder(plugin=false_plugin) h.update_manufacturers(d) assert len(h.manufacturers) == 2 h.kind = 'Lock-in' for m in h.manufacturers: assert m.kind == h.kind h.use_series = not h.use_series for m in h.manufacturers: assert m.use_series == h.use_series h.kind = 'All' # Remove some drivers h.update_manufacturers(d[:6] + d[9:], removed=True) assert len(h.manufacturers) == 1 assert not h.manufacturers[0]._series # Remove all drivers h.update_manufacturers(d, removed=True) assert not h.manufacturers