def test_init_loads_db_listed_modules_and_works(self): self.mgr = SensorManager(fake_config) assert len(self.mgr.libraries) == 3 assert self.mgr.parse("liba.format_a", None, "thedata") == \ ('formatted by a', "'thedata'") assert self.mgr.parse("liba.format_b", None, "asdf") == \ {"information": 64, "hello": "world"} assert self.mgr.parse("libb.format_c", cfg_c, "asdf") == \ "more functions"
class TestSensorManager: def test_module_includes_base_functions(self): self.mgr = SensorManager(empty_config) assert len(self.mgr.libraries) == 1 assert self.mgr.parse("base.ascii_int", None, "1234") == 1234 assert self.mgr.parse("base.ascii_float", None, "12.32") == 12.32 assert self.mgr.parse("base.string", None, "1234") == "1234" def test_init_loads_db_listed_modules_and_works(self): self.mgr = SensorManager(fake_config) assert len(self.mgr.libraries) == 3 assert self.mgr.parse("liba.format_a", None, "thedata") == \ ('formatted by a', "'thedata'") assert self.mgr.parse("liba.format_b", None, "asdf") == \ {"information": 64, "hello": "world"} assert self.mgr.parse("libb.format_c", cfg_c, "asdf") == \ "more functions" @raises(ValueError) def test_errors_bubble_up_a(self): SensorManager(empty_config).parse("base.ascii_int", None, "non-int") @raises(ValueError) def test_errors_bubble_up_b(self): SensorManager(fake_config).parse("libb.format_d", {}, "hmm") def test_parse_passes_config_dict(self): SensorManager(fake_config).parse("libb.format_c", cfg_c, "data") @raises(ValueError) def test_cannot_use_sensor_not_in_all(self): SensorManager(fake_config).parse("libb.somethingelse", {}, "hah!") def test_repr_describes_manager(self): mgr = SensorManager(empty_config) expect = "<habitat.parser.SensorManager: {num} libraries loaded>" assert repr(mgr) == expect.format(num=1) mgr.load(example_path + "_a", "liba") assert repr(mgr) == expect.format(num=2)
def test_repr_describes_manager(self): mgr = SensorManager(empty_config) expect = "<habitat.parser.SensorManager: {num} libraries loaded>" assert repr(mgr) == expect.format(num=1) mgr.load(example_path + "_a", "liba") assert repr(mgr) == expect.format(num=2)
def test_module_includes_base_functions(self): self.mgr = SensorManager(empty_config) assert len(self.mgr.libraries) == 1 assert self.mgr.parse("base.ascii_int", None, "1234") == 1234 assert self.mgr.parse("base.ascii_float", None, "12.32") == 12.32 assert self.mgr.parse("base.string", None, "1234") == "1234"