本文整理汇总了Python中tapiriik.sync.Sync._accumulateExclusions方法的典型用法代码示例。如果您正苦于以下问题:Python Sync._accumulateExclusions方法的具体用法?Python Sync._accumulateExclusions怎么用?Python Sync._accumulateExclusions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tapiriik.sync.Sync
的用法示例。
在下文中一共展示了Sync._accumulateExclusions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_accumulate_exclusions
# 需要导入模块: from tapiriik.sync import Sync [as 别名]
# 或者: from tapiriik.sync.Sync import _accumulateExclusions [as 别名]
def test_accumulate_exclusions(self):
svcA, svcB = TestTools.create_mock_services()
recA = TestTools.create_mock_svc_record(svcA)
exclusionstore = {recA._id: {}}
# regular
exc = APIExcludeActivity("Messag!e", activityId=3.14)
Sync._accumulateExclusions(recA, exc, exclusionstore)
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", activityId=42, permanent=False, activity=act)
Sync._accumulateExclusions(recA, exc, exclusionstore)
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", activityId=13)
exc3 = APIExcludeActivity("FNIM", activityId=37)
Sync._accumulateExclusions(recA, [exc2, exc3], exclusionstore)
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")
self.assertRaises(ValueError, Sync._accumulateExclusions, recA, [exc4], exclusionstore)