def test_with_missing_provider(self): data = {'id':1, 'url':'http://facebook.com'} serializer = SocialSerializer(data=data) self.assertFalse(serializer.is_valid())
def test_with_missing_url(self): data = {'id':1, 'provider':'facebook'} serializer = SocialSerializer(data=data) self.assertFalse(serializer.is_valid())
def test_with_valid_data(self): data = {'id':1, 'provider':'facebook', 'url':'http://facebook.com'} serializer = SocialSerializer(data=data) self.assertTrue(serializer.is_valid()) self.assertEqual(dict(serializer.validated_data), data)