當前位置: 首頁>>代碼示例>>Python>>正文


Python ActivityFactory.create方法代碼示例

本文整理匯總了Python中remo.reports.tests.ActivityFactory.create方法的典型用法代碼示例。如果您正苦於以下問題:Python ActivityFactory.create方法的具體用法?Python ActivityFactory.create怎麽用?Python ActivityFactory.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在remo.reports.tests.ActivityFactory的用法示例。


在下文中一共展示了ActivityFactory.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_base

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 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,代碼行數:37,代碼來源:test_api.py

示例2: test_campain_activity_without_campaign

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def test_campain_activity_without_campaign(self):
     activity = ActivityFactory.create(name=ACTIVITY_CAMPAIGN)
     data = {"activity": activity.id}
     form = NGReportForm(data)
     ok_(not form.is_valid())
     ok_("campaign" in form.errors)
     ok_(form.errors["campaign"], "Please select an option from the list.")
開發者ID:flaki,項目名稱:remo,代碼行數:9,代碼來源:test_forms.py

示例3: test_base

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 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,代碼行數:33,代碼來源:test_forms.py

示例4: test_base

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def test_base(self):
     user = UserFactory.create()
     activity = ActivityFactory.create()
     functional_area = FunctionalAreaFactory.create()
     data = {
         'report_date': '25 March 2012',
         'activity': activity.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:Binzzzz,項目名稱:remo,代碼行數:31,代碼來源:test_forms.py

示例5: test_base_content_activity_delete_post

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def test_base_content_activity_delete_post(self):
     """Test delete activity."""
     admin = UserFactory.create(groups=['Admin'])
     activity = ActivityFactory.create(name='test activity')
     response = self.post(reverse('delete_activity',
                                  kwargs={'pk': activity.id}), user=admin,
                          follow=True)
     eq_(response.status_code, 200)
     query = Activity.objects.filter(name='test activity')
     eq_(query.exists(), False)
開發者ID:abshetewy,項目名稱:remo,代碼行數:12,代碼來源:test_views.py

示例6: test_campain_activity_without_campaign

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def test_campain_activity_without_campaign(self):
     activity = ActivityFactory.create(
         name='Participated in a campaign')
     data = {
         'activity': activity.id
     }
     form = NGReportForm(data)
     ok_(not form.is_valid())
     ok_('campaign' in form.errors)
     ok_(form.errors['campaign'],
         'Please select an option from the list.')
開發者ID:josephbosire,項目名稱:remo,代碼行數:13,代碼來源:test_forms.py

示例7: test_base_content_activity_edit_post

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def test_base_content_activity_edit_post(self):
     """Test post edit activity."""
     admin = UserFactory.create(groups=['Admin'])
     activity = ActivityFactory.create(name='test activity')
     with self.login(admin) as client:
         response = client.post(reverse('edit_activity', kwargs={'pk': activity.id}),
                                data={'name': 'edit activity'},
                                follow=True)
     eq_(response.status_code, 200)
     query = Activity.objects.filter(name='edit activity')
     eq_(query.exists(), True)
開發者ID:Josespaul,項目名稱:remo,代碼行數:13,代碼來源:test_views.py

示例8: test_edit_event

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
    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,代碼行數:17,代碼來源:test_forms.py

示例9: test_verify_activity

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
    def test_verify_activity(self):
        model = ContentType.objects.get_for_model(NGReport)
        items = ActionItem.objects.filter(content_type=model)
        ok_(not items.exists())

        activity = ActivityFactory.create(name=RECRUIT_MOZILLIAN)
        mentor = UserFactory.create()
        user = UserFactory.create(groups=['Rep'], userprofile__mentor=mentor)
        report = NGReportFactory.create(activity=activity, user=user,
                                        mentor=mentor)

        items = ActionItem.objects.filter(content_type=model,
                                          object_id=report.id,
                                          resolved=False)
        eq_(items.count(), 1)
開發者ID:flaki,項目名稱:remo,代碼行數:17,代碼來源:test_models.py

示例10: test_edit_event

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def test_edit_event(self):
     """Edit NGReport with inactive categories."""
     activity = ActivityFactory.create()
     active_area = FunctionalAreaFactory.create()
     inactive_areas = FunctionalAreaFactory.create_batch(2, active=False)
     report = NGReportFactory.create(activity=activity,
                                     functional_areas=inactive_areas)
     data = model_to_dict(report)
     areas = [active_area.id] + [x.id for x in inactive_areas]
     data['functional_areas'] = areas
     form = NGReportForm(data, instance=report)
     ok_(form.is_valid())
     result = form.save()
     for area in inactive_areas + [active_area]:
         ok_(area in result.functional_areas.all())
開發者ID:Binzzzz,項目名稱:remo,代碼行數:17,代碼來源:test_forms.py

示例11: setUp

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def setUp(self):
     ActivityFactory.create(name=ACTIVITY_EVENT_ATTEND)
     ActivityFactory.create(name=ACTIVITY_EVENT_CREATE)
開發者ID:Josespaul,項目名稱:remo,代碼行數:5,代碼來源:test_models.py

示例12: setUp

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def setUp(self):
     ActivityFactory.create(name=ACTIVITY_EVENT_CREATE)
     self.single_day_end = START_DT + datetime.timedelta(hours=4)
開發者ID:Josespaul,項目名稱:remo,代碼行數:5,代碼來源:test_helpers.py

示例13: setUp

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def setUp(self):
     ActivityFactory.create(name=ACTIVITY_EVENT_CREATE)
     self.start = datetime.combine(get_date(days=-1), datetime.min.time())
     self.end = datetime.combine(get_date(days=-1), datetime.max.time())
開發者ID:Josespaul,項目名稱:remo,代碼行數:6,代碼來源:test_tasks.py

示例14: setUp

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def setUp(self):
     ActivityFactory.create(name=ACTIVITY_EVENT_CREATE)
     self.event = EventFactory.create()
開發者ID:Josespaul,項目名稱:remo,代碼行數:5,代碼來源:test_models.py

示例15: setUp

# 需要導入模塊: from remo.reports.tests import ActivityFactory [as 別名]
# 或者: from remo.reports.tests.ActivityFactory import create [as 別名]
 def setUp(self):
     self.factory = RequestFactory()
     self.url = '/api/kpi/events'
     ActivityFactory.create(name=ACTIVITY_EVENT_CREATE)
開發者ID:Josespaul,項目名稱:remo,代碼行數:6,代碼來源:test_api.py


注:本文中的remo.reports.tests.ActivityFactory.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。