Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
    def test_custom(self):
        boolean_array = types.Array(element_template=types.Boolean(),
                                    description="boolean")
        self.assertEqual(boolean_array.description, "boolean")

        float_array = types.Array(element_template=types.Float(),
                                  description="float")
        self.assertEqual(float_array.description, "float")

        integer_array = types.Array(element_template=types.Integer(),
                                    description="integer")
        self.assertEqual(integer_array.description, "integer")

        string_array = types.Array(element_template=types.String(),
                                   description="string")
        self.assertEqual(string_array.description, "string")

        date_array = types.Array(element_template=types.Date(),
                                 description="date")
        self.assertEqual(date_array.description, "date")

        datetime_array = types.Array(element_template=types.DateTime(),
                                     description="datetime")
        self.assertEqual(datetime_array.description, "datetime")

        time_array = types.Array(element_template=types.Date(),
                                 description="time")
        self.assertEqual(time_array.description, "time")
Exemplo n.º 3
0
 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())
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
    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))
Exemplo n.º 6
0
    def test_datetime_default(self):
        datetime_type = types.DateTime()

        blueprint = datetime_type.blueprint()
        blueprint["map_name"] = "a_b"
        datetime_meta = AttributeMetaData("created_date", blueprint)
        self.assertEqual(datetime_meta.name, "created_date")
        self.assertEqual(datetime_meta.map_name, "a_b")
        self.assertEqual(datetime_meta.cc, "CreatedDate")
        self.assertEqual(datetime_meta.ccif, "createdDate")
        self.assertEqual(datetime_meta.blueprint_type, "datetime")
        self.assertEqual(datetime_meta.client_class_name, "DateTime")
        self.assertEqual(datetime_meta.required, "true")
        self.assertEqual(datetime_meta.default, "null")
        self.assertEqual(datetime_meta.timezone, "false")
        self.assertEqual(datetime_meta.utc, "false")
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
    def test_datetime_given_values(self):
        datetime_type = types.DateTime(
            required=False,
            default=types.DateTime.NOW,
            timezone=True,
            utc=True
        )

        blueprint = datetime_type.blueprint()
        blueprint["map_name"] = "a_b"
        datetime_meta = AttributeMetaData("created_date", blueprint)
        self.assertEqual(datetime_meta.name, "created_date")
        self.assertEqual(datetime_meta.map_name, "a_b")
        self.assertEqual(datetime_meta.cc, "CreatedDate")
        self.assertEqual(datetime_meta.ccif, "createdDate")
        self.assertEqual(datetime_meta.blueprint_type, "datetime")
        self.assertEqual(datetime_meta.client_class_name, "DateTime")
        self.assertEqual(datetime_meta.required, "false")
        self.assertEqual(datetime_meta.default, "prestans.types.DateTime.NOW")
        self.assertEqual(datetime_meta.timezone, "true")
        self.assertEqual(datetime_meta.utc, "true")
Exemplo n.º 9
0
 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)