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])
dataset/ETHPy150Open cpfair/tapiriik/tapiriik/testing/sync.py/SyncTests.test_accumulate_exclusions/original