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


Python tests.CampaignFactory类代码示例

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


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

示例1: test_edit_event

    def test_edit_event(self):
        """Edit event with inactive categories."""
        start_form = {
            'start_form_0_month': 1,
            'start_form_0_day': 25,
            'start_form_0_year': 2014,
            'start_form_1_hour': 4,
            'start_form_1_minute': 1}
        end_form = {
            'end_form_0_month': 1,
            'end_form_0_day': 25,
            'end_form_0_year': 2015,
            'end_form_1_hour': 4,
            'end_form_1_minute': 1}

        owner = UserFactory.create(groups=['Mentor'])
        functional_area = [FunctionalAreaFactory.create()]
        campaign = [CampaignFactory.create()]
        event = EventFactory.create(owner=owner, categories=functional_area)

        data = model_to_dict(event)
        data['categories'] = functional_area[0].id
        data['campaign'] = campaign[0].id
        data.update(start_form)
        data.update(end_form)

        form = EventForm(data=data, editable_owner=False, instance=event)
        ok_(form.is_valid())
        result = form.save()
        ok_(functional_area[0] in result.categories.all())
开发者ID:Azeez09,项目名称:remo,代码行数:30,代码来源:test_forms.py

示例2: test_base

 def test_base(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     event = EventFactory.create()
     functional_areas = [FunctionalAreaFactory.create()]
     campaign = CampaignFactory.create()
     activity = ActivityFactory.create()
     report = NGReportFactory.create(
         functional_areas=functional_areas, mentor=mentor,
         campaign=campaign, user=user, event=event, activity=activity)
     url = '/api/beta/activities/%s' % report.id
     request = RequestFactory().get(url)
     data = ActivitiesDetailedSerializer(report,
                                         context={'request': request}).data
     eq_(data['user']['first_name'], user.first_name)
     eq_(data['user']['last_name'], user.last_name)
     eq_(data['user']['display_name'], user.userprofile.display_name)
     ok_(data['user']['_url'])
     eq_(data['activity'], activity.name)
     eq_(data['initiative'], campaign.name)
     eq_(data['functional_areas'][0]['name'], functional_areas[0].name)
     eq_(data['activity_description'], report.activity_description)
     eq_(data['location'], report.location)
     eq_(data['latitude'], float(report.latitude))
     eq_(data['longitude'], float(report.longitude))
     eq_(data['report_date'], report.report_date.strftime('%Y-%m-%d'))
     eq_(data['link'], report.link)
     eq_(data['link_description'], report.link_description)
     eq_(data['mentor']['first_name'], mentor.first_name)
     eq_(data['mentor']['last_name'], mentor.last_name)
     eq_(data['mentor']['display_name'], mentor.userprofile.display_name)
     ok_(data['mentor']['_url'])
     eq_(data['passive_report'], report.is_passive)
     eq_(data['event']['name'], event.name)
     ok_(data['event']['_url'])
开发者ID:Mte90,项目名称:remo,代码行数:35,代码来源:test_api.py

示例3: test_base_content_update_unauthed

 def test_base_content_update_unauthed(self):
     """Test update base content unauthorized."""
     user = UserFactory.create(groups=['Rep'])
     campaign = CampaignFactory.create(name='test campaign')
     self.post(reverse('edit_campaign', kwargs={'pk': campaign.id}),
               data={'name': 'edit campaign'},
               user=user, follow=True)
开发者ID:abshetewy,项目名称:remo,代码行数:7,代码来源:test_views.py

示例4: test_base

 def test_base(self):
     user = UserFactory.create()
     activity = ActivityFactory.create()
     campaign = CampaignFactory.create()
     functional_area = FunctionalAreaFactory.create()
     data = {
         'report_date': '25 March 2012',
         'activity': activity.id,
         'campaign': campaign.id,
         'longitude': 44.33,
         'latitude': 55.66,
         'location': 'world',
         'link': 'https://example.com',
         'link_description': 'Test link.',
         'activity_description': 'Test activity',
         'functional_areas': functional_area.id,
     }
     form = NGReportForm(data, instance=NGReport(user=user))
     ok_(form.is_valid())
     db_obj = form.save()
     eq_(db_obj.report_date, date(2012, 3, 25))
     eq_(db_obj.activity, activity)
     eq_(db_obj.longitude, 44.33)
     eq_(db_obj.latitude, 55.66)
     eq_(db_obj.location, 'world')
     eq_(db_obj.link, 'https://example.com')
     eq_(db_obj.link_description, 'Test link.')
     eq_(db_obj.activity_description, 'Test activity'),
     eq_(db_obj.functional_areas.all().count(), 1)
     eq_(db_obj.functional_areas.all()[0], functional_area)
     eq_(db_obj.mentor, user.userprofile.mentor)
开发者ID:akatsoulas,项目名称:remo,代码行数:31,代码来源:test_forms.py

示例5: test_base

 def test_base(self):
     user = UserFactory.create()
     categories = [FunctionalAreaFactory.create()]
     initiative = CampaignFactory.create()
     event = EventFactory.create(categories=categories, owner=user,
                                 campaign=initiative)
     url = '/api/beta/events/%s' % event.id
     request = RequestFactory().get(url)
     data = EventDetailedSerializer(event,
                                    context={'request': request}).data
     serialized_start = parser.parse(data['start'])
     serialized_end = parser.parse(data['end'])
     eq_(data['name'], event.name)
     eq_(data['description'], event.description)
     eq_(serialized_start.date(), event.start.date())
     eq_(serialized_start.time(), event.start.time())
     eq_(serialized_end.date(), event.end.date())
     eq_(serialized_end.time(), event.end.time())
     eq_(data['timezone'], event.timezone)
     eq_(data['city'], event.city)
     eq_(data['region'], event.region)
     eq_(data['country'], event.country)
     eq_(data['lat'], event.lat)
     eq_(data['lon'], event.lon)
     eq_(data['external_link'], event.external_link)
     eq_(data['estimated_attendance'], event.estimated_attendance)
     eq_(data['planning_pad_url'], event.planning_pad_url)
     eq_(data['hashtag'], event.hashtag)
     eq_(data['owner']['first_name'], user.first_name)
     eq_(data['owner']['last_name'], user.last_name)
     eq_(data['owner']['display_name'], user.userprofile.display_name)
     ok_(data['owner']['_url'])
     eq_(data['categories'][0]['name'], categories[0].name)
     eq_(data['initiative'], initiative.name)
开发者ID:Mte90,项目名称:remo,代码行数:34,代码来源:test_api.py

示例6: test_base

 def test_base(self):
     user = UserFactory.create()
     activity = ActivityFactory.create()
     campaign = CampaignFactory.create()
     functional_area = FunctionalAreaFactory.create()
     data = {
         "report_date": "25 March 2012",
         "activity": activity.id,
         "campaign": campaign.id,
         "longitude": 44.33,
         "latitude": 55.66,
         "location": "world",
         "link": "https://example.com",
         "link_description": "Test link.",
         "activity_description": "Test activity",
         "functional_areas": functional_area.id,
     }
     form = NGReportForm(data, instance=NGReport(user=user))
     ok_(form.is_valid())
     db_obj = form.save()
     eq_(db_obj.report_date, date(2012, 03, 25))
     eq_(db_obj.activity, activity)
     eq_(db_obj.longitude, 44.33)
     eq_(db_obj.latitude, 55.66)
     eq_(db_obj.location, "world")
     eq_(db_obj.link, "https://example.com/")
     eq_(db_obj.link_description, "Test link.")
     eq_(db_obj.activity_description, "Test activity"),
     eq_(db_obj.functional_areas.all().count(), 1)
     eq_(db_obj.functional_areas.all()[0], functional_area)
     eq_(db_obj.mentor, user.userprofile.mentor)
开发者ID:flaki,项目名称:remo,代码行数:31,代码来源:test_forms.py

示例7: test_base_content_campaign_delete_post

 def test_base_content_campaign_delete_post(self):
     """Test delete campaign."""
     admin = UserFactory.create(groups=['Admin'])
     campaign = CampaignFactory.create(name='test campaign')
     response = self.post(reverse('delete_campaign',
                                  kwargs={'pk': campaign.id}), user=admin,
                          follow=True)
     eq_(response.status_code, 200)
     query = Campaign.objects.filter(name='test campaign')
     eq_(query.exists(), False)
开发者ID:abshetewy,项目名称:remo,代码行数:10,代码来源:test_views.py

示例8: test_base_content_campaign_edit_post

 def test_base_content_campaign_edit_post(self):
     """Test post edit campaign."""
     admin = UserFactory.create(groups=['Admin'])
     campaign = CampaignFactory.create(name='test campaign')
     with self.login(admin) as client:
         response = client.post(reverse('edit_campaign', kwargs={'pk': campaign.id}),
                                data={'name': 'edit campaign'},
                                follow=True)
     eq_(response.status_code, 200)
     query = Campaign.objects.filter(name='edit campaign')
     eq_(query.exists(), True)
开发者ID:Josespaul,项目名称:remo,代码行数:11,代码来源:test_views.py

示例9: test_edit_event

    def test_edit_event(self):
        """Edit NGReport with inactive categories."""
        activity = ActivityFactory.create()
        campaign = CampaignFactory.create()
        active_area = FunctionalAreaFactory.create()
        inactive_areas = FunctionalAreaFactory.create_batch(2, active=False)
        report = NGReportFactory.create(activity=activity, campaign=campaign, functional_areas=inactive_areas)

        data = model_to_dict(report)
        data["functional_areas"] = active_area.id
        form = NGReportForm(data, instance=report)
        ok_(form.is_valid())
        result = form.save()
        ok_(active_area in result.functional_areas.all())
        eq_(result.functional_areas.all().count(), 1)
开发者ID:flaki,项目名称:remo,代码行数:15,代码来源:test_forms.py

示例10: test_passive_report_save

    def test_passive_report_save(self):
        """Test that a passive report is created on form save()"""
        start_form = {
            'start_form_0_month': 1,
            'start_form_0_day': 25,
            'start_form_0_year': 2013,
            'start_form_1_hour': 4,
            'start_form_1_minute': 1}
        end_form = {
            'end_form_0_month': 1,
            'end_form_0_day': 26,
            'end_form_0_year': 2013,
            'end_form_1_hour': 4,
            'end_form_1_minute': 1}

        owner = UserFactory.create(groups=['Rep', 'Mentor'])
        areas = [FunctionalAreaFactory.create()]
        campaign = [CampaignFactory.create()]
        event = EventFactory.create(owner=owner, categories=areas)

        data = model_to_dict(event)
        data['categories'] = areas[0].id
        data['campaign'] = campaign[0].id
        data.update(start_form)
        data.update(end_form)

        form = PostEventForm(data=data, editable_owner=False, instance=event)

        activity = Activity.objects.get(name=ACTIVITY_POST_EVENT_METRICS)
        reports = NGReport.objects.filter(user=owner, activity=activity)
        ok_(not reports.exists())
        ok_(form.is_valid())
        form.save()

        reports = NGReport.objects.filter(user=owner, activity=activity)
        ok_(reports.count(), 1)
开发者ID:Azeez09,项目名称:remo,代码行数:36,代码来源:test_forms.py


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