Ejemplo n.º 1
0
 def test_get_human_readable_type_null_boolean(self):
     with patch.object(SerialisableModel, "_get_field") as get_field:
         get_field.return_value = models.NullBooleanField()
         self.assertEqual(
             SerialisableModel.get_human_readable_type("tree"),
             "Either True, False or None",
         )
Ejemplo n.º 2
0
 def test_get_human_readable_type_datetime_field(self):
     with patch.object(SerialisableModel, "_get_field") as get_field:
         get_field.return_value = models.DateTimeField()
         self.assertEqual(
             SerialisableModel.get_human_readable_type("tree"),
             "Date & Time",
         )
Ejemplo n.º 3
0
 def test_build_field_schema(self):
     schema = SerialisableModel.build_field_schema()
     expected = [
         {
             'model': 'SerialisableModel',
             'description': None,
             'enum': None,
             'lookup_list': None,
             'type': 'string',
             'name': 'pid',
             'default': None,
             'title': u'Pid'
         },
         {
             'model': 'SerialisableModel',
             'description': None,
             'enum': None,
             'lookup_list': 'hat',
             'type': 'string',
             'name': 'hatty',
             'default': None,
             'title': 'Hatty'
         }
     ]
     self.assertEqual(schema, expected)
Ejemplo n.º 4
0
 def test_build_field_schema(self):
     schema = SerialisableModel.build_field_schema()
     expected = [
         {
             'model': 'SerialisableModel',
             'description': None,
             'enum': None,
             'lookup_list': None,
             'type': 'string',
             'name': 'pid',
             'default': None,
             'title': u'Pid'
         },
         {
             'model': 'SerialisableModel',
             'description': None,
             'enum': None,
             'lookup_list': 'hat',
             'type': 'string',
             'name': 'hatty',
             'default': None,
             'title': 'Hatty'
         }
     ]
     self.assertEqual(schema, expected)
Ejemplo n.º 5
0
 def test_get_human_readable_type_datetime_field(self):
         with patch.object(SerialisableModel, "_get_field") as get_field:
             get_field.return_value = models.DateTimeField()
             self.assertEqual(
                 SerialisableModel.get_human_readable_type("tree"),
                 "Date & Time",
             )
Ejemplo n.º 6
0
 def test_get_human_readable_type_null_boolean(self):
         with patch.object(SerialisableModel, "_get_field") as get_field:
             get_field.return_value = models.NullBooleanField()
             self.assertEqual(
                 SerialisableModel.get_human_readable_type("tree"),
                 "Either True, False or None",
             )
Ejemplo n.º 7
0
 def test_get_fieldnames(self):
     names = SerialisableModel._get_fieldnames_to_serialize()
     expected = set([
         'id',
         'pid',
         'hatty',
     ])
     self.assertEqual(expected, set(names))
Ejemplo n.º 8
0
 def test_get_fieldnames(self):
     names = SerialisableModel._get_fieldnames_to_serialize()
     expected = set([
         'id',
         'pid',
         'hatty',
     ])
     self.assertEqual(expected, set(names))
Ejemplo n.º 9
0
 def test_get_human_readable_type_numeric_field(self):
     numeric_fields = [
         models.AutoField, models.BigIntegerField, models.IntegerField,
         models.FloatField, models.DecimalField
     ]
     for numeric_field in numeric_fields:
         with patch.object(SerialisableModel, "_get_field") as get_field:
             get_field.return_value = numeric_field()
             self.assertEqual(
                 SerialisableModel.get_human_readable_type("tree"),
                 "Number")
Ejemplo n.º 10
0
 def test_get_human_readable_type_numeric_field(self):
     numeric_fields = [
         models.AutoField,
         models.BigIntegerField,
         models.IntegerField,
         models.FloatField,
         models.DecimalField
     ]
     for numeric_field in numeric_fields:
         with patch.object(SerialisableModel, "_get_field") as get_field:
             get_field.return_value = numeric_field()
             self.assertEqual(
                 SerialisableModel.get_human_readable_type("tree"),
                 "Number"
             )
Ejemplo n.º 11
0
 def test_get_field_type(self):
     self.assertEqual(models.ForeignKey,
                      SerialisableModel._get_field_type('patient_id'))
Ejemplo n.º 12
0
 def test_get_field_type(self):
     self.assertEqual(models.ForeignKey, SerialisableModel._get_field_type('patient_id'))