コード例 #1
0
ファイル: tests_misc.py プロジェクト: leowmjw/popit_ng
    def test_create_contact_details_without_parent(self):
        data = {"type": "twitter", "value": "sinarproject"}

        serializer = ContactDetailSerializer(data=data, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        with self.assertRaises(ContentObjectNotAvailable):
            serializer.save()
コード例 #2
0
ファイル: tests_misc.py プロジェクト: leowmjw/popit_ng
 def test_create_contact_details(self):
     data = {"type": "twitter", "value": "sinarproject"}
     person = Person.objects.language("en").get(id="8497ba86-7485-42d2-9596-2ab14520f1f4")
     serializer = ContactDetailSerializer(data=data, language="en")
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save(content_object=person)
     person_ = Person.objects.language("en").get(id="8497ba86-7485-42d2-9596-2ab14520f1f4")
     contact_details = person_.contact_details.language("en").get(type="twitter")
     self.assertEqual(contact_details.value, "sinarproject")
コード例 #3
0
    def test_create_persons_contact_details_translated(self):
        # Translatino does not exist yet
        data = {
            "label": "emel mengster"
        }
        person = Person.objects.language('en').get(id='c2a241a0d1fd4483b60af7dd219de22d')
        contact_details = person.contact_details.untranslated().get(id="2525224ad1d94ccfac0f1aa38bf3c2de")

        serializer = ContactDetailSerializer(contact_details, data=data, language="ms", partial=True)
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()
        contact_details = person.contact_details.language("ms").get(id="2525224ad1d94ccfac0f1aa38bf3c2de")
        self.assertEqual(contact_details.label, "emel mengster")
コード例 #4
0
ファイル: tests_misc.py プロジェクト: leowmjw/popit_ng
    def test_test_update_contact_details(self):
        data = {"id": "a66cb422-eec3-4861-bae1-a64ae5dbde61", "value": "0123421222"}

        person = Person.objects.language("en").get(id="ab1a5788e5bae955c048748fa6af0e97")

        contact_details = person.contact_details.untranslated().get(id="a66cb422-eec3-4861-bae1-a64ae5dbde61")
        serializer = ContactDetailSerializer(contact_details, data=data, language="en", partial=True)
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()

        person_ = Person.objects.language("en").get(id="ab1a5788e5bae955c048748fa6af0e97")
        contact_details = person_.contact_details.language("en").get(id="a66cb422-eec3-4861-bae1-a64ae5dbde61")
        self.assertEqual(contact_details.value, "0123421222")
コード例 #5
0
    def test_update_persons_contact_details_translated(self):
        data = {
            "label": "fon sweemeng"
        }

        person = Person.objects.language('en').get(id='ab1a5788e5bae955c048748fa6af0e97')
        # In production language existence is checked and translated version is passed into serializer if exist
        contact_details = person.contact_details.language("ms").get(id="a66cb422-eec3-4861-bae1-a64ae5dbde61")

        serializer = ContactDetailSerializer(contact_details, data=data, language="ms", partial=True)
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()

        contact_details = person.contact_details.language("ms").get(id="a66cb422-eec3-4861-bae1-a64ae5dbde61")
        self.assertEqual(contact_details.label, "fon sweemeng")