Exemplo n.º 1
0
 def test_dictas_2(self):
     f = DictAs(ExampleResource, null=True)
     self.assertEqual(None, f.clean(None))
     self.assertRaises(ValidationError, f.clean, 'abc')
     self.assertRaises(ValidationError, f.clean, 123)
     self.assertRaises(ValidationError, f.clean, {})
     self.assertRaises(ValidationError, f.clean, {'$': 'test_composite_fields.ExampleResource'})
     self.assertResourceEqual(ExampleResource(name='foo'), f.clean({'name': 'foo'}))
     self.assertResourceEqual(ExampleResource(name='foo'), f.clean({
         '$': 'test_composite_fields.ExampleResource', 'name': 'foo'}))
Exemplo n.º 2
0
 def test_dictas_2(self):
     f = DictAs(ExampleResource, null=True)
     self.assertEqual(None, f.clean(None))
     self.assertRaises(ValidationError, f.clean, 'abc')
     self.assertRaises(ValidationError, f.clean, 123)
     self.assertRaises(ValidationError, f.clean, {})
     self.assertRaises(ValidationError, f.clean, {'$': 'tests.test_composite_fields.ExampleResource'})
     self.assertResourceEqual(ExampleResource(name='foo'), f.clean({'name': 'foo'}))
     self.assertResourceEqual(ExampleResource(name='foo'), f.clean({
         '$': 'tests.test_composite_fields.ExampleResource', 'name': 'foo'}))
Exemplo n.º 3
0
 def test_dictas_2(self):
     f = DictAs(ExampleResource, null=True)
     assert f.clean(None) is None
     pytest.raises(ValidationError, f.clean, 'abc')
     pytest.raises(ValidationError, f.clean, 123)
     pytest.raises(ValidationError, f.clean, {})
     pytest.raises(ValidationError, f.clean, {'$': 'tests.test_fields_composite.ExampleResource'})
     self.assertResourceEqual(ExampleResource(name='foo'), f.clean({'name': 'foo'}))
     self.assertResourceEqual(ExampleResource(name='foo'), f.clean({
         '$': 'tests.test_fields_composite.ExampleResource', 'name': 'foo'}))
Exemplo n.º 4
0
 def test_dictas_1(self):
     f = DictAs(ExampleResource)
     pytest.raises(ValidationError, f.clean, None)
     pytest.raises(ValidationError, f.clean, 'abc')
     pytest.raises(ValidationError, f.clean, 123)
     pytest.raises(ValidationError, f.clean, {})
     pytest.raises(ValidationError, f.clean,
                   {'$': 'tests.test_fields_composite.ExampleResource'})
     self.assertResourceEqual(ExampleResource(name='foo'),
                              f.clean({'name': 'foo'}))
     self.assertResourceEqual(
         ExampleResource(name='foo'),
         f.clean({
             '$': 'tests.test_fields_composite.ExampleResource',
             'name': 'foo'
         }))
Exemplo n.º 5
0
 def test_dictas_ensure_is_resource(self):
     with pytest.raises(TypeError):
         DictAs("an item")
Exemplo n.º 6
0
 def test_dictas_ensure_is_resource(self):
     with self.assertRaises(TypeError):
         DictAs("an item")