def test_custom(self): self.assertEqual( types.Array(element_template=types.Boolean(), max_length=1).max_length, 1) self.assertEqual( types.Array(element_template=types.Float(), max_length=2).max_length, 2) self.assertEqual( types.Array(element_template=types.Integer(), max_length=3).max_length, 3) self.assertEqual( types.Array(element_template=types.String(), max_length=4).max_length, 4) self.assertEqual( types.Array(element_template=types.Date(), max_length=5).max_length, 5) self.assertEqual( types.Array(element_template=types.DateTime(), max_length=6).max_length, 6) self.assertEqual( types.Array(element_template=types.Time(), max_length=7).max_length, 7) self.assertEqual( types.Array(element_template=types.Model(), max_length=8).max_length, 8)
def test_data_structure(self): self.assertIsNone( types.Array(element_template=types.Date()).attribute_rewrite_map()) self.assertIsNone( types.Array( element_template=types.DateTime()).attribute_rewrite_map()) self.assertIsNone( types.Array(element_template=types.Time()).attribute_rewrite_map())
class MyModel(types.Model): boolean = types.Boolean() date = types.Date() datetime = types.DateTime() float = types.Float() integer = types.Integer() string = types.String() sub = SubModel() time = types.Time()
def test_time_default(self): datetime_type = types.Time() blueprint = datetime_type.blueprint() blueprint["map_name"] = "a_b" datetime_meta = AttributeMetaData("opening_time", blueprint) self.assertEqual(datetime_meta.name, "opening_time") self.assertEqual(datetime_meta.map_name, "a_b") self.assertEqual(datetime_meta.cc, "OpeningTime") self.assertEqual(datetime_meta.ccif, "openingTime") self.assertEqual(datetime_meta.blueprint_type, "time") self.assertEqual(datetime_meta.client_class_name, "Time") self.assertEqual(datetime_meta.required, "true") self.assertEqual(datetime_meta.default, "null")
def test_data_structure(self): date_array = types.Array(element_template=types.Date()) self.assertFalse(date_array.get_attribute_filter()) self.assertFalse(date_array.get_attribute_filter(False)) self.assertTrue(date_array.get_attribute_filter(True)) datetime_array = types.Array(element_template=types.DateTime()) self.assertFalse(datetime_array.get_attribute_filter()) self.assertFalse(datetime_array.get_attribute_filter(False)) self.assertTrue(datetime_array.get_attribute_filter(True)) time_array = types.Array(element_template=types.Time()) self.assertFalse(time_array.get_attribute_filter()) self.assertFalse(time_array.get_attribute_filter(False)) self.assertTrue(time_array.get_attribute_filter(True))
def test_default(self): self.assertIsNone( types.Array(element_template=types.Boolean()).min_length) self.assertIsNone( types.Array(element_template=types.Float()).min_length) self.assertIsNone( types.Array(element_template=types.Integer()).min_length) self.assertIsNone( types.Array(element_template=types.String()).min_length) self.assertIsNone( types.Array(element_template=types.Date()).min_length) self.assertIsNone( types.Array(element_template=types.DateTime()).min_length) self.assertIsNone( types.Array(element_template=types.Time()).min_length) self.assertIsNone( types.Array(element_template=types.Model()).min_length)
def test_time_given_values(self): datetime_type = types.Time( required=False, default=types.Time.NOW ) blueprint = datetime_type.blueprint() blueprint["map_name"] = "a_b" datetime_meta = AttributeMetaData("opening_time", blueprint) self.assertEqual(datetime_meta.name, "opening_time") self.assertEqual(datetime_meta.map_name, "a_b") self.assertEqual(datetime_meta.cc, "OpeningTime") self.assertEqual(datetime_meta.ccif, "openingTime") self.assertEqual(datetime_meta.blueprint_type, "time") self.assertEqual(datetime_meta.client_class_name, "Time") self.assertEqual(datetime_meta.required, "false") self.assertEqual(datetime_meta.default, "prestans.types.Time.NOW")
def test_data_structure(self): self.assertFalse(types.Array(element_template=types.Date()).is_scalar) self.assertFalse( types.Array(element_template=types.DateTime()).is_scalar) self.assertFalse(types.Array(element_template=types.Time()).is_scalar)