Exemplo n.º 1
0
    def test_add_project(self):
        """Checks that we can add a project successfully."""
        response = self.client.get("/admin/projects.html")
        self.assertContains(response, "<a href='/projects/pootle/admin.html'>pootle</a>")
        self.assertContains(response, "<a href='/projects/terminology/admin.html'>terminology</a>")

        add_dict = {
            "code": "testproject",
            "localfiletype": "xlf",
            "fullname": "Test Project",
            "checkstyle": "standard",
            "treestyle": "gnu",
            }

        response = self.client.post("/admin/projects.html", formset_dict([add_dict]))
        self.assertContains(response, "<a href='/projects/testproject/admin.html'>testproject</a>")

        # check for the actual model
        testproject = Project.objects.get(code="testproject")

        self.assertTrue(testproject)
        self.assertEqual(testproject.fullname, add_dict['fullname'])
        self.assertEqual(testproject.checkstyle, add_dict['checkstyle'])
        self.assertEqual(testproject.localfiletype, add_dict['localfiletype'])
        self.assertEqual(testproject.treestyle, add_dict['treestyle'])
Exemplo n.º 2
0
    def test_add_project(self):
        """Checks that we can add a project successfully."""
        response = self.client.get("/admin/projects.html")
        self.assertContains(
            response, "<a href='/projects/tutorial/admin.html'>tutorial</a>")
        self.assertContains(
            response,
            "<a href='/projects/terminology/admin.html'>terminology</a>")
        en = Language.objects.get(code='en')
        add_dict = {
            "code": "testproject",
            "localfiletype": "xlf",
            "fullname": "Test Project",
            "checkstyle": "standard",
            "source_language": en.id,
            "treestyle": "gnu",
        }

        response = self.client.post("/admin/projects.html",
                                    formset_dict([add_dict]))
        self.assertContains(
            response,
            "<a href='/projects/testproject/admin.html'>testproject</a>")

        # check for the actual model
        testproject = Project.objects.get(code="testproject")

        self.assertTrue(testproject)
        self.assertEqual(testproject.fullname, add_dict['fullname'])
        self.assertEqual(testproject.checkstyle, add_dict['checkstyle'])
        self.assertEqual(testproject.localfiletype, add_dict['localfiletype'])
        self.assertEqual(testproject.treestyle, add_dict['treestyle'])
Exemplo n.º 3
0
    def test_add_project_language(self):
        """Tests that we can add a language to a project, then access
        its page when there are no files."""
        fish = Language(code="fish", fullname="fish")
        fish.save()

        response = self.client.get("/projects/tutorial/admin.html")
        self.assertContains(response, "fish")

        project = Project.objects.get(code="tutorial")
        add_dict = {"language": fish.id, "project": project.id}
        response = self.client.post("/projects/tutorial/admin.html", formset_dict([add_dict]))
        self.assertContains(response, "/fish/tutorial/")

        response = self.client.get("/fish/")
        self.assertContains(response, '<a href="/fish/">fish</a>')
        self.assertContains(response, '<a href="/fish/tutorial/">Tutorial</a>')
        self.assertContains(response, "1 project, 0% translated")
Exemplo n.º 4
0
    def test_add_project_language(self):
        """Tests that we can add a language to a project, then access
        its page when there are no files."""
        fish = Language(code="fish", fullname="fish")
        fish.save()

        response = self.client.get("/projects/tutorial/admin.html")
        self.assertContains(response, "fish")

        project = Project.objects.get(code='tutorial')
        add_dict = {
            "language": fish.id,
            "project": project.id,
            }
        response = self.client.post("/projects/tutorial/admin.html", formset_dict([add_dict]))
        self.assertContains(response, '/fish/tutorial/')

        response = self.client.get("/fish/")
        self.assertContains(response, '<a href="/fish/">fish</a>')
        self.assertContains(response, '<a href="/fish/tutorial/">Tutorial</a>')
        self.assertContains(response, "1 project, 0% translated")