예제 #1
0
    def test_create_without_parent(self):
        data = {"url": "http://twitter.com/sweemeng"}

        serializer = LinkSerializer(data=data, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        with self.assertRaises(ContentObjectNotAvailable):
            serializer.save()
예제 #2
0
    def test_update_links(self):
        data = {"id": "a4ffa24a9ef3cbcb8cfaa178c9329367", "note": "just a random repo"}
        link = Link.objects.untranslated().get(id="a4ffa24a9ef3cbcb8cfaa178c9329367")
        serializer = LinkSerializer(link, data=data, partial=True, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()

        person = Person.objects.language("en").get(id="ab1a5788e5bae955c048748fa6af0e97")
        url = person.links.language("en").get(id="a4ffa24a9ef3cbcb8cfaa178c9329367")
        self.assertEqual(url.note, "just a random repo")
예제 #3
0
    def test_create_links(self):
        data = {"url": "http://twitter.com/sweemeng"}

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

        serializer = LinkSerializer(data=data, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save(content_object=person)

        person_ = Person.objects.language("en").get(id="ab1a5788e5bae955c048748fa6af0e97")
        url = person_.links.language("en").get(url="http://twitter.com/sweemeng")
        self.assertEqual(url.url, "http://twitter.com/sweemeng")