Beispiel #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"
Beispiel #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)
Beispiel #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"
Beispiel #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")
Beispiel #5
0
 def test_value_malformed(self):
     """Testing Value: malformed event"""
     with self.assertRaises(ValueError):
         Value.from_dump("E|0")
Beispiel #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)
Beispiel #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")
Beispiel #8
0
 def test_value_malformed(self):
     """Testing Value: malformed event"""
     with self.assertRaises(ValueError):
         Value.from_dump("E|0")
Beispiel #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)