Exemplo n.º 1
0
 def test_blank_field(self):
     """Test if blank fields are optional but not null."""
     type_info = Container.get_flat_type_info(Container)
     blank_field = type_info['blank_field']
     self.assertEqual(blank_field.__name__, 'NormalizedString')
     self.assertEqual(blank_field.Attributes.min_occurs, 0)
     self.assertFalse(blank_field.Attributes.nullable)
Exemplo n.º 2
0
 def test_blank_field(self):
     """Test if blank fields are optional but not null."""
     type_info = Container.get_flat_type_info(Container)
     blank_field = type_info['blank_field']
     self.assertEqual(blank_field.__name__, 'NormalizedString')
     self.assertEqual(blank_field.Attributes.min_occurs, 0)
     self.assertFalse(blank_field.Attributes.nullable)
Exemplo n.º 3
0
 def test_regex_pattern_mappiing(self):
     """Test if regex pattern is mapped from django model."""
     type_info = Container.get_flat_type_info(Container)
     email_field = type_info['email_field']
     self.assertEqual(email_field.__name__, 'Unicode')
     self.assertIsNotNone(email_field.Attributes.pattern)
     self.assertEqual(email_field.Attributes.min_occurs, 1)
     self.assertFalse(email_field.Attributes.nullable)
Exemplo n.º 4
0
 def test_regex_pattern_mapping(self):
     """Test if regex pattern is mapped from django model."""
     type_info = Container.get_flat_type_info(Container)
     email_field = type_info['email_field']
     self.assertEqual(email_field.__name__, 'Unicode')
     self.assertIsNotNone(email_field.Attributes.pattern)
     self.assertEqual(email_field.Attributes.min_occurs, 1)
     self.assertFalse(email_field.Attributes.nullable)
Exemplo n.º 5
0
 def test_length_validators_field(self):
     """Test if length validators are correctly mapped."""
     type_info = Container.get_flat_type_info(Container)
     length_validators_field = type_info['length_validators_field']
     self.assertEqual(length_validators_field.__name__, 'NormalizedString')
     self.assertEqual(length_validators_field.Attributes.min_occurs, 1)
     self.assertTrue(length_validators_field.Attributes.nullable)
     self.assertEqual(length_validators_field.Attributes.min_len, 3)
     self.assertEqual(length_validators_field.Attributes.max_len, 10)
Exemplo n.º 6
0
 def test_length_validators_field(self):
     """Test if length validators are correctly mapped."""
     type_info = Container.get_flat_type_info(Container)
     length_validators_field = type_info['length_validators_field']
     self.assertEqual(length_validators_field.__name__, 'NormalizedString')
     self.assertEqual(length_validators_field.Attributes.min_occurs, 1)
     self.assertTrue(length_validators_field.Attributes.nullable)
     self.assertEqual(length_validators_field.Attributes.min_len, 3)
     self.assertEqual(length_validators_field.Attributes.max_len, 10)
Exemplo n.º 7
0
 def test_exclude(self):
     """Test if excluded field is not mapped."""
     type_info = Container.get_flat_type_info(Container)
     self.assertIn('id', type_info)
     self.assertNotIn('excluded_field', type_info)
Exemplo n.º 8
0
 def test_regex_pattern_mappiing(self):
     """Test if regex pattern is mapped from django model."""
     type_info = Container.get_flat_type_info(Container)
     field_mapper = default_model_mapper.get_field_mapper('EmailField')
     self.assertEqual(type_info['email_field'].__name__, 'Unicode')
     self.assertIsNotNone(type_info['email_field'].Attributes.pattern)
Exemplo n.º 9
0
 def test_exclude(self):
     """Test if excluded field is not mapped."""
     type_info = Container.get_flat_type_info(Container)
     self.assertIn('id', type_info)
     self.assertNotIn('excluded_field', type_info)
Exemplo n.º 10
0
 def test_pk_mapping(self):
     """Test if primary key is mapped as optional but not nillable."""
     type_info = Container.get_flat_type_info(Container)
     pk_field = type_info['id']
     self.assertEqual(pk_field.Attributes.min_occurs, 0)
     self.assertFalse(pk_field.Attributes.nullable)
Exemplo n.º 11
0
 def test_regex_pattern_mappiing(self):
     """Test if regex pattern is mapped from django model."""
     type_info = Container.get_flat_type_info(Container)
     field_mapper = default_model_mapper.get_field_mapper('EmailField')
     self.assertEqual(type_info['email_field'].__name__, 'Unicode')
     self.assertIsNotNone(type_info['email_field'].Attributes.pattern)
Exemplo n.º 12
0
 def test_blank_as_dict(self):
     """Test if blank field is omitted in as_dict representation."""
     container = Container()
     container_dict = container.as_dict()
     self.assertNotIn('blank_field', container_dict)
Exemplo n.º 13
0
 def test_pk_mapping(self):
     """Test if primary key is mapped as optional but not nillable."""
     type_info = Container.get_flat_type_info(Container)
     pk_field = type_info['id']
     self.assertEqual(pk_field.Attributes.min_occurs, 0)
     self.assertFalse(pk_field.Attributes.nullable)