def test_timestamp(self):
        test_property_schema = {'type': 'timestamp'}
        # canonical timestamp
        propertyInstance = Property('test_property', '2015-04-01T02:59:43.1Z',
                                    test_property_schema)
        self.assertIsNone(propertyInstance.validate())
        self.assertEqual("2015-04-01T02:59:43.1Z", propertyInstance.value)

        # iso8601 timestamp
        propertyInstance = Property('test_property',
                                    '2015-04-01t21:59:43.10-05:00',
                                    test_property_schema)
        self.assertIsNone(propertyInstance.validate())
        self.assertEqual("2015-04-01t21:59:43.10-05:00",
                         propertyInstance.value)

        # space separated timestamp
        propertyInstance = Property('test_property',
                                    '2015-04-01 21:59:43.10 -5',
                                    test_property_schema)
        self.assertIsNone(propertyInstance.validate())
        self.assertEqual("2015-04-01 21:59:43.10 -5", propertyInstance.value)

        # no time zone timestamp
        propertyInstance = Property('test_property', '2015-04-01 21:59:43.10',
                                    test_property_schema)
        self.assertIsNone(propertyInstance.validate())
        self.assertEqual("2015-04-01 21:59:43.10", propertyInstance.value)

        # date (00:00:00Z)
        propertyInstance = Property('test_property', '2015-04-01',
                                    test_property_schema)
        self.assertIsNone(propertyInstance.validate())
        self.assertEqual("2015-04-01", propertyInstance.value)
 def test_map_entry_schema(self):
     test_property_schema = {'type': 'map',
                             'entry_schema': {'type': 'boolean'}}
     propertyInstance = Property('test_property',
                                 {'valid': True, 'required': True},
                                 test_property_schema)
     self.assertIsNone(propertyInstance.validate())
     self.assertEqual({'valid': True, 'required': True},
                      propertyInstance.value)
 def test_boolean(self):
     test_property_schema = {'type': 'boolean'}
     propertyInstance = Property('test_property', 'true',
                                 test_property_schema)
     self.assertIsNone(propertyInstance.validate())
     propertyInstance = Property('test_property', True,
                                 test_property_schema)
     self.assertIsNone(propertyInstance.validate())
     self.assertEqual(True, propertyInstance.value)
    def test_list_entry_schema(self):
        test_property_schema = {'type': 'list',
                                'entry_schema': {'type': 'string'}}
        propertyInstance = Property('test_property', ['a', 'b'],
                                    test_property_schema)
        self.assertIsNone(propertyInstance.validate())
        self.assertEqual(['a', 'b'], propertyInstance.value)

        schema_snippet = '''
        type: list
        entry_schema:
          type: string
          constraints:
            - min_length: 2
        '''
        test_property_schema = yamlparser.simple_parse(schema_snippet)
        propertyInstance = Property('test_property', ['ab', 'cd'],
                                    test_property_schema)
        self.assertIsNone(propertyInstance.validate())
        self.assertEqual(['ab', 'cd'], propertyInstance.value)
 def test_map(self):
     test_property_schema = {'type': 'map'}
     propertyInstance = Property('test_property', {'a': 'b'},
                                 test_property_schema)
     self.assertIsNone(propertyInstance.validate())
     self.assertEqual({'a': 'b'}, propertyInstance.value)
 def test_list(self):
     test_property_schema = {'type': 'list'}
     propertyInstance = Property('test_property', ['a', 'b'],
                                 test_property_schema)
     self.assertIsNone(propertyInstance.validate())
     self.assertEqual(['a', 'b'], propertyInstance.value)
 def test_float(self):
     test_property_schema = {'type': 'float'}
     propertyInstance = Property('test_property', 0.1,
                                 test_property_schema)
     self.assertIsNone(propertyInstance.validate())
     self.assertEqual(0.1, propertyInstance.value)