本文整理汇总了Python中tapiriik.services.interchange.Activity.Record方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.Record方法的具体用法?Python Activity.Record怎么用?Python Activity.Record使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tapiriik.services.interchange.Activity
的用法示例。
在下文中一共展示了Activity.Record方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_svc_supported_activity_types
# 需要导入模块: from tapiriik.services.interchange import Activity [as 别名]
# 或者: from tapiriik.services.interchange.Activity import Record [as 别名]
def test_svc_supported_activity_types(self):
''' check that only activities are only sent to services which support them '''
svcA, svcB = TestTools.create_mock_services()
recA = TestTools.create_mock_svc_record(svcA)
recB = TestTools.create_mock_svc_record(svcB)
svcA.SupportedActivities = [ActivityType.CrossCountrySkiing]
svcB.SupportedActivities = [ActivityType.Cycling]
actA = Activity()
actA.StartTime = datetime(1, 2, 3, 4, 5, 6, 7)
actA.ServiceDataCollection = TestTools.create_mock_servicedatacollection(svcA, record=recA)
actA.Type = svcA.SupportedActivities[0]
actA.CalculateUID()
actA.UIDs = set([actA.UID])
actA.Record = ActivityRecord.FromActivity(actA)
actB = Activity()
actB.StartTime = datetime(5, 6, 7, 8, 9, 10, 11)
actB.ServiceDataCollection = TestTools.create_mock_servicedatacollection(svcB, record=recB)
actB.Type = [x for x in svcB.SupportedActivities if x != actA.Type][0]
actB.CalculateUID()
actB.UIDs = set([actB.UID])
actB.Record = ActivityRecord.FromActivity(actB)
s = SynchronizationTask(None)
s._serviceConnections = [recA, recB]
s._activities = []
s._accumulateActivities(recA, [actA])
s._accumulateActivities(recB, [actB])
syncToA = s._determineRecipientServices(actA)
syncToB = s._determineRecipientServices(actB)
self.assertEqual(len(syncToA), 0)
self.assertEqual(len(syncToB), 0)
svcB.SupportedActivities = svcA.SupportedActivities
syncToA = s._determineRecipientServices(actA)
syncToB = s._determineRecipientServices(actB)
self.assertEqual(len(syncToA), 1)
self.assertEqual(len(syncToB), 0)
svcB.SupportedActivities = svcA.SupportedActivities = [ActivityType.CrossCountrySkiing, ActivityType.Cycling]
syncToA = s._determineRecipientServices(actA)
syncToB = s._determineRecipientServices(actB)
self.assertEqual(len(syncToA), 1)
self.assertEqual(len(syncToB), 1)