Пример #1
0
    def generic_test_add_duplicate_project(self, from_same_org=True):

        org = self.test_data['orgs'][0]
        project = {
            'description': "",
            'country': '',
            'access': 'public',
            '_org_slug': org['slug'],
            '_org_name': org['name'],
            '_org_logo': org['logo'] if 'logo' in org else '',
        }
        duplicated_proj_idx = 0 if from_same_org else 1
        duplicated_proj = self.test_data['projects'][duplicated_proj_idx]
        project['name'] = duplicated_proj['name']
        project['slug'] = duplicated_proj['slug'] + '-1'

        # Log in as org admin
        LoginPage(self).login(self.orgadmin['username'],
                              self.orgadmin['password'])

        # Go to the add project wizard and
        # proceed to step 2 and input the project name
        proj_add_page = ProjectAddPage(self)
        proj_add_page.go_to()
        proj_add_page.submit_geometry()
        proj_add_page.set_name(project['name'])

        if from_same_org:
            # If project name is duplicate from the same org, expect that
            # submitting step 2 will result in an error
            proj_add_page.try_submit_details()
            proj_add_page.check_duplicate_name_error()

            # Make the name unique
            project['name'] = project['name'] + " 1"
            proj_add_page.set_name(project['name'])

        # successfully complete the add project wizard
        proj_add_page.submit_details()
        proj_add_page.submit_permissions()

        # Check that we are now in the new project page
        # and that the displayed project details are correct
        proj_page = ProjectPage(self, project['_org_slug'], project['slug'])
        assert proj_page.is_on_page()
        proj_page.check_page_contents(project)

        # Construct final list of projects that should be in the DB
        expected_projs = []
        for proj in self.test_data['projects']:
            proj_copy = proj.copy()
            proj_org = self.test_data['orgs'][proj['_org']]
            proj_copy['_org_slug'] = proj_org['slug']
            proj_copy['_org_name'] = proj_org['name']
            proj_copy['_org_logo'] = (
                proj_org['logo'] if 'logo' in proj_org else '')
            expected_projs.append(proj_copy)
        expected_projs.append(project)

        # Go to project list and check that details are correct
        proj_list_page = ProjectListPage(self)
        proj_list_page.go_to_and_check_on_page()
        proj_list_page.check_project_list(expected_projs)

        self.logout()
Пример #2
0
    def generic_test_orgadmin(self, access):

        assert access in ('public', 'private')

        # Log in as org admin
        LoginPage(self).login(self.orgadmin['username'],
                              self.orgadmin['password'])

        # Declare working project data for verification
        project = {}

        proj_add_page = ProjectAddPage(self)
        proj_add_page.go_to()
        assert proj_add_page.is_on_page()
        assert proj_add_page.is_on_subpage('geometry')

        # Select country and submit geometry
        project['country'] = 'AU' if access == 'public' else 'BR'
        proj_add_page.set_geometry(project['country'])
        proj_add_page.submit_geometry()

        # Check that details are all blank/default
        project['org'] = ''
        project['name'] = ""
        project['access'] = 'public'
        project['description'] = ""
        project['url'] = ''
        proj_add_page.check_details(project)

        # TODO: Check that only valid orgs are provided
        # TODO: Vary org selection

        # Check that errors occurs when no org was selected
        # and no project name was set
        # Also toggle access and set description
        project['access'] = 'private'
        project['description'] = self.test_data['project_description']
        proj_add_page.set_access(project['access'])
        proj_add_page.set_description(project['description'])
        proj_add_page.try_submit_details()
        proj_add_page.check_missing_org_error()
        proj_add_page.check_missing_name_error()
        proj_add_page.check_no_duplicate_name_error()
        proj_add_page.check_no_invalid_url_error()
        proj_add_page.check_details(project)

        # Select the first valid org
        # Check that an error occurs when the project name is only whitespace
        # Also toggle access and set URL
        project['org'] = 'unesco'
        project['name'] = "     "
        project['access'] = 'public'
        project['url'] = self.test_data['project_url']
        proj_add_page.set_org(project['org'])
        proj_add_page.set_name(project['name'])
        proj_add_page.set_access(project['access'])
        proj_add_page.set_proj_url(project['url'])
        proj_add_page.try_submit_details()
        proj_add_page.check_no_missing_org_error()
        proj_add_page.check_missing_name_error()
        proj_add_page.check_no_duplicate_name_error()
        proj_add_page.check_no_invalid_url_error()
        proj_add_page.check_details(project)

        # Unset the org, and set a valid project name
        # Check that an error occurs for the missing org
        project['org'] = ''
        project['name'] = self.test_data['project_name']
        proj_add_page.set_org(project['org'])
        proj_add_page.set_name(project['name'])
        proj_add_page.try_submit_details()
        proj_add_page.check_missing_org_error()
        proj_add_page.check_no_missing_name_error()
        proj_add_page.check_no_duplicate_name_error()
        proj_add_page.check_no_invalid_url_error()
        proj_add_page.check_details(project)

        # Set final org, final access, and invalid URL
        # Check that the page is not submitted due to the invalid URL
        project['org'] = 'unesco'
        project['access'] = access
        project['url'] = "DEADBEEF"
        proj_add_page.set_org(project['org'])
        proj_add_page.set_name(project['name'])
        proj_add_page.set_access(project['access'])
        proj_add_page.set_proj_url(project['url'])
        proj_add_page.try_submit_details()
        proj_add_page.check_no_missing_org_error()
        proj_add_page.check_no_missing_name_error()
        proj_add_page.check_no_duplicate_name_error()
        proj_add_page.check_invalid_url_error()
        proj_add_page.check_details(project)

        # Correct the URL, press "Previous" then "Next" and ensure
        # that details settings are preserved.
        project['url'] = self.test_data['project_url']
        proj_add_page.set_proj_url(project['url'])
        proj_add_page.click_previous_details()
        proj_add_page.submit_geometry()
        proj_add_page.check_details(project)

        # Finally submit details
        proj_add_page.submit_details()

        # Set permissions
        # TODO: Vary permissions and check permissions after
        proj_add_page.submit_permissions()

        # Set project slug and org details
        project['slug'] = self.test_data['project_slug']
        orgs = self.test_data['orgs']
        project['_org_slug'] = orgs[0]['slug']
        project['_org_name'] = orgs[0]['name']
        project['_org_logo'] = (orgs[0]['logo'] if 'logo' in orgs[0] else '')

        # Check that we are now in the project page
        # and that displayed project details are correct
        proj_page = ProjectPage(self, project['_org_slug'], project['slug'])
        assert proj_page.is_on_page()
        proj_page.check_page_contents(project)

        # Go to project list and check that details are correct
        proj_list_page = ProjectListPage(self)
        proj_list_page.go_to_and_check_on_page()
        proj_list_page.check_project_list([project])

        self.logout()

        # Check new project as an org member
        LoginPage(self).login(self.orgmember['username'],
                              self.orgmember['password'])
        proj_page.go_to()
        assert proj_page.is_on_page()
        proj_page.check_page_contents(project)
        proj_list_page = ProjectListPage(self)
        proj_list_page.go_to_and_check_on_page()
        proj_list_page.check_project_list([project])
        self.logout()

        # Check new project as an unaffiliated user
        LoginPage(self).login(self.unaffuser['username'],
                              self.unaffuser['password'])
        proj_page.go_to()
        if access == 'public':
            assert proj_page.is_on_page()
            proj_page.check_page_contents(project)
        else:
            assert DashboardPage(self).is_on_page()
            self.assert_has_message('alert', "have permission")
        proj_list_page = ProjectListPage(self)
        proj_list_page.go_to_and_check_on_page()
        if access == 'public':
            proj_list_page.check_project_list([project])
        else:
            assert proj_list_page.is_list_empty()
        self.logout()
Пример #3
0
    def generic_test_orgadmin(self, access):

        assert access in ("public", "private")

        # Log in as org admin
        LoginPage(self).login(self.orgadmin["username"], self.orgadmin["password"])

        # Declare working project data for verification
        project = {}

        proj_add_page = ProjectAddPage(self)
        proj_add_page.go_to()
        assert proj_add_page.is_on_page()
        assert proj_add_page.is_on_subpage("geometry")

        # Select country and submit geometry
        project["country"] = "AU" if access == "public" else "BR"
        proj_add_page.set_geometry(project["country"])
        proj_add_page.submit_geometry()

        # Check that details are all blank/default
        project["org"] = ""
        project["name"] = ""
        project["access"] = "public"
        project["description"] = ""
        project["url"] = ""
        proj_add_page.check_details(project)

        # TODO: Check that only valid orgs are provided
        # TODO: Vary org selection

        # Check that errors occurs when no org was selected
        # and no project name was set
        # Also toggle access and set description
        project["access"] = "private"
        project["description"] = self.test_data["project_description"]
        proj_add_page.set_access(project["access"])
        proj_add_page.set_description(project["description"])
        proj_add_page.try_submit_details()
        proj_add_page.check_missing_org_error()
        proj_add_page.check_missing_name_error()
        proj_add_page.check_no_duplicate_name_error()
        proj_add_page.check_no_invalid_url_error()
        proj_add_page.check_details(project)

        # Select the first valid org
        # Check that an error occurs when the project name is only whitespace
        # Also toggle access and set URL
        project["org"] = "unesco"
        project["name"] = "     "
        project["access"] = "public"
        project["url"] = self.test_data["project_url"]
        proj_add_page.set_org(project["org"])
        proj_add_page.set_name(project["name"])
        proj_add_page.set_access(project["access"])
        proj_add_page.set_proj_url(project["url"])
        proj_add_page.try_submit_details()
        proj_add_page.check_no_missing_org_error()
        proj_add_page.check_missing_name_error()
        proj_add_page.check_no_duplicate_name_error()
        proj_add_page.check_no_invalid_url_error()
        proj_add_page.check_details(project)

        # Unset the org, and set a valid project name
        # Check that an error occurs for the missing org
        project["org"] = ""
        project["name"] = self.test_data["project_name"]
        proj_add_page.set_org(project["org"])
        proj_add_page.set_name(project["name"])
        proj_add_page.try_submit_details()
        proj_add_page.check_missing_org_error()
        proj_add_page.check_no_missing_name_error()
        proj_add_page.check_no_duplicate_name_error()
        proj_add_page.check_no_invalid_url_error()
        proj_add_page.check_details(project)

        # Set final org, final access, and invalid URL
        # Check that the page is not submitted due to the invalid URL
        project["org"] = "unesco"
        project["access"] = access
        project["url"] = "DEADBEEF"
        proj_add_page.set_org(project["org"])
        proj_add_page.set_name(project["name"])
        proj_add_page.set_access(project["access"])
        proj_add_page.set_proj_url(project["url"])
        proj_add_page.try_submit_details()
        proj_add_page.check_no_missing_org_error()
        proj_add_page.check_no_missing_name_error()
        proj_add_page.check_no_duplicate_name_error()
        proj_add_page.check_invalid_url_error()
        proj_add_page.check_details(project)

        # Correct the URL, press "Previous" then "Next" and ensure
        # that details settings are preserved.
        project["url"] = self.test_data["project_url"]
        proj_add_page.set_proj_url(project["url"])
        proj_add_page.click_previous_details()
        proj_add_page.submit_geometry()
        proj_add_page.check_details(project)

        # Finally submit details
        proj_add_page.submit_details()

        # Set permissions
        # TODO: Vary permissions and check permissions after
        proj_add_page.submit_permissions()

        # Set project slug and org details
        project["slug"] = self.test_data["project_slug"]
        orgs = self.test_data["orgs"]
        project["_org_slug"] = orgs[0]["slug"]
        project["_org_name"] = orgs[0]["name"]
        project["_org_logo"] = orgs[0]["logo"] if "logo" in orgs[0] else ""

        # Check that we are now in the project page
        # and that displayed project details are correct
        proj_page = ProjectPage(self, project["_org_slug"], project["slug"])
        assert proj_page.is_on_page()
        proj_page.check_page_contents(project)

        # Go to project list and check that details are correct
        proj_list_page = ProjectListPage(self)
        proj_list_page.go_to_and_check_on_page()
        proj_list_page.check_project_list([project])

        self.logout()

        # Check new project as an org member
        LoginPage(self).login(self.orgmember["username"], self.orgmember["password"])
        proj_page.go_to()
        assert proj_page.is_on_page()
        proj_page.check_page_contents(project)
        proj_list_page = ProjectListPage(self)
        proj_list_page.go_to_and_check_on_page()
        proj_list_page.check_project_list([project])
        self.logout()

        # Check new project as an unaffiliated user
        LoginPage(self).login(self.unaffuser["username"], self.unaffuser["password"])
        proj_page.go_to()
        if access == "public":
            assert proj_page.is_on_page()
            proj_page.check_page_contents(project)
        else:
            assert DashboardPage(self).is_on_page()
            self.assert_has_message("alert", "have permission")
        proj_list_page = ProjectListPage(self)
        proj_list_page.go_to_and_check_on_page()
        if access == "public":
            proj_list_page.check_project_list([project])
        else:
            assert proj_list_page.is_list_empty()
        self.logout()