当前位置: 首页>>代码示例>>Python>>正文


Python models.Project类代码示例

本文整理汇总了Python中mysite.search.models.Project的典型用法代码示例。如果您正苦于以下问题:Python Project类的具体用法?Python Project怎么用?Python Project使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_populate_icon_from_ohloh

    def test_populate_icon_from_ohloh(self):

        project = Project()
        project.name = 'Mozilla Firefox'
        project.populate_icon_from_ohloh()

        self.assert_(project.icon_raw)
        self.assertEqual(project.icon_raw.width, 64)
        self.assertNotEqual(project.date_icon_was_fetched_from_ohloh, None)
开发者ID:anall,项目名称:oh-mainline,代码行数:9,代码来源:tests.py

示例2: test_populate_icon_from_ohloh_uses_none_on_no_match

    def test_populate_icon_from_ohloh_uses_none_on_no_match(self):

        project = Project()
        project.name = 'lolnomatchiawergh'

        project.populate_icon_from_ohloh()

        self.assertFalse(project.icon_raw)
        # We don't know how to compare this against None,
        # but this seems to work.

        self.assertNotEqual(project.date_icon_was_fetched_from_ohloh, None)
开发者ID:anall,项目名称:oh-mainline,代码行数:12,代码来源:tests.py

示例3: create_dummy

 def create_dummy(**kwargs):
     data = {'project': Project.create_dummy(),
             'project_description': "DESCRIPTION-----------------------------" + uuid.uuid4().hex }
     data.update(kwargs)
     ret = PortfolioEntry(**data)
     ret.save()
     return ret
开发者ID:athonlab,项目名称:OpenHatch,代码行数:7,代码来源:models.py

示例4: test

    def test(self):
        # Create an answer whose author isn't specified. This replicates the
        # situation where the user isn't logged in.
        p = Project.create_dummy(name='Myproject')
        q = ProjectInvolvementQuestion.create_dummy(
            key_string='where_to_start', is_bug_style=False)

        # Do a GET on the project page to prove cookies work.
        self.client.get(p.get_url())

        # POST some text to the answer creation post handler
        POST_data = {
            'project__pk': p.pk,
            'question__pk': q.pk,
            'answer__text': ("Help produce official documentation, share "
                                 "the solution to a problem, or check, proof "
                                 "and test other documents for accuracy."),
        }
        response = self.client.post(
            reverse(mysite.project.views.create_answer_do), POST_data,
            follow=True)

        # Now, the session will know about the answer, but the answer will
        # not be published. Visit the login page, assert that the page
        # contains the text of the answer.

        response = self.client.get(reverse('oh_login'))
        self.assertContains(response, POST_data['answer__text'])
开发者ID:Winterflower,项目名称:oh-mainline,代码行数:28,代码来源:tests.py

示例5: test

    def test(self):
        # Steps for this test
        # 1. User POSTs to the wannahelp POST handler, indicating the request
        #    came from offsite
        # 2. User is redirected to a login page that knows the request came
        #    from offsite
        project_id = Project.create_dummy(name='Myproject').id

        # At the start, no one wants to help our project.
        self.assertFalse(Project.objects.get(id=project_id)
                         .people_who_wanna_help.all())

        # Click the button saying we want to help!
        post_to = reverse(mysite.project.views.wanna_help_do)
        response = self.client.post(post_to,
                                    {u'project': unicode(project_id),
                                     u'from_offsite': u'True'}, follow=True)

        # Make sure the session knows we came from offsite. Login-related
        # templates want this knowledge.
        self.assert_(self.client.session.get('from_offsite', False))

        # FIXME: There should be a cancel button letting the user
        # destroy the session and then go back to the Referring page.

        # Make sure we are redirected to the right place
        self.assertEqual(
            response.redirect_chain,
            [('http://testserver/account/login/?'
              'next=%2Fprojects%2FMyproject%3Fwanna_help%3Dtrue', 302)])

        lucky_projects = (mysite.project.view_helpers.
                          get_wanna_help_queue_from_session(self.client.
                                                            session))
        self.assertEqual([k.name for k in lucky_projects], ['Myproject'])
开发者ID:1234-,项目名称:oh-mainline,代码行数:35,代码来源:tests.py

示例6: test_kde_harder_bug

 def test_kde_harder_bug(self):
     p = Project.create_dummy(name='KDE')
     f = os.path.join(settings.MEDIA_ROOT, 'sample-data', 'kde-182054-2010-04-09.xml')
     xml_fd = file(f)
     bug = mysite.customs.miro.xml2bug_object(xml_fd)
     self.assertEqual(bug.submitter_username, 'jedd progsoc org')
     self.assertEqual(bug.submitter_realname, '')
开发者ID:athonlab,项目名称:OpenHatch,代码行数:7,代码来源:tests.py

示例7: test_kde

 def test_kde(self):
     p = Project.create_dummy(name="KDE")
     f = os.path.join(settings.MEDIA_ROOT, "sample-data", "kde-117760-2010-04-09.xml")
     xml_fd = file(f)
     bug = mysite.customs.miro.xml2bug_object(xml_fd)
     self.assertEqual(bug.submitter_username, "hasso kde org")
     self.assertEqual(bug.submitter_realname, "Hasso Tepper")
开发者ID:rafpaf,项目名称:OpenHatch,代码行数:7,代码来源:tests.py

示例8: test_snapshot_project_with_icon

    def test_snapshot_project_with_icon(self, fake_icon):
        fake_icon_data = open(os.path.join(
            settings.MEDIA_ROOT, 'no-project-icon.png')).read()
        fake_icon.return_value = fake_icon_data

        fake_stdout = StringIO()
        # make fake Project
        proj = Project.create_dummy(
            name="karens-awesome-project", language="Python")
        proj.populate_icon_from_ohloh()
        proj.save()

        command = mysite.customs.management.commands.snapshot_public_data.Command(
        )
        command.handle(output=fake_stdout)

        # now delete fake Project...
        proj.delete()

        # let's see if we can reincarnate it!
        for obj in django.core.serializers.deserialize('json', fake_stdout.getvalue()):
            obj.save()

        # test: are there ANY projects?
        self.assertTrue(Project.objects.all())
        # test: is our lovely fake project there?
        mysite.search.models.Project.objects.get(name="karens-awesome-project")
开发者ID:anall,项目名称:oh-mainline,代码行数:27,代码来源:tests.py

示例9: test_project_creator_simply_redirects_to_project_if_it_exists

    def test_project_creator_simply_redirects_to_project_if_it_exists(self, mock_populate_icon, mock_populate_language):
        # Show that it works
        project_name = "Something novel"
        Project.create_dummy(name=project_name.lower())

        # See? We have our project in the database (with slightly different case, but still)
        self.assertEqual(1, len(mysite.search.models.Project.objects.all()))

        response = self.client.post(
            reverse(mysite.project.views.create_project_page_do), {"project_name": project_name}, follow=True
        )

        # And we still have exactly that one project in the database.
        self.assertEqual(1, len(mysite.search.models.Project.objects.all()))

        #  and redirected.
        self.assertEqual(response.redirect_chain, [("http://testserver/+projects/something%20novel", 302)])
开发者ID:jledbetter,项目名称:oh-mainline,代码行数:17,代码来源:tests.py

示例10: test_mark_as_helper_anonymously

    def test_mark_as_helper_anonymously(self):
        # Steps for this test
        # 1. User fills in the form anonymously
        # 2. We test that the Answer is not yet saved
        # 3. User logs in
        # 4. We test that the Answer is saved

        project_id = Project.create_dummy(name='Myproject').id

        # At the start, no one wants to help our project.
        self.assertFalse(Project.objects.get(id=project_id)
                         .people_who_wanna_help.all())

        # Click the button saying we want to help!
        post_to = reverse(mysite.project.views.wanna_help_do)
        response = self.client.post(
            post_to, {u'project': unicode(project_id)}, follow=True)

        # Make sure we are redirected to the right place
        self.assertEqual(response.redirect_chain,
                         [('http://testserver/account/login/?next=%2Fprojects%2FMyproject%3Fwanna_help%3Dtrue', 302)])

        # check that the session can detect that we want to help Ubuntu out
        self.assertEqual(self.client.session['projects_we_want_to_help_out'],
                         [project_id])

        # According to the database, no one wants to help our project.
        self.assertFalse(Project.objects.get(id=project_id)
                         .people_who_wanna_help.all())

        # But when the user is logged in and *then* visits the project page
        login_worked = self.client.login(username='paulproteus',
                                         password="paulproteus's unbreakable password")
        self.assert_(login_worked)

        # Visit the project page...
        self.client.get(Project.objects.get(id=project_id).get_url())

        # After the GET, we've removed our note in the session
        self.assertFalse(
            self.client.session.get('projects_we_want_to_help_out', None))

        # then the DB knows the user wants to help out!
        self.assertEqual(
            list(Project.objects.get(id=project_id)
                 .people_who_wanna_help.all()),
            [Person.objects.get(user__username='paulproteus')])
        self.assert_(mysite.search.models.WannaHelperNote.objects.all())

        # Say we're not interested anymore.
        post_to = reverse(mysite.project.views.unlist_self_from_wanna_help_do)
        response = self.client.post(
            post_to, {u'project': unicode(project_id)}, follow=True)

        # And now the DB shows we have removed ourselves.
        self.assertFalse(Project.objects.get(id=project_id)
                         .people_who_wanna_help.all())
        self.assertFalse(mysite.search.models.WannaHelperNote.objects.all())
开发者ID:Aaron1011,项目名称:oh-mainline,代码行数:58,代码来源:tests.py

示例11: test_scrape_bug_status_and_mark_as_closed

    def test_scrape_bug_status_and_mark_as_closed(self):
        roundup_project = Project.create_dummy()
        tracker = mysite.customs.models.RoundupBugTracker(
                project=roundup_project,
                roundup_root_url="http://example.org")
        tracker.save()

        bug = tracker.create_bug_object_for_remote_bug_id(1)
        self.assert_(bug.looks_closed)
开发者ID:athonlab,项目名称:OpenHatch,代码行数:9,代码来源:tests.py

示例12: test

    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 the 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)
开发者ID:jledbetter,项目名称:oh-mainline,代码行数:52,代码来源:tests.py

示例13: test_unmark_as_wanna_help

    def test_unmark_as_wanna_help(self):
        # We're in there...
        person = Person.objects.get(user__username='paulproteus')
        p_before = Project.create_dummy()
        p_before.people_who_wanna_help.add(person)
        p_before.save()
        mysite.search.models.WannaHelperNote.add_person_project(person, p_before)

        # Submit that project to unlist_self_from_wanna_help_do
        client = self.login_with_client()
        post_to = reverse(mysite.project.views.unlist_self_from_wanna_help_do)
        client.post(post_to, {u'project': unicode(p_before.pk)})

        # Are we gone yet?
        p_after = Project.objects.get(pk=p_before.pk)

        self.assertFalse(p_after.people_who_wanna_help.all())
开发者ID:CourtneyThurston,项目名称:oh-mainline,代码行数:17,代码来源:tests.py

示例14: test_mark_as_contacted

    def test_mark_as_contacted(self):
        person = Person.objects.get(user__username='paulproteus')
        p_before = Project.create_dummy()
        p_before.people_who_wanna_help.add(person)
        p_before.save()
        mysite.search.models.WannaHelperNote.add_person_project(person, p_before)

        client = self.login_with_client()
        post_to = reverse(mysite.project.views.mark_contacted_do)
        vars = {u'mark_contact-project': unicode(p_before.pk),
                u'helper-%s-checked' % (person.pk,) : unicode('on'),
                u'helper-%s-person_id' % (person.pk) : unicode(person.pk),
                u'helper-%s-project_id' % (person.pk) : unicode(p_before.pk)}
        client.post(post_to, vars)

        whn_after = mysite.search.models.WannaHelperNote.objects.get(person=person, project=p_before)
        self.assertTrue(whn_after.contacted_on)
        self.assertTrue(whn_after.contacted_by, datetime.date.today())
开发者ID:CourtneyThurston,项目名称:oh-mainline,代码行数:18,代码来源:tests.py

示例15: test_mark_as_wanna_help

    def test_mark_as_wanna_help(self):
        person = Person.objects.get(user__username="paulproteus")
        p_before = Project.create_dummy()
        self.assertFalse(mysite.search.models.WannaHelperNote.objects.all())

        self.assertFalse(p_before.people_who_wanna_help.all())

        client = self.login_with_client()
        post_to = reverse(mysite.project.views.wanna_help_do)
        client.post(post_to, {u"project": unicode(p_before.pk)})

        p_after = Project.objects.get(pk=p_before.pk)

        self.assertEqual(list(p_after.people_who_wanna_help.all()), [person])

        note = mysite.search.models.WannaHelperNote.objects.get()
        self.assertEqual(note.person, person)
        self.assertEqual(note.project, p_after)
开发者ID:jledbetter,项目名称:oh-mainline,代码行数:18,代码来源:tests.py


注:本文中的mysite.search.models.Project类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。