def test_converter_serialize(self):
     a_property_set = PropertySet('Test')
     a_property_set.properties.append(Property('Test', 100))
     self.assertEqual(
         Converter.serialize(a_property_set),
         '{"name": "Test", "type": "PropertySet", "properties": ['
         '{"name": "Test", "value": 100, "type": "Property"}]}')
    def test_property_create(self):

        a_property = Property('Test', 100)

        self.assertEquals(a_property.type, 'Property')
        self.assertEquals(a_property.name, 'Test')
        self.assertEquals(a_property.value, 100)
Example #3
0
 def test_composer_doFile_demo_input_pretty(self):
     #doIt(self, listOfSets, pretty)
     print "DoFile Test mit den Bereitgestellten Testdaten"
     property_set = PropertySet('Test Property Set 1')
     property_set.properties.append(Property('Width', 100))
     property_set.properties.append(Property('Height', 100))
     property_set.properties.append(Property('ThermalTransmittance', 0.9))
     property_set.properties.append(Property('FireResistance', 'Class 4'))
     property_set.properties.append(Property('WindLoadRating', 'Class 3'))
     listOfSets = []
     listOfSets.append(property_set)
     a_composer = PropertySetToJsonComposer()
     a_composer.doFile(listOfSets, 1, "./demodata/demo_pretty.json")
     actual = hashlib.md5(open("./demodata/demo_pretty.json",
                               'rb').read()).hexdigest()
     self.assertEquals("500fa32457f264fc2e32129b31f7e944", actual)
Example #4
0
 def test_composer_doprint_demo_input(self):
     #doIt(self, listOfSets, pretty)
     print "DoPrint Test mit den Bereitgestellten Testdaten"
     property_set = PropertySet('Test Property Set 1')
     property_set.properties.append(Property('Width', 100))
     property_set.properties.append(Property('Height', 100))
     property_set.properties.append(Property('ThermalTransmittance', 0.9))
     property_set.properties.append(Property('FireResistance', 'Class 4'))
     property_set.properties.append(Property('WindLoadRating', 'Class 3'))
     listOfSets = []
     listOfSets.append(property_set)
     a_composer = PropertySetToJsonComposer()
     a_composer.doPrint(listOfSets, 0)
     a_composer.doFile(listOfSets, 0, "./demodata/demo_md5.json")
     actual = hashlib.md5(open("./demodata/demo_md5.json",
                               'rb').read()).hexdigest()
     self.assertEquals("5ce5fe11238323764e8d9c81d736310d", actual)
    def test_property_repr(self):
        a_property0 = Property('Test', 100)
        self.assertEqual(a_property0.__repr__(),
                         '{"name": "Test", "value": 100, "type": "Property"}')

        a_property1 = Property('Test', 1.23)
        self.assertEqual(
            a_property1.__repr__(),
            '{"name": "Test", "value": 1.23, "type": "Property"}')

        a_property2 = Property('Test', "test")
        self.assertEqual(
            a_property2.__repr__(),
            '{"name": "Test", "value": "test", "type": "Property"}')
    def test_propertyset_repr(self):
        a_property_set = PropertySet('Test')
        self.assertEqual(
            a_property_set.__repr__(),
            '{"name": "Test", "type": "PropertySet", "properties": []}')

        a_property_set.properties.append(Property('Test', 100))
        self.assertEqual(
            a_property_set.__repr__(),
            '{"name": "Test", "type": "PropertySet", "properties": ['
            '{"name": "Test", "value": 100, "type": "Property"}]}')
Example #7
0
 def createProps(self, keyValues):
     x = []
     print keyValues
     if (self.allowIncomplete == 1
             or ("name" in keyValues and "value" in keyValues
                 and "type" in keyValues)):
         name = self.__readValue(keyValues, "name")
         value = self.__readValue(keyValues, "value")
         type = self.__readValue(keyValues, "type")
         if (self.allowIncomplete == 1 or
             (type == Property.DEFAULT_TYPE and self.__checkIsNotEmpty(name)
              and self.__checkIsNotEmpty(value))):
             x.append(Property(name, value))
         else:
             print("Fail: ", name, " Property-Data ignored")
     else:
         print("Property corrupt", keyValues)
     return x