Example #1
0
    def test_saving(self):
        advisor = Fixture1.advisor1()
        advisor.regional_data = {
            'tax_file_number': '1234',
        }
        advisor.clean()
        advisor.save()

        advisor = self.o(advisor)
        self.assertDictEqual(advisor.regional_data, {
            'tax_file_number': '1234',
        })

        advisor.regional_data = ''
        with self.assertRaises(ValueError) as e:
            advisor.clean()
        self.assertEqual(str(e.exception), "{'regional_data': "
                         "\"Must be 'dict' type.\"}")

        advisor.regional_data = {}
        advisor.clean()
        advisor.save()

        advisor = self.o(advisor)
        self.assertEqual(advisor.regional_data, {})
Example #2
0
 def test_assign_invalid_field_name(self):
     advisor = Fixture1.advisor1()
     advisor.regional_data = {
         'us_citizen': True,
     }
     with self.assertRaises(ValueError) as e:
         advisor.clean()
     self.assertEqual(
         str(e.exception), "{'regional_data': 'Got 1 unknown fields "
         "(us_citizen).'}")
Example #3
0
 def test_assign_invalid_field_value(self):
     advisor = Fixture1.advisor1()
     advisor.regional_data = {
         'provide_tfn': 'yes',
     }
     with self.assertRaises(ValidationError) as e:
         advisor.clean()
     self.assertEqual(str(e.exception),
                      "{'regional_data': ['Field provide_tfn has bool type, "
                      "got str.']}")
Example #4
0
    def test_event_memo(self):
        '''
        Tests event memos and assigning multiple events to one activity log item.
        :return:
        '''
        # Add a public settings event with a memo
        se = Fixture1.settings_event1()
        EventMemo.objects.create(event=se,
                                 comment='A memo for e1',
                                 staff=False)
        # Add a staff settings event with a memo
        se2 = Fixture1.settings_event2()
        EventMemo.objects.create(event=se2,
                                 comment='A memo for e2',
                                 staff=True)
        # Add a transaction event without a memo
        Fixture1.transaction_event1()
        # We also need to activate the activity logging for the desired event types.
        # We add selected and update to the same une to test that too
        al = ActivityLog.objects.create(name="Settings Funk",
                                        format_str='Settings messed with')
        ActivityLogEvent.objects.create(
            id=Event.APPROVE_SELECTED_SETTINGS.value, activity_log=al)
        ActivityLogEvent.objects.create(
            id=Event.UPDATE_SELECTED_SETTINGS.value, activity_log=al)
        ActivityLogEvent.get(Event.GOAL_DEPOSIT_EXECUTED)

        url = '/api/v1/goals/{}/activity'.format(Fixture1.goal1().id)
        # Log in as a client and make sure I see the public settings event, and the transaction, not the staff entry.
        self.client.force_authenticate(user=Fixture1.client1().user)
        response = self.client.get(url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 3)
        self.assertEqual(response.data[2]['memos'], ['A memo for e1'])
        self.assertFalse('memos' in response.data[0])
        self.assertFalse('memos' in response.data[1])

        # Log in as the advisor and make sure I see all three events.
        self.client.force_authenticate(user=Fixture1.advisor1().user)
        response = self.client.get(url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 3)
        self.assertEqual(response.data[2]['memos'], ['A memo for e1'])
        self.assertEqual(response.data[1]['memos'], ['A memo for e2'])
        self.assertFalse('memos' in response.data[0])
Example #5
0
 def test_average_group_balance(self):
     advisor = Fixture1.advisor1()
     self.assertEqual(advisor.average_group_balance, 0)
Example #6
0
 def test_default_value(self):
     advisor = Fixture1.advisor1()
     self.assertEqual(advisor.regional_data, {})