Beispiel #1
0
 def test_list_with_tuples(self):
     result = flatten([1, 2, (
         3,
         4,
         (),
         (5, ),
         [[[[6]]]],
     )])
     self.assertEqual(list(result), [1, 2, 3, 4, 5, 6])
    def test_add_expiration_if_expired_method(self):
        tests = (                                   # Expected action type,      branch, scenario
                (Action.TYPES.REQUEST,                Action.TYPES.EXPIRATION,        0, []),
                (Action.TYPES.CLARIFICATION_RESPONSE, Action.TYPES.EXPIRATION,        0, [u'clarification_request', u'clarification_response']),
                (Action.TYPES.APPEAL,                 Action.TYPES.APPEAL_EXPIRATION, 0, [u'expiration', u'appeal']),
                (Action.TYPES.CONFIRMATION,           Action.TYPES.EXPIRATION,        0, [u'confirmation']),
                (Action.TYPES.EXTENSION,              Action.TYPES.EXPIRATION,        0, [u'extension']),
                (Action.TYPES.ADVANCEMENT,            None,                           0, [u'advancement']),
                (Action.TYPES.CLARIFICATION_REQUEST,  None,                           0, [u'clarification_request']),
                (Action.TYPES.DISCLOSURE,             None,                           0, [u'disclosure']),
                (Action.TYPES.REFUSAL,                None,                           0, [u'refusal']),
                (Action.TYPES.AFFIRMATION,            None,                           0, [u'refusal', u'appeal', u'affirmation']),
                (Action.TYPES.REVERSION,              None,                           0, [u'refusal', u'appeal', u'reversion']),
                (Action.TYPES.REMANDMENT,             Action.TYPES.EXPIRATION,        0, [u'refusal', u'appeal', u'remandment']),
                (Action.TYPES.ADVANCED_REQUEST,       Action.TYPES.EXPIRATION,        1, [u'advancement']),
                (Action.TYPES.EXPIRATION,             None,                           0, [u'expiration']),
                (Action.TYPES.APPEAL_EXPIRATION,      None,                           0, [u'refusal', u'appeal', u'appeal_expiration']),
                )
        # Make sure we are testing all defined action types
        tested_action_types = set(a for a, _, _, _ in tests)
        defined_action_types = Action.TYPES._inverse.keys()
        self.assertItemsEqual(tested_action_types, defined_action_types)

        for action_type, expected_action_type, branch, scenario in tests:
            timewarp.jump(local_datetime_from_local(u'2010-07-05 10:33:00'))
            objs = self._create_inforequest_scenario(*scenario)
            branch = [o for o in flatten(objs) if isinstance(o, Branch)][branch]
            self.assertEqual(branch.last_action.type, action_type)
            original_last_action = branch.last_action

            # Deadline not expired yet
            with created_instances(Action.objects) as action_set:
                branch.add_expiration_if_expired()
            self.assertEqual(action_set.count(), 0)

            # Any deadline is expired now
            timewarp.jump(local_datetime_from_local(u'2010-10-05 10:33:00'))
            branch = Branch.objects.get(pk=branch.pk)
            with created_instances(Action.objects) as action_set:
                branch.add_expiration_if_expired()

            branch = Branch.objects.get(pk=branch.pk)
            if expected_action_type is None:
                self.assertEqual(action_set.count(), 0)
                self.assertEqual(branch.last_action, original_last_action)
            else:
                added_action = action_set.get()
                self.assertEqual(branch.last_action, added_action)
                self.assertEqual(added_action.type, expected_action_type)
                self.assertEqual(added_action.effective_date, naive_date(u'2010-10-05'))
    def test_collect_obligee_emails_method_ignores_addresses_from_other_branches(self):
        obligee1 = self._create_obligee(emails=u'Obligee1 <*****@*****.**>')
        obligee2 = self._create_obligee(emails=u'Ignored <*****@*****.**>')
        _, branch, actions = self._create_inforequest_scenario(obligee1,
                u'request',
                u'refusal',
                (u'advancement', [obligee2, u'advanced_request', u'refusal']),
                )
        result = list(branch.collect_obligee_emails())
        self.assertItemsEqual(result, [(u'Obligee1', u'*****@*****.**')])

        # For reference check that the method for the advanced branch returs the other address
        branch2 = [o for o in flatten(actions) if isinstance(o, Branch)][0]
        result = list(branch2.collect_obligee_emails())
        self.assertItemsEqual(result, [(u'Ignored', u'*****@*****.**')])
Beispiel #4
0
    def test_collect_obligee_emails_method_ignores_addresses_from_other_branches(
            self):
        obligee1 = self._create_obligee(emails=u'Obligee1 <*****@*****.**>')
        obligee2 = self._create_obligee(emails=u'Ignored <*****@*****.**>')
        _, branch, actions = self._create_inforequest_scenario(
            obligee1,
            u'request',
            u'refusal',
            (u'advancement', [obligee2, u'advanced_request', u'refusal']),
        )
        result = list(branch.collect_obligee_emails())
        self.assertItemsEqual(result, [(u'Obligee1', u'*****@*****.**')])

        # For reference check that the method for the advanced branch returs the other address
        branch2 = [o for o in flatten(actions) if isinstance(o, Branch)][0]
        result = list(branch2.collect_obligee_emails())
        self.assertItemsEqual(result, [(u'Ignored', u'*****@*****.**')])
Beispiel #5
0
    def test_add_expiration_if_expired_method(self):
        tests = (  # Expected action type,      branch, scenario
            (Action.TYPES.REQUEST, Action.TYPES.EXPIRATION, 0, []),
            (Action.TYPES.CLARIFICATION_RESPONSE, Action.TYPES.EXPIRATION, 0,
             [u'clarification_request', u'clarification_response']),
            (Action.TYPES.APPEAL, Action.TYPES.APPEAL_EXPIRATION, 0,
             [u'expiration', u'appeal']),
            (Action.TYPES.CONFIRMATION, Action.TYPES.EXPIRATION, 0,
             [u'confirmation']),
            (Action.TYPES.EXTENSION, Action.TYPES.EXPIRATION, 0,
             [u'extension']),
            (Action.TYPES.ADVANCEMENT, None, 0, [u'advancement']),
            (Action.TYPES.CLARIFICATION_REQUEST, None, 0,
             [u'clarification_request']),
            (Action.TYPES.DISCLOSURE, None, 0, [u'disclosure']),
            (Action.TYPES.REFUSAL, None, 0, [u'refusal']),
            (Action.TYPES.AFFIRMATION, None, 0,
             [u'refusal', u'appeal', u'affirmation']),
            (Action.TYPES.REVERSION, None, 0,
             [u'refusal', u'appeal', u'reversion']),
            (Action.TYPES.REMANDMENT, Action.TYPES.EXPIRATION, 0,
             [u'refusal', u'appeal', u'remandment']),
            (Action.TYPES.ADVANCED_REQUEST, Action.TYPES.EXPIRATION, 1,
             [u'advancement']),
            (Action.TYPES.EXPIRATION, None, 0, [u'expiration']),
            (Action.TYPES.APPEAL_EXPIRATION, None, 0,
             [u'refusal', u'appeal', u'appeal_expiration']),
        )
        # Make sure we are testing all defined action types
        tested_action_types = set(a for a, _, _, _ in tests)
        defined_action_types = Action.TYPES._inverse.keys()
        self.assertItemsEqual(tested_action_types, defined_action_types)

        for action_type, expected_action_type, branch, scenario in tests:
            timewarp.jump(local_datetime_from_local(u'2010-07-05 10:33:00'))
            objs = self._create_inforequest_scenario(*scenario)
            branch = [o for o in flatten(objs)
                      if isinstance(o, Branch)][branch]
            self.assertEqual(branch.last_action.type, action_type)
            original_last_action = branch.last_action

            # Deadline not expired yet
            with created_instances(Action.objects) as action_set:
                branch.add_expiration_if_expired()
            self.assertEqual(action_set.count(), 0)

            # Any deadline is expired now
            timewarp.jump(local_datetime_from_local(u'2010-10-05 10:33:00'))
            branch = Branch.objects.get(pk=branch.pk)
            with created_instances(Action.objects) as action_set:
                branch.add_expiration_if_expired()

            branch = Branch.objects.get(pk=branch.pk)
            if expected_action_type is None:
                self.assertEqual(action_set.count(), 0)
                self.assertEqual(branch.last_action, original_last_action)
            else:
                added_action = action_set.get()
                self.assertEqual(branch.last_action, added_action)
                self.assertEqual(added_action.type, expected_action_type)
                self.assertEqual(added_action.effective_date,
                                 naive_date(u'2010-10-05'))
Beispiel #6
0
    def test_can_add_x_properties(self):
        tests = (
            (Action.TYPES.REQUEST,
             Bunch(
                 scenario=[],
                 allowed=[
                     u'confirmation', u'extension', u'advancement',
                     u'clarification_request', u'disclosure', u'refusal',
                     u'obligee_action', u'obligee_email_action'
                 ],
                 expired=[
                     u'appeal', u'confirmation', u'extension', u'advancement',
                     u'clarification_request', u'disclosure', u'refusal',
                     u'obligee_action', u'obligee_email_action',
                     u'applicant_action'
                 ],
             )),
            (Action.TYPES.CLARIFICATION_RESPONSE,
             Bunch(
                 scenario=[
                     u'clarification_request', u'clarification_response'
                 ],
                 allowed=[
                     u'extension', u'advancement', u'clarification_request',
                     u'disclosure', u'refusal', u'obligee_action',
                     u'obligee_email_action'
                 ],
                 expired=[
                     u'appeal', u'extension', u'advancement',
                     u'clarification_request', u'disclosure', u'refusal',
                     u'obligee_action', u'obligee_email_action',
                     u'applicant_action'
                 ],
             )),
            (Action.TYPES.APPEAL,
             Bunch(
                 scenario=[u'expiration', u'appeal'],
                 allowed=[
                     u'affirmation', u'reversion', u'remandment',
                     u'obligee_action'
                 ],
                 expired=[
                     u'affirmation', u'reversion', u'remandment',
                     u'obligee_action'
                 ],
             )),
            (Action.TYPES.CONFIRMATION,
             Bunch(
                 scenario=[u'confirmation'],
                 allowed=[
                     u'extension', u'advancement', u'clarification_request',
                     u'disclosure', u'refusal', u'obligee_action',
                     u'obligee_email_action'
                 ],
                 expired=[
                     u'appeal', u'extension', u'advancement',
                     u'clarification_request', u'disclosure', u'refusal',
                     u'obligee_action', u'obligee_email_action',
                     u'applicant_action'
                 ],
             )),
            (Action.TYPES.EXTENSION,
             Bunch(
                 scenario=[u'extension'],
                 allowed=[
                     u'disclosure', u'refusal', u'obligee_action',
                     u'obligee_email_action'
                 ],
                 expired=[
                     u'appeal', u'disclosure', u'refusal', u'obligee_action',
                     u'obligee_email_action', u'applicant_action'
                 ],
             )),
            (Action.TYPES.ADVANCEMENT,
             Bunch(
                 scenario=[u'advancement'],
                 allowed=[u'appeal', u'applicant_action'],
                 expired=[u'appeal', u'applicant_action'],
             )),
            (Action.TYPES.CLARIFICATION_REQUEST,
             Bunch(
                 scenario=[u'clarification_request'],
                 allowed=[
                     u'clarification_response', u'clarification_request',
                     u'obligee_action', u'obligee_email_action',
                     u'applicant_action', u'applicant_email_action'
                 ],
                 expired=[
                     u'clarification_response', u'clarification_request',
                     u'obligee_action', u'obligee_email_action',
                     u'applicant_action', u'applicant_email_action'
                 ],
             )),
            (Action.TYPES.DISCLOSURE,
             Bunch(
                 scenario=[
                     (u'disclosure',
                      dict(disclosure_level=Action.DISCLOSURE_LEVELS.NONE))
                 ],
                 allowed=[u'appeal', u'applicant_action'],
                 expired=[u'appeal', u'applicant_action'],
             )),
            (Action.TYPES.DISCLOSURE,
             Bunch(
                 scenario=[
                     (u'disclosure',
                      dict(disclosure_level=Action.DISCLOSURE_LEVELS.PARTIAL))
                 ],
                 allowed=[u'appeal', u'applicant_action'],
                 expired=[u'appeal', u'applicant_action'],
             )),
            (Action.TYPES.DISCLOSURE,
             Bunch(
                 scenario=[
                     (u'disclosure',
                      dict(disclosure_level=Action.DISCLOSURE_LEVELS.FULL))
                 ],
                 allowed=[],
                 expired=[],
             )),
            (Action.TYPES.REFUSAL,
             Bunch(
                 scenario=[u'refusal'],
                 allowed=[u'appeal', u'applicant_action'],
                 expired=[u'appeal', u'applicant_action'],
             )),
            (Action.TYPES.AFFIRMATION,
             Bunch(
                 scenario=[u'refusal', u'appeal', u'affirmation'],
                 allowed=[],
                 expired=[],
             )),
            (Action.TYPES.REVERSION,
             Bunch(
                 scenario=[u'refusal', u'appeal', u'reversion'],
                 allowed=[],
                 expired=[],
             )),
            (Action.TYPES.REMANDMENT,
             Bunch(
                 scenario=[u'refusal', u'appeal', u'remandment'],
                 allowed=[
                     u'extension', u'disclosure', u'refusal',
                     u'obligee_action', u'obligee_email_action'
                 ],
                 expired=[
                     u'appeal', u'extension', u'disclosure', u'refusal',
                     u'obligee_action', u'obligee_email_action',
                     u'applicant_action'
                 ],
             )),
            (Action.TYPES.ADVANCED_REQUEST,
             Bunch(
                 branch=1,
                 scenario=[u'advancement'],
                 allowed=[
                     u'confirmation', u'extension', u'advancement',
                     u'clarification_request', u'disclosure', u'refusal',
                     u'obligee_action', u'obligee_email_action'
                 ],
                 expired=[
                     u'appeal', u'confirmation', u'extension', u'advancement',
                     u'clarification_request', u'disclosure', u'refusal',
                     u'obligee_action', u'obligee_email_action',
                     u'applicant_action'
                 ],
             )),
            (Action.TYPES.EXPIRATION,
             Bunch(
                 scenario=[u'expiration'],
                 allowed=[u'appeal', u'applicant_action'],
                 expired=[u'appeal', u'applicant_action'],
             )),
            (Action.TYPES.APPEAL_EXPIRATION,
             Bunch(
                 scenario=[u'refusal', u'appeal', u'appeal_expiration'],
                 allowed=[],
                 expired=[],
             )),
        )
        # Make sure we are testing all defined action types
        tested_action_types = set(a for a, _ in tests)
        defined_action_types = Action.TYPES._inverse.keys()
        self.assertItemsEqual(tested_action_types, defined_action_types)

        can_add_properties = (
            u'request',
            u'clarification_response',
            u'appeal',
            u'confirmation',
            u'extension',
            u'advancement',
            u'clarification_request',
            u'disclosure',
            u'refusal',
            u'affirmation',
            u'reversion',
            u'remandment',
            u'applicant_action',
            u'applicant_email_action',
            u'obligee_action',
            u'obligee_email_action',
        )

        for action_type, test in tests:
            timewarp.jump(local_datetime_from_local(u'2010-07-05 10:33:00'))
            objs = self._create_inforequest_scenario(*test.scenario)
            branch = getattr(test, u'branch', 0)
            branch = [o for o in flatten(objs)
                      if isinstance(o, Branch)][branch]
            self.assertEqual(branch.last_action.type, action_type)

            # Check actions allowed when the last action deadline is not expired yet
            for can_add_property in can_add_properties:
                value = getattr(branch, u'can_add_%s' % can_add_property)
                expected = can_add_property in test.allowed
                self.assertEqual(
                    value, expected, u'can_add_%s is %s after %r' %
                    (can_add_property, value, test.scenario))

            # Check actions allowed when the last action deadline is expired
            timewarp.jump(local_datetime_from_local(u'2010-10-05 10:33:00'))
            branch = Branch.objects.get(pk=branch.pk)
            for can_add_property in can_add_properties:
                value = getattr(branch, u'can_add_%s' % can_add_property)
                expected = can_add_property in test.expired
                self.assertEqual(
                    value, expected, u'can_add_%s is %s after expired %r' %
                    (can_add_property, value, test.scenario))
Beispiel #7
0
 def test_list_with_circular_references_raises_error(self):
     a = [1, 2, 3]
     a[0] = a
     with self.assertRaisesMessage(RuntimeError,
                                   u'maximum recursion depth exceeded'):
         list(flatten(a))
Beispiel #8
0
 def test_list_with_multiple_references_to_the_same_list(self):
     a = [1, 2, 3]
     b = [a, a, a]
     result = flatten(b)
     self.assertEqual(list(result), [1, 2, 3, 1, 2, 3, 1, 2, 3])
Beispiel #9
0
 def test_empty_list(self):
     result = flatten([])
     self.assertEqual(list(result), [])
Beispiel #10
0
 def test_list_with_strings(self):
     result = flatten([u'one', [u'two', u'three']])
     self.assertEqual(list(result), ['one', 'two', 'three'])
Beispiel #11
0
 def test_list_with_circular_references_raises_error(self):
     a = [1, 2, 3]
     a[0] = a
     with self.assertRaisesMessage(RuntimeError, u'maximum recursion depth exceeded'):
         list(flatten(a))
Beispiel #12
0
 def test_list_with_multiple_references_to_the_same_list(self):
     a = [1, 2, 3]
     b = [a, a, a]
     result = flatten(b)
     self.assertEqual(list(result), [1, 2, 3, 1, 2, 3, 1, 2, 3])
Beispiel #13
0
 def test_empty_list(self):
     result = flatten([])
     self.assertEqual(list(result), [])
Beispiel #14
0
 def test_list_with_strings(self):
     result = flatten([u'one', [u'two', u'three']])
     self.assertEqual(list(result), ['one', 'two', 'three'])
Beispiel #15
0
 def test_list_with_tuples(self):
     result = flatten([1, 2, (3, 4, (), (5,), [[[[6]]]],)])
     self.assertEqual(list(result), [1, 2, 3, 4, 5, 6])
    def test_can_add_x_properties(self):
        tests = (
                (Action.TYPES.REQUEST, Bunch(
                    scenario=[],
                    allowed=[           u'confirmation', u'extension', u'advancement', u'clarification_request', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action'],
                    expired=[u'appeal', u'confirmation', u'extension', u'advancement', u'clarification_request', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action', u'applicant_action'],
                    )),
                (Action.TYPES.CLARIFICATION_RESPONSE, Bunch(
                    scenario=[u'clarification_request', u'clarification_response'],
                    allowed=[           u'extension', u'advancement', u'clarification_request', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action'],
                    expired=[u'appeal', u'extension', u'advancement', u'clarification_request', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action', u'applicant_action'],
                    )),
                (Action.TYPES.APPEAL, Bunch(
                    scenario=[u'expiration', u'appeal'],
                    allowed=[u'affirmation', u'reversion', u'remandment', u'obligee_action'],
                    expired=[u'affirmation', u'reversion', u'remandment', u'obligee_action'],
                    )),
                (Action.TYPES.CONFIRMATION, Bunch(
                    scenario=[u'confirmation'],
                    allowed=[           u'extension', u'advancement', u'clarification_request', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action'],
                    expired=[u'appeal', u'extension', u'advancement', u'clarification_request', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action', u'applicant_action'],
                    )),
                (Action.TYPES.EXTENSION, Bunch(
                    scenario=[u'extension'],
                    allowed=[           u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action'],
                    expired=[u'appeal', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action', u'applicant_action'],
                    )),
                (Action.TYPES.ADVANCEMENT, Bunch(
                    scenario=[u'advancement'],
                    allowed=[u'appeal', u'applicant_action'],
                    expired=[u'appeal', u'applicant_action'],
                    )),
                (Action.TYPES.CLARIFICATION_REQUEST, Bunch(
                    scenario=[u'clarification_request'],
                    allowed=[u'clarification_response', u'clarification_request', u'obligee_action', u'obligee_email_action', u'applicant_action', u'applicant_email_action'],
                    expired=[u'clarification_response', u'clarification_request', u'obligee_action', u'obligee_email_action', u'applicant_action', u'applicant_email_action'],
                    )),
                (Action.TYPES.DISCLOSURE, Bunch(
                    scenario=[(u'disclosure', dict(disclosure_level=Action.DISCLOSURE_LEVELS.NONE))],
                    allowed=[u'appeal', u'applicant_action'],
                    expired=[u'appeal', u'applicant_action'],
                    )),
                (Action.TYPES.DISCLOSURE, Bunch(
                    scenario=[(u'disclosure', dict(disclosure_level=Action.DISCLOSURE_LEVELS.PARTIAL))],
                    allowed=[u'appeal', u'applicant_action'],
                    expired=[u'appeal', u'applicant_action'],
                    )),
                (Action.TYPES.DISCLOSURE, Bunch(
                    scenario=[(u'disclosure', dict(disclosure_level=Action.DISCLOSURE_LEVELS.FULL))],
                    allowed=[],
                    expired=[],
                    )),
                (Action.TYPES.REFUSAL, Bunch(
                    scenario=[u'refusal'],
                    allowed=[u'appeal', u'applicant_action'],
                    expired=[u'appeal', u'applicant_action'],
                    )),
                (Action.TYPES.AFFIRMATION, Bunch(
                    scenario=[u'refusal', u'appeal', u'affirmation'],
                    allowed=[],
                    expired=[],
                    )),
                (Action.TYPES.REVERSION, Bunch(
                    scenario=[u'refusal', u'appeal', u'reversion'],
                    allowed=[],
                    expired=[],
                    )),
                (Action.TYPES.REMANDMENT, Bunch(
                    scenario=[u'refusal', u'appeal', u'remandment'],
                    allowed=[           u'extension', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action'],
                    expired=[u'appeal', u'extension', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action', u'applicant_action'],
                    )),
                (Action.TYPES.ADVANCED_REQUEST, Bunch(
                    branch=1,
                    scenario=[u'advancement'],
                    allowed=[           u'confirmation', u'extension', u'advancement', u'clarification_request', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action'],
                    expired=[u'appeal', u'confirmation', u'extension', u'advancement', u'clarification_request', u'disclosure', u'refusal', u'obligee_action', u'obligee_email_action', u'applicant_action'],
                    )),
                (Action.TYPES.EXPIRATION, Bunch(
                    scenario=[u'expiration'],
                    allowed=[u'appeal', u'applicant_action'],
                    expired=[u'appeal', u'applicant_action'],
                    )),
                (Action.TYPES.APPEAL_EXPIRATION, Bunch(
                    scenario=[u'refusal', u'appeal', u'appeal_expiration'],
                    allowed=[],
                    expired=[],
                    )),
                )
        # Make sure we are testing all defined action types
        tested_action_types = set(a for a, _ in tests)
        defined_action_types = Action.TYPES._inverse.keys()
        self.assertItemsEqual(tested_action_types, defined_action_types)

        can_add_properties = (
                u'request',
                u'clarification_response',
                u'appeal',
                u'confirmation',
                u'extension',
                u'advancement',
                u'clarification_request',
                u'disclosure',
                u'refusal',
                u'affirmation',
                u'reversion',
                u'remandment',
                u'applicant_action',
                u'applicant_email_action',
                u'obligee_action',
                u'obligee_email_action',
                )

        for action_type, test in tests:
            timewarp.jump(local_datetime_from_local(u'2010-07-05 10:33:00'))
            objs = self._create_inforequest_scenario(*test.scenario)
            branch = getattr(test, u'branch', 0)
            branch = [o for o in flatten(objs) if isinstance(o, Branch)][branch]
            self.assertEqual(branch.last_action.type, action_type)

            # Check actions allowed when the last action deadline is not expired yet
            for can_add_property in can_add_properties:
                value = getattr(branch, u'can_add_%s' % can_add_property)
                expected = can_add_property in test.allowed
                self.assertEqual(value, expected, u'can_add_%s is %s after %r' % (can_add_property, value, test.scenario))

            # Check actions allowed when the last action deadline is expired
            timewarp.jump(local_datetime_from_local(u'2010-10-05 10:33:00'))
            branch = Branch.objects.get(pk=branch.pk)
            for can_add_property in can_add_properties:
                value = getattr(branch, u'can_add_%s' % can_add_property)
                expected = can_add_property in test.expired
                self.assertEqual(value, expected, u'can_add_%s is %s after expired %r' % (can_add_property, value, test.scenario))