def test_can_add_2_targets(self): a = Controller() t1 = mock_target('Mock Target 1') t2 = mock_target('Mock Target 2') a.add_target(t1) a.add_target(t2) assert a.get_target_names() == ('Mock Target 1', 'Mock Target 2')
def test_can_add_2_sources(self): a = Controller() s1 = mock_source('Source 1') s2 = mock_source('Source 2') a.add_source(s1) a.add_source(s2) assert a.get_source_names() == ('Source 1', 'Source 2')
def mock_application(): tf = mock.Mock() df = mock.Mock() a = Controller(timefcn=tf, delayfcn=df) s = mock_source('Source 1') a.add_source(s) for count in range(2): t = mock_target('Target {}'.format(count + 1)) a.add_target(t) a._read_sources = mock.Mock(wraps=a._read_sources) a._update_targets = mock.Mock(wraps=a._update_targets) return a
from sensormesh.text import TextLogger from sensormesh.twitter import TwitterUpdate # Configure logging with open('conf_logging.yaml', 'r') as f: log_config = yaml.load(f) log_config['disable_existing_loggers'] = False logging.config.dictConfig(log_config) # Configuration loader class cfgr = ConfigLoader() config = cfgr.load_config_file('conf_therm.yaml') # Configure App app = Controller() tgr_config = config['trigger'] app.set_steps(**tgr_config) # Source o = W1ThermSensor() print(o) s = DataSourceWrapper( fields=['temperature'], source=o.get_temperature, name=str(o) ) app.add_source(s) # Target 1
def test_cannot_start_without_source(self): a = Controller() t = mock_target() a.add_target(t) with pytest.raises(ConfigurationError): a.run()
def test_can_add_target(self): a = Controller() t = mock_target('Mock Target') a.add_target(t) assert a.get_target_names() == ('Mock Target',)
def test_can_add_source(self): a = Controller() s = mock_source('Mock Source') a.add_source(s) assert a.get_source_names() == ('Mock Source',)