Esempio n. 1
0
    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
        })
Esempio n. 2
0
    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
        })
Esempio n. 3
0
    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,
            },
        )
Esempio n. 4
0
    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,
            },
        )
Esempio n. 5
0
 def test_post_contributor_dict_invalid(self):  # pylint: disable=invalid-name
     with self.assertRaises(exceptions.ValidationError):
         ContributorSerializer().to_internal_value({
             'invalid-dictionary':
             True,
         })
Esempio n. 6
0
 def test_post_contributor_dict_invalid(self):
     with self.assertRaises(exceptions.ValidationError):
         ContributorSerializer().to_internal_value({
             "invalid-dictionary":
             True,
         })