Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
    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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)