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


Python TestTools.create_blank_activity方法代码示例

本文整理汇总了Python中tapiriik.testing.testtools.TestTools.create_blank_activity方法的典型用法代码示例。如果您正苦于以下问题:Python TestTools.create_blank_activity方法的具体用法?Python TestTools.create_blank_activity怎么用?Python TestTools.create_blank_activity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tapiriik.testing.testtools.TestTools的用法示例。


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

示例1: test_eligibility_flowexception_none

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
    def test_eligibility_flowexception_none(self):
        user = TestTools.create_mock_user()
        svcA, svcB = TestTools.create_mock_services()
        recA = TestTools.create_mock_svc_record(svcA)
        recB = TestTools.create_mock_svc_record(svcB)
        act = TestTools.create_blank_activity(svcA, record=recB)
        act.Origin = recB
        act.UIDs = set([act.UID])
        act.Record = ActivityRecord.FromActivity(act)
        User.SetFlowException(user, recA, recB, flowToSource=False, flowToTarget=False)
        recipientServices = [recA]
        s = SynchronizationTask(None)
        s._excludedServices = {}
        s.user = user
        s._serviceConnections = [recA, recB]
        eligible = s._determineEligibleRecipientServices(act, recipientServices)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB not in eligible)

        recipientServices = [recB]
        act.Origin = recA
        act.ServiceDataCollection = TestTools.create_mock_servicedatacollection(svcA, record=recA)
        eligible = s._determineEligibleRecipientServices(act, recipientServices)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB not in eligible)
开发者ID:OkanEsen,项目名称:tapiriik,代码行数:27,代码来源:sync.py

示例2: test_eligibility_flowexception_shortcircuit

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
    def test_eligibility_flowexception_shortcircuit(self):
        user = TestTools.create_mock_user()
        svcA, svcB = TestTools.create_mock_services()
        svcC = TestTools.create_mock_service("mockC")
        recA = TestTools.create_mock_svc_record(svcA)
        recB = TestTools.create_mock_svc_record(svcB)
        recC = TestTools.create_mock_svc_record(svcC)
        act = TestTools.create_blank_activity(svcA, record=recA)
        User.SetFlowException(user, recA, recC, flowToTarget=False)

        # Behaviour with known origin and no override set
        act.Origin = recA
        recipientServices = [recC, recB]
        excludedServices = []
        eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=[recA, recB, recC], recipientServices=recipientServices, excludedServices=excludedServices, user=user)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB in eligible)
        self.assertTrue(recC not in eligible)

        # Enable alternate routing
        recB.SetConfiguration({"allow_activity_flow_exception_bypass_via_self":True}, no_save=True)
        self.assertTrue(recB.GetConfiguration()["allow_activity_flow_exception_bypass_via_self"])
        # We should now be able to arrive at recC via recB
        act.Origin = recA
        recipientServices = [recC, recB]
        excludedServices = []
        eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=[recA, recB, recC], recipientServices=recipientServices, excludedServices=excludedServices, user=user)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB in eligible)
        self.assertTrue(recC in eligible)
开发者ID:7e7,项目名称:tapiriik,代码行数:32,代码来源:sync.py

示例3: test_eligibility_excluded

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
 def test_eligibility_excluded(self):
     user = TestTools.create_mock_user()
     svcA, svcB = TestTools.create_mock_services()
     recA = TestTools.create_mock_svc_record(svcA)
     recB = TestTools.create_mock_svc_record(svcB)
     act = TestTools.create_blank_activity(svcA, record=recB)
     recipientServices = [recA, recB]
     excludedServices = [recA]
     eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=recipientServices, recipientServices=recipientServices, excludedServices=excludedServices, user=user)
     self.assertTrue(recB in eligible)
     self.assertTrue(recA not in eligible)
开发者ID:7e7,项目名称:tapiriik,代码行数:13,代码来源:sync.py

示例4: test_eligibility_flowexception_reverse

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
 def test_eligibility_flowexception_reverse(self):
     user = TestTools.create_mock_user()
     svcA, svcB = TestTools.create_mock_services()
     recA = TestTools.create_mock_svc_record(svcA)
     recB = TestTools.create_mock_svc_record(svcB)
     act = TestTools.create_blank_activity(svcA, record=recB)
     act.Origin = recB
     User.SetFlowException(user, recA, recB, flowToSource=False)
     recipientServices = [recA, recB]
     excludedServices = []
     eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=recipientServices, recipientServices=recipientServices, excludedServices=excludedServices, user=user)
     self.assertFalse(recA in eligible)
     self.assertTrue(recB in eligible)
开发者ID:7e7,项目名称:tapiriik,代码行数:15,代码来源:sync.py

示例5: test_eligibility_config

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
 def test_eligibility_config(self):
     user = TestTools.create_mock_user()
     svcA, svcB = TestTools.create_mock_services()
     svcA.Configurable = True
     svcA.RequiresConfiguration = lambda x: True
     recA = TestTools.create_mock_svc_record(svcA)
     recB = TestTools.create_mock_svc_record(svcB)
     act = TestTools.create_blank_activity(svcA, record=recB)
     recipientServices = [recA, recB]
     excludedServices = []
     eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=recipientServices, recipientServices=recipientServices, excludedServices=excludedServices, user=user)
     self.assertTrue(recB in eligible)
     self.assertTrue(recA not in eligible)
开发者ID:7e7,项目名称:tapiriik,代码行数:15,代码来源:sync.py

示例6: test_eligibility_excluded

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
 def test_eligibility_excluded(self):
     user = TestTools.create_mock_user()
     svcA, svcB = TestTools.create_mock_services()
     recA = TestTools.create_mock_svc_record(svcA)
     recB = TestTools.create_mock_svc_record(svcB)
     act = TestTools.create_blank_activity(svcA, record=recB)
     recipientServices = [recA, recB]
     s = SynchronizationTask(None)
     s._excludedServices = {recA._id: UserException(UserExceptionType.Private)}
     s.user = user
     s._serviceConnections = recipientServices
     act.UIDs = set([act.UID])
     act.Record = ActivityRecord.FromActivity(act)
     eligible = s._determineEligibleRecipientServices(act, recipientServices)
     self.assertTrue(recB in eligible)
     self.assertTrue(recA not in eligible)
开发者ID:OkanEsen,项目名称:tapiriik,代码行数:18,代码来源:sync.py

示例7: test_eligibility_config

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
 def test_eligibility_config(self):
     user = TestTools.create_mock_user()
     svcA, svcB = TestTools.create_mock_services()
     svcA.Configurable = True
     svcA.RequiresConfiguration = lambda x: True
     recA = TestTools.create_mock_svc_record(svcA)
     recB = TestTools.create_mock_svc_record(svcB)
     act = TestTools.create_blank_activity(svcA, record=recB)
     recipientServices = [recA, recB]
     s = SynchronizationTask(None)
     s._excludedServices = {}
     s.user = user
     s._serviceConnections = recipientServices
     act.UIDs = set([act.UID])
     act.Record = ActivityRecord.FromActivity(act)
     eligible = s._determineEligibleRecipientServices(act, recipientServices)
     self.assertTrue(recB in eligible)
     self.assertTrue(recA not in eligible)
开发者ID:OkanEsen,项目名称:tapiriik,代码行数:20,代码来源:sync.py

示例8: test_accumulate_exclusions

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
    def test_accumulate_exclusions(self):
        svcA, svcB = TestTools.create_mock_services()
        recA = TestTools.create_mock_svc_record(svcA)

        # regular
        s = SynchronizationTask(None)
        s._syncExclusions = {recA._id: {}}
        exc = APIExcludeActivity("Messag!e", activity_id=3.14)
        s._accumulateExclusions(recA, exc)
        exclusionstore = s._syncExclusions
        self.assertTrue("3_14" in exclusionstore[recA._id])
        self.assertEqual(exclusionstore[recA._id]["3_14"]["Message"], "Messag!e")
        self.assertEqual(exclusionstore[recA._id]["3_14"]["Activity"], None)
        self.assertEqual(exclusionstore[recA._id]["3_14"]["ExternalActivityID"], 3.14)
        self.assertEqual(exclusionstore[recA._id]["3_14"]["Permanent"], True)

        # updating
        act = TestTools.create_blank_activity(svcA)
        act.UID = "3_14"  # meh
        exc = APIExcludeActivity("Messag!e2", activity_id=42, permanent=False, activity=act)
        s = SynchronizationTask(None)
        s._syncExclusions = {recA._id: {}}
        s._accumulateExclusions(recA, exc)
        exclusionstore = s._syncExclusions
        self.assertTrue("3_14" in exclusionstore[recA._id])
        self.assertEqual(exclusionstore[recA._id]["3_14"]["Message"], "Messag!e2")
        self.assertNotEqual(exclusionstore[recA._id]["3_14"]["Activity"], None)  # Who knows what the string format will be down the road?
        self.assertEqual(exclusionstore[recA._id]["3_14"]["ExternalActivityID"], 42)
        self.assertEqual(exclusionstore[recA._id]["3_14"]["Permanent"], False)

        # multiple, retaining existing
        exc2 = APIExcludeActivity("INM", activity_id=13)
        exc3 = APIExcludeActivity("FNIM", activity_id=37)
        s._accumulateExclusions(recA, [exc2, exc3])
        exclusionstore = s._syncExclusions
        self.assertTrue("3_14" in exclusionstore[recA._id])
        self.assertTrue("37" in exclusionstore[recA._id])
        self.assertTrue("13" in exclusionstore[recA._id])

        # don't allow with no identifiers
        exc4 = APIExcludeActivity("nooooo")
        s = SynchronizationTask(None)
        s._syncExclusions = {}
        self.assertRaises(ValueError, s._accumulateExclusions, recA, [exc4])
开发者ID:OkanEsen,项目名称:tapiriik,代码行数:46,代码来源:sync.py

示例9: test_eligibility_flowexception_none

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
    def test_eligibility_flowexception_none(self):
        user = TestTools.create_mock_user()
        svcA, svcB = TestTools.create_mock_services()
        recA = TestTools.create_mock_svc_record(svcA)
        recB = TestTools.create_mock_svc_record(svcB)
        act = TestTools.create_blank_activity(svcA, record=recB)
        act.Origin = recB
        User.SetFlowException(user, recA, recB, flowToSource=False, flowToTarget=False)
        recipientServices = [recA]
        excludedServices = []
        eligible = Sync._determineEligibleRecipientServices(activity=act, recipientServices=recipientServices, excludedServices=excludedServices, user=user)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB not in eligible)

        recipientServices = [recB]
        act.Origin = recA
        act.UploadedTo = [TestTools.create_mock_upload_record(svcA, record=recA)]
        eligible = Sync._determineEligibleRecipientServices(activity=act, recipientServices=recipientServices, excludedServices=excludedServices, user=user)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB not in eligible)
开发者ID:euphoria,项目名称:tapiriik,代码行数:22,代码来源:sync.py

示例10: test_eligibility_flowexception_change

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
    def test_eligibility_flowexception_change(self):
        user = TestTools.create_mock_user()
        svcA, svcB = TestTools.create_mock_services()
        recA = TestTools.create_mock_svc_record(svcA)
        recB = TestTools.create_mock_svc_record(svcB)
        act = TestTools.create_blank_activity(svcA, record=recB)
        act.Origin = recB

        recipientServices = [recA]
        excludedServices = []


        User.SetFlowException(user, recA, recB, flowToSource=False, flowToTarget=True)
        eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=[recA, recB], recipientServices=recipientServices, excludedServices=excludedServices, user=user)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB not in eligible)

        recipientServices = [recB]
        act.Origin = recA
        act.ServiceDataCollection = TestTools.create_mock_servicedatacollection(svcA, record=recA)
        User.SetFlowException(user, recA, recB, flowToSource=True, flowToTarget=False)
        eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=[recA, recB], recipientServices=recipientServices, excludedServices=excludedServices, user=user)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB not in eligible)

        User.SetFlowException(user, recA, recB, flowToSource=False, flowToTarget=False)
        eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=[recA, recB], recipientServices=recipientServices, excludedServices=excludedServices, user=user)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB not in eligible)

        recipientServices = [recA, recB]
        User.SetFlowException(user, recA, recB, flowToSource=True, flowToTarget=True)
        eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=[recA, recB], recipientServices=recipientServices, excludedServices=excludedServices, user=user)
        self.assertTrue(recA in eligible)
        self.assertTrue(recB in eligible)

        eligible = Sync._determineEligibleRecipientServices(activity=act, connectedServices=[recA, recB], recipientServices=recipientServices, excludedServices=excludedServices, user=user)
        self.assertTrue(recA in eligible)
        self.assertTrue(recB in eligible)
开发者ID:7e7,项目名称:tapiriik,代码行数:41,代码来源:sync.py

示例11: test_eligibility_flowexception_shortcircuit

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
    def test_eligibility_flowexception_shortcircuit(self):
        user = TestTools.create_mock_user()
        svcA, svcB = TestTools.create_mock_services()
        svcC = TestTools.create_mock_service("mockC")
        recA = TestTools.create_mock_svc_record(svcA)
        recB = TestTools.create_mock_svc_record(svcB)
        recC = TestTools.create_mock_svc_record(svcC)
        act = TestTools.create_blank_activity(svcA, record=recA)
        User.SetFlowException(user, recA, recC, flowToTarget=False)

        # Behaviour with known origin and no override set
        act.Origin = recA
        act.UIDs = set([act.UID])
        act.Record = ActivityRecord.FromActivity(act)
        recipientServices = [recC, recB]
        s = SynchronizationTask(None)
        s._excludedServices = {}
        s.user = user
        s._serviceConnections = [recA, recB, recC]
        eligible = s._determineEligibleRecipientServices(act, recipientServices)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB in eligible)
        self.assertTrue(recC not in eligible)

        # Enable alternate routing
        # FIXME: This setting doesn't seem to be used anywhere any more??  Test disabled at the end..
        recB.SetConfiguration({"allow_activity_flow_exception_bypass_via_self": True}, no_save=True)
        self.assertTrue(recB.GetConfiguration()["allow_activity_flow_exception_bypass_via_self"])
        # We should now be able to arrive at recC via recB
        act.Origin = recA
        act.UIDs = set([act.UID])
        act.Record = ActivityRecord.FromActivity(act)
        recipientServices = [recC, recB]
        s._excludedServices = {}
        s._serviceConnections = [recA, recB, recC]
        eligible = s._determineEligibleRecipientServices(act, recipientServices)
        self.assertTrue(recA not in eligible)
        self.assertTrue(recB in eligible)
开发者ID:OkanEsen,项目名称:tapiriik,代码行数:40,代码来源:sync.py

示例12: test_duration_calculation

# 需要导入模块: from tapiriik.testing.testtools import TestTools [as 别名]
# 或者: from tapiriik.testing.testtools.TestTools import create_blank_activity [as 别名]
    def test_duration_calculation(self):
        ''' ensures that true-duration calculation is being reasonable '''
        act = TestTools.create_blank_activity()
        act.StartTime = datetime.now()
        act.EndTime = act.StartTime + timedelta(hours=3)

        # No waypoints
        self.assertRaises(ValueError, act.GetMovingTime)

        # Too few waypoints
        act.Waypoints = [Waypoint(timestamp=act.StartTime), Waypoint(timestamp=act.EndTime)]
        self.assertRaises(ValueError, act.GetMovingTime)

        # straight-up calculation
        act.EndTime = act.StartTime + timedelta(seconds=14)
        act.Waypoints = [Waypoint(timestamp=act.StartTime),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=2)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=6)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=10)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=14))]
        self.assertEqual(act.GetMovingTime(), timedelta(seconds=14))

        # pauses
        act.EndTime = act.StartTime + timedelta(seconds=14)
        act.Waypoints = [Waypoint(timestamp=act.StartTime),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=2)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=6), ptType=WaypointType.Pause),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=9), ptType=WaypointType.Pause),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=10), ptType=WaypointType.Resume),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=14))]
        self.assertEqual(act.GetMovingTime(), timedelta(seconds=10))

        # laps - NO effect
        act.EndTime = act.StartTime + timedelta(seconds=14)
        act.Waypoints = [Waypoint(timestamp=act.StartTime),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=2)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=6), ptType=WaypointType.Lap),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=9)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=10), ptType=WaypointType.Lap),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=14))]
        self.assertEqual(act.GetMovingTime(), timedelta(seconds=14))

        # multiple pauses + ending after pause
        act.EndTime = act.StartTime + timedelta(seconds=20)
        act.Waypoints = [Waypoint(timestamp=act.StartTime),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=2)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=6), ptType=WaypointType.Pause),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=9), ptType=WaypointType.Pause),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=10), ptType=WaypointType.Resume),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=12)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=16)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=17), ptType=WaypointType.Pause),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=20), ptType=WaypointType.End)]
        self.assertEqual(act.GetMovingTime(), timedelta(seconds=13))

        # implicit pauses (>1m5s)
        act.EndTime = act.StartTime + timedelta(seconds=20)
        act.Waypoints = [Waypoint(timestamp=act.StartTime),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=2)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=6)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=120)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=124)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=130))]
        self.assertEqual(act.GetMovingTime(), timedelta(seconds=16))

        # mixed pauses - would this ever happen?? Either way, the explicit pause should override the implicit one and cause otherwise-ignored time to be counted
        act.EndTime = act.StartTime + timedelta(seconds=23)
        act.Waypoints = [Waypoint(timestamp=act.StartTime),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=2)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=6)),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=20), ptType=WaypointType.Pause),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=24), ptType=WaypointType.Resume),
                         Waypoint(timestamp=act.StartTime + timedelta(seconds=30))]
        self.assertEqual(act.GetMovingTime(), timedelta(seconds=26))
开发者ID:CptanPanic,项目名称:tapiriik,代码行数:76,代码来源:interchange.py


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