示例#1
0
    def test(self):

        # Create a project.
        project = Project.create_dummy()

        # Create two profiles, each with a PortfolioEntry linking it to the
        # project, each with descriptions.
        def create_pfe_with_description(username):
            return PortfolioEntry.create_dummy(
                project=project,
                person=Person.get_by_username(username),
                is_published=True)

        pfes = {
            'uncheck_me': create_pfe_with_description('paulproteus'),
            'keep_me_checked': create_pfe_with_description('barry')
        }

        # Get a list of PortfolioEntries that we use to get a random project
        # description for the project page.
        descriptions = project.get_pfentries_with_usable_descriptions()

        # Observe that the list contains both PortfolioEntries.
        for entry in pfes.values():
            self.assert_(entry in descriptions)

        self.login_with_twill()

        # Go to the project page.
        url = urlparse.urljoin("http://openhatch.org",
                               project.get_edit_page_url())
        tc.go(better_make_twill_url(url))

        # In preparation for the next set of assertions, make sure that the
        # entries don't have the same description.
        self.assertNotEqual(pfes['uncheck_me'].project_description,
                            pfes['keep_me_checked'].project_description)

        # See a list of project descriptions on the page, which equals the
        # list of descriptions in the DB.
        for entry in pfes.values():
            tc.find(entry.project_description)

        # Uncheck one of the checkboxes and submit the form
        name_of_checkbox_to_uncheck = "%s-use_my_description" % pfes[
            'uncheck_me'].pk
        tc.fv("2", name_of_checkbox_to_uncheck, False)
        tc.submit()

        # Get a list of the PortfolioEntries that we use to get a random
        # project description for the project page.
        good_pfentries = project.get_pfentries_with_usable_descriptions()

        # Observe that the list contains only the checked PortfolioEntry.
        self.assert_(pfes['uncheck_me'] not in good_pfentries)
        self.assert_(pfes['keep_me_checked'] in good_pfentries)
示例#2
0
 def test_form_sends_data_to_get(self):
     # This test will fail if a query that selects one project but doesn't
     # equal the project's name causes a redirect.
     relevant = mysite.search.models.Project.create_dummy(name='Twisted System')
     tc.go(better_make_twill_url('http://openhatch.org/+projects'))
     query = 'Twisted'
     tc.fv(1, 'search_q', query)
     tc.submit()
     tc.url('\?q=Twisted') # Assert that URL contains this substring.
     tc.find(query)
示例#3
0
 def test_form_on_project_search_page_submits_to_project_creation_post_handler(self):
     project_search_page_url = better_make_twill_url(
             "http://openhatch.org%s?q=newproject" % reverse(mysite.project.views.projects))
     tc.go(project_search_page_url)
     # Fill form out with slightly different project name, which we
     # anticipate happening sometimes
     tc.fv('create_project', 'project_name', 'NewProject')
     tc.submit()
     post_handler_url = reverse(mysite.project.views.create_project_page_do)
     import re
     tc.url(re.escape(post_handler_url))
示例#4
0
    def test(self):

        # Create a project.
        project = Project.create_dummy()

        # Create two profiles, each with a PortfolioEntry linking it to the
        # project, each with descriptions.
        def create_pfe_with_description(username):
            return PortfolioEntry.create_dummy(project=project,
                                               person=Person.get_by_username(
                                                   username),
                                               is_published=True)
        pfes = {'uncheck_me': create_pfe_with_description('paulproteus'),
                'keep_me_checked': create_pfe_with_description('barry')}

        # Get a list of PortfolioEntries that we use to get a random project
        # description for the project page.
        descriptions = project.get_pfentries_with_usable_descriptions()

        # Observe that the list contains both PortfolioEntries.
        for entry in pfes.values():
            self.assert_(entry in descriptions)

        self.login_with_twill()

        # Go to the project page.
        url = urlparse.urljoin(
            "http://openhatch.org", project.get_edit_page_url())
        tc.go(better_make_twill_url(url))

        # In preparation for the next set of assertions, make sure that the
        # entries don't have the same description.
        self.assertNotEqual(
            pfes['uncheck_me'].project_description,
            pfes['keep_me_checked'].project_description)

        # See a list of project descriptions on the page, which equals the
        # list of descriptions in the DB.
        for entry in pfes.values():
            tc.find(entry.project_description)

        # Uncheck one of the checkboxes and submit the form
        name_of_checkbox_to_uncheck = "%s-use_my_description" % pfes[
            'uncheck_me'].pk
        tc.fv("2", name_of_checkbox_to_uncheck, False)
        tc.submit()

        # Get a list of the PortfolioEntries that we use to get a random
        # project description for the project page.
        good_pfentries = project.get_pfentries_with_usable_descriptions()

        # Observe that the list contains only the checked PortfolioEntry.
        self.assert_(pfes['uncheck_me'] not in good_pfentries)
        self.assert_(pfes['keep_me_checked'] in good_pfentries)
示例#5
0
    def test_form_sends_data_to_get(self):
        # This test will fail if a query that selects one project but doesn't
        # equal the project's name causes a redirect.

        # First, create the project that we will refer to below.
        mysite.search.models.Project.create_dummy(name='Twisted System')

        tc.go(better_make_twill_url('http://openhatch.org/projects'))
        query = 'Twisted'
        tc.fv(1, 'search_q', query)
        tc.submit()
        tc.url('\?q=Twisted') # Assert that URL contains this substring.
        tc.find(query)
示例#6
0
    def test_form_sends_data_to_get(self):
        # This test will fail if a query that selects one project but doesn't
        # equal the project's name causes a redirect.

        # First, create the project that we will refer to below.
        mysite.search.models.Project.create_dummy(name="Twisted System")

        tc.go(better_make_twill_url("http://openhatch.org/+projects"))
        query = "Twisted"
        tc.fv(1, "search_q", query)
        tc.submit()
        tc.url("\?q=Twisted")  # Assert that URL contains this substring.
        tc.find(query)