Esempio n. 1
0
    def test_with_organizations_and_projects(self):
        user = UserFactory.create()
        org1, org2 = OrganizationFactory.create_batch(2)

        proj1, proj2 = ProjectFactory.create_batch(2, organization=org1)
        proj3 = ProjectFactory.create(organization=org2)
        proj4 = ProjectFactory.create(organization=org2, archived=False)

        ProjectRole.objects.create(project=proj1, user=user, role='DC')
        is_not_admin_org1 = OrganizationRole.objects.create(organization=org1,
                                                            user=user,
                                                            admin=False).admin
        is_admin_org2 = OrganizationRole.objects.create(organization=org2,
                                                        user=user,
                                                        admin=True).admin

        response = self.request(user=user)

        assert response.status_code == 200
        assert response.content == self.render_content(user_orgs_and_projects=[
            (org1, is_not_admin_org1,
             [(proj2, 'Public User'), (proj1, 'Data Collector')]),
            (org2, is_admin_org2,
             [(proj3, 'Administrator'), (proj4, 'Administrator')]),
        ])
    def test_archived_projects_appear_in_long_lists(self):
        """If the project list spans two pages, and an archived
        project appears on the second page, the archive filter option
        should still appear"""

        ProjectFactory.create_batch(10)

        LoginPage(self).login('default5', 'password1')
        page = ProjectListPage(self)
        page.go_to_and_check_on_page()

        project_title = page.get_project_title_in_table()
        assert project_title == 'Linux Kernel'

        project_title = page.sort_table_by("descending")
        assert project_title == 'Project Gutenberg'

        page.sort_table_by("ascending")
        page.click_archive_filter("Archived")
        project_title = page.get_project_title_in_table()
        assert project_title == 'Zealous Archived Project Archived'

        project_title = page.sort_table_by("descending")
        assert project_title == 'Zealous Archived Project Archived'

        page.sort_table_by("ascending")
        page.click_archive_filter("All")
        project_title = page.get_project_title_in_table()
        assert project_title == 'Linux Kernel'

        project_title = page.sort_table_by("descending")
        assert project_title == 'Zealous Archived Project Archived'

        page.sort_table_by("ascending")
        page.click_archive_filter("Archived")
        page.click_archive_filter("Active")
        project_title = page.get_project_title_in_table()
        assert project_title == 'Linux Kernel'
    def test_archived_projects_appear_in_long_lists(self):
        """If the project list spans two pages, and an archived
        project appears on the second page, the archive filter option
        should still appear"""

        ProjectFactory.create_batch(10)

        LoginPage(self).login("default5", "password1")
        page = ProjectListPage(self)
        page.go_to_and_check_on_page()

        project_title = page.get_project_title_in_table()
        assert project_title == "Linux Kernel"

        project_title = page.sort_table_by("descending")
        assert project_title == "Project Gutenberg"

        page.sort_table_by("ascending")
        page.click_archive_filter("Archived")
        project_title = page.get_project_title_in_table()
        assert project_title == "Zealous Archived Project Archived"

        project_title = page.sort_table_by("descending")
        assert project_title == "Zealous Archived Project Archived"

        page.sort_table_by("ascending")
        page.click_archive_filter("All")
        project_title = page.get_project_title_in_table()
        assert project_title == "Linux Kernel"

        project_title = page.sort_table_by("descending")
        assert project_title == "Zealous Archived Project Archived"

        page.sort_table_by("ascending")
        page.click_archive_filter("Archived")
        page.click_archive_filter("Active")
        project_title = page.get_project_title_in_table()
        assert project_title == "Linux Kernel"