Esempio n. 1
0
 def test_graph_dump(self):
     sen = home_service.HumiditySensor('sensor1')
     sys = home_service.System('s1', [sen])
     sys.record_obs()
     # out = io.BytesIO()
     out = 'tmp/s1.ttl'
     sys.dump_rdf(out)
Esempio n. 2
0
 def setUp(self):
     self.uid_sen = 'sensor1'
     self.sen = home_service.HumiditySensor(self.uid_sen)
     self.uid_sen2 = 'sensor2'
     self.sen2 = home_service.TemperatureSensor(self.uid_sen2)
     self.uid_sys = 's1'
     self.sys = home_service.System(self.uid_sys, [self.sen, self.sen2])
Esempio n. 3
0
 def test_record_obs(self):
     hs = home_service.HumiditySensor('hs1')
     s = home_service.System('s1', [hs])
     s.record_obs()
     # obs1 = s.obs[hs.uid]
     obs1 = s.sensors[0].observations
     self.assertEqual(len(obs1), 1)
     self.assertAlmostEqual(obs1[0]['value'], 40, delta=20)
Esempio n. 4
0
 def test_init_observations(self):
     sen = home_service.HumiditySensor('sensor1')
     sen2 = home_service.TemperatureSensor('sensor2')
     sys = home_service.System('s1', [sen, sen2])
     sys.init_observations()
     # out = io.BytesIO()
     out = 'tmp/s1.ttl'
     sys.dump_rdf(out)
Esempio n. 5
0
 def test_graph_init(self):
     sys = home_service.System('s1')
     # for s, p, o in sys.graph.triples((None, RDF.type, None)):
     #     print(s, p, o)
     self.assertEqual(len(sys.graph), 1)