• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Project类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_snapshot_project

    def test_snapshot_project(self,fake_icon):
        fake_stdout = StringIO()
        # make fake Project
        proj = Project.create_dummy_no_icon(name="karens-awesome-project",language="Python")

        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:aldeka,项目名称:oh-mainline,代码行数:19,代码来源:tests.py


示例17: test_scrape_bug_status_and_mark_as_closed

    def test_scrape_bug_status_and_mark_as_closed(
        self, mock_urlopen, project_name="Mercurial", should_do_something=True, should_use_urlopen=True
    ):
        if Project.objects.filter(name=project_name):
            roundup_project = Project.objects.get(name=project_name)
        else:
            roundup_project = Project.create_dummy(name=project_name)

        mock_urlopen.return_value = open(MercurialRoundupGrab.closed_bug_filename)

        tracker = mysite.customs.bugtrackers.roundup_general.MercurialTracker()
        did_create = tracker.create_bug_object_for_remote_bug_id_if_necessary(1)
        self.assertEqual(did_create, should_do_something)

        bug = Bug.all_bugs.get()
        self.assert_(bug.looks_closed)

        if should_use_urlopen:
            self.assert_(mock_urlopen.called)
开发者ID:rafpaf,项目名称:OpenHatch,代码行数:19,代码来源:tests.py


示例18: test_mark_as_wanna_help

    def test_mark_as_wanna_help(self, mock_reindex_person_method):
        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)
        response = client.post(post_to, {u'project': unicode(p_before.pk)})
        self.assert_(mock_reindex_person_method.called)

        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:aishahalim,项目名称:OpenHatch,代码行数:21,代码来源:tests.py


示例19: create_dummy_with_project

 def create_dummy_with_project(**kwargs):
     data = {'project': Project.create_dummy()}
     data.update(kwargs)
     return PortfolioEntry.create_dummy(**data)
开发者ID:JakubBielecki,项目名称:oh-mainline,代码行数:4,代码来源:models.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mysql.search_db函数代码示例发布时间:2022-05-27
下一篇:
Python tests.reverse函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap