Пример #1
0
    def test_category_with_source(self):
        with self.settings(GIT_REPO_PATH=self.workspace.working_dir):
            c = Category(title="sample title", subtitle="subtitle", localisation=Localisation._for("afr_ZA"))
            c.save()
            c2 = Category(title="sample title", subtitle="subtitle", localisation=Localisation._for("eng_UK"))
            c2.save()

            c = Category.objects.get(pk=c.pk)
            c2 = Category.objects.get(pk=c2.pk)
            c2.source = c
            c2.save()

            [git_c2] = self.workspace.S(eg_models.Category).filter(uuid=c2.uuid)
            self.assertEquals(git_c2.language, "eng_UK")
            [source] = self.workspace.S(eg_models.Category).filter(uuid=git_c2.source)
            self.assertEquals(source.language, "afr_ZA")

            c2.source = None
            c2.save()

            [git_c2] = self.workspace.S(eg_models.Category).filter(uuid=c2.uuid)
            self.assertEquals(git_c2.source, None)