Ejemplo n.º 1
0
 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')
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
# 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
csl_config = config['targets']['console']
t = ConsoleDisplay(**csl_config)
app.add_target(t)

# Target 2
tsl_config = config['targets']['thingspeak']
t = ThingSpeakLogger(**tsl_config)
app.add_target(t)

# Target 3
csv_config = config['targets']['csv_file']
t = TextLogger(**csv_config)
app.add_target(t)
Ejemplo n.º 4
0
 def test_cannot_start_without_target(self):
     a = Controller()
     s = mock_source()
     a.add_source(s)
     with pytest.raises(ConfigurationError):
         a.run()
Ejemplo n.º 5
0
 def test_can_add_source(self):
     a = Controller()
     s = mock_source('Mock Source')
     a.add_source(s)
     assert a.get_source_names() == ('Mock Source',)