def test_post_contributor_dict(self): response = ContributorSerializer(ContributorSerializer().to_internal_value({'id': self.user1.pk})).data self.assertEqual(response, { 'id': self.user1.pk, 'username': self.user1.username, 'first_name': self.user1.first_name, 'last_name': self.user1.last_name })
def test_post_contributor_dict_extra_data(self): # pylint: disable=invalid-name response = ContributorSerializer(ContributorSerializer().to_internal_value({ 'id': self.user1.pk, 'username': '******', 'first_name': 'ignored' })).data self.assertEqual(response, { 'id': self.user1.pk, 'username': self.user1.username, 'first_name': self.user1.first_name, 'last_name': self.user1.last_name })
def test_post_contributor_numeric(self): response = ContributorSerializer( ContributorSerializer().to_internal_value(self.user1.pk)).data self.assertEqual( response, { "id": self.user1.pk, "username": self.user1.username, "first_name": self.user1.first_name, "last_name": self.user1.last_name, }, )
def test_post_contributor_dict_extra_data(self): response = ContributorSerializer( ContributorSerializer().to_internal_value({ "id": self.user1.pk, "username": "******", "first_name": "ignored" })).data self.assertEqual( response, { "id": self.user1.pk, "username": self.user1.username, "first_name": self.user1.first_name, "last_name": self.user1.last_name, }, )
def test_post_contributor_dict_invalid(self): # pylint: disable=invalid-name with self.assertRaises(exceptions.ValidationError): ContributorSerializer().to_internal_value({ 'invalid-dictionary': True, })
def test_post_contributor_dict_invalid(self): with self.assertRaises(exceptions.ValidationError): ContributorSerializer().to_internal_value({ "invalid-dictionary": True, })