Esempio n. 1
0
    def test_value(self):
        """Testing Value: dump()"""
        value = Value("example", 42, nodename="test", timestamp=0)
        assert value.is_value()
        assert value.dump() == "V|0|test|example|42.0|g"

        value = Value("example", 42, nodename="test")
        assert value.dump() == "V|%d|test|example|42.0|g" % (int(time.time()),)
        assert value.value_id == "test.example"
Esempio n. 2
0
    def test_log_plugin(self):
        config = Config()
        channel = Channel()
        channel.subscribe("internal.log")
        channel.publish(Value("test", 0))

        kls = log.LogPlugin(config, channel)
        kls.plugin_name = "internal.log"
        kls.write(channel)
Esempio n. 3
0
    def test_value(self):
        """Testing Value: dump()"""
        value = Value("example", 42, nodename="test", timestamp=0)
        assert value.is_value()
        assert value.dump() == "V|0|test|example|42.0|g"

        value = Value("example", 42, nodename="test")
        assert value.dump() == "V|%d|test|example|42.0|g" % (int(
            time.time()), )
        assert value.value_id == "test.example"
Esempio n. 4
0
 def test_value_invalid_type(self):
     """Testing Value: invalid value type"""
     with self.assertRaises(ValueError):
         Value.from_dump("V|0|test|example|42.0|ZZ")
Esempio n. 5
0
 def test_value_malformed(self):
     """Testing Value: malformed event"""
     with self.assertRaises(ValueError):
         Value.from_dump("E|0")
Esempio n. 6
0
 def test_value_dump(self):
     """Testing Value: from_dump()"""
     value = Value.from_dump("V|0|test|example|42.0|g")
     assert value.dump() == "V|0|test|example|42.0|g" == repr(value)
Esempio n. 7
0
 def test_value_invalid_type(self):
     """Testing Value: invalid value type"""
     with self.assertRaises(ValueError):
         Value.from_dump("V|0|test|example|42.0|ZZ")
Esempio n. 8
0
 def test_value_malformed(self):
     """Testing Value: malformed event"""
     with self.assertRaises(ValueError):
         Value.from_dump("E|0")
Esempio n. 9
0
 def test_value_dump(self):
     """Testing Value: from_dump()"""
     value = Value.from_dump("V|0|test|example|42.0|g")
     assert value.dump() == "V|0|test|example|42.0|g" == repr(value)