def test_archived_orgs_appear_for_admin_user(self):
        """The option to filter active/archived organizations is available to
        organization administrators."""

        LoginPage(self).login('testadmin', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        page.sort_table_by("ascending", col="organization")
        page.click_archive_filter("All")
        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("ascending", col="organization")
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        page.click_archive_filter("Active")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'
    def test_archived_orgs_filter_appears_in_long_list(self):
        """If the organization list spans two pages, and an archived
        organization appears on the second page, the archive filter option
        should still appear"""
        OrganizationFactory.create_batch(10)

        LoginPage(self).login('testadmin', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        page.sort_table_by("ascending", col="organization")
        page.click_archive_filter("All")
        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("ascending", col="organization")
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        page.click_archive_filter("Active")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'
    def test_archived_orgs_filter_appears_in_long_list(self):
        """If the organization list spans two pages, and an archived
        organization appears on the second page, the archive filter option
        should still appear"""
        OrganizationFactory.create_batch(10)

        LoginPage(self).login('testadmin', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        page.sort_table_by("ascending", col="organization")
        page.click_archive_filter("All")
        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("ascending", col="organization")
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        page.click_archive_filter("Active")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'
    def test_archived_orgs_appear_for_admin_user(self):
        """The option to filter active/archived organizations is available to
        organization administrators."""

        LoginPage(self).login('testadmin', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        page.sort_table_by("ascending", col="organization")
        page.click_archive_filter("All")
        first_org = page.sort_table_by("descending", col="organization")
        assert first_org == 'Zealous Archived Organization Archived'

        first_org = page.sort_table_by("ascending", col="organization")
        assert first_org == 'Organization #0'

        page.click_archive_filter("Archived")
        page.click_archive_filter("Active")
        first_org = page.get_organization_title_in_table()
        assert first_org == 'Organization #0'
    def test_organizations_view_with_permission(self):
        """A registered user can view organizations"""

        LoginPage(self).login('testuser', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        organization_title = page.get_organization_title_in_table()
        assert organization_title == 'Organization #0'
    def test_organizations_view_without_permission(self):
        """ Unregistered users can see organizations."""
        # again, not sure why you have to call this explicitly
        assign_user_policies(None, Policy.objects.get(name='default'))
        page = OrganizationListPage(self)
        page.go_to()

        organization_title = page.get_organization_title_in_table()
        assert organization_title == 'Organization #0'
    def test_organizations_view_with_permission(self):
        """A registered user can view organizations"""

        LoginPage(self).login('testuser', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        organization_title = page.get_organization_title_in_table()
        assert organization_title == 'Organization #0'
    def test_organizations_view_without_permission(self):
        """ Unregistered users can see organizations."""
        # again, not sure why you have to call this explicitly
        assign_user_policies(None, Policy.objects.get(name='default'))
        page = OrganizationListPage(self)
        page.go_to()

        organization_title = page.get_organization_title_in_table()
        assert organization_title == 'Organization #0'
    def test_searching_for_organizations(self):
        """A registered user user can search for organization by name."""

        LoginPage(self).login('testuser', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        search = page.get_search_box()
        search.send_keys("#1")

        organization_title = page.get_organization_title_in_table()
        assert organization_title == 'Organization #1'
    def test_searching_for_organizations(self):
        """A registered user user can search for organization by name."""

        LoginPage(self).login('testuser', 'password')
        page = OrganizationListPage(self)
        page.go_to()

        search = page.get_search_box()
        search.send_keys("#1")

        organization_title = page.get_organization_title_in_table()
        assert organization_title == 'Organization #1'