def test_days_active_for_user(self):
     actual_days_active = 153
     response = self.client.get(
         build_url('days_active', params={'user_id': self.user_id}),
         content_type='application/json')
     self.assertEqual(actual_days_active,
                      response.json()['days_active'], 'Expected days active not matches')
示例#2
0
 def test_all_policies(self):
     """Test all policies are returned"""
     response = self.client.get(build_url('policies'),
                                content_type='application/json')
     actual_count = models.Policy.objects.count()
     self.assertEqual(actual_count, len(response.json()),
                      'Expected length not matches')
 def test_new_users_premium_for_underwriter(self):
     actual_results = [{'date': '2020-03', 'premium': 197}, {'date': '2020-04', 'premium': 38}]
     response = self.client.get(
         build_url('new_users_premium', params={'underwriter': self.underwriter}),
         content_type='application/json')
     self.assertListEqual(actual_results,
                          response.json(),
                          'Expected new users premium count not matches')
 def test_lapsed_users_for_month(self):
     actual_users = 3
     response = self.client.get(
         build_url('lapsed_users', params={'month': self.month}),
         content_type='application/json')
     self.assertEqual(actual_users,
                      response.json()['lapsed_users_count'],
                      'Expected lapsed users count not matches')
 def test_new_users_for_date(self):
     actual_users = 7
     response = self.client.get(
         build_url('new_users', params={'date': self.date}),
         content_type='application/json')
     self.assertEqual(actual_users,
                      response.json()['new_users_count'],
                      'Expected new users count not matches')
 def test_days_active_for_user_with_optional_params(self):
     month = 5
     underwriter = 'blue'
     actual_days_active = 31
     response = self.client.get(
         build_url('days_active', params={'user_id': self.user_id, 'month': month, 'underwriter': underwriter}),
         content_type='application/json')
     self.assertEqual(actual_days_active,
                      response.json()['days_active'], 'Expected days active not matches')
 def test_new_users_for_date_with_optional_params(self):
     month = 5
     underwriter = 'blue'
     actual_days_active = 4
     response = self.client.get(
         build_url('new_users', params={'date': self.date, 'month': month, 'underwriter': underwriter}),
         content_type='application/json')
     self.assertEqual(actual_days_active,
                      response.json()['new_users_count'],
                      'Expected new users count not matches with optional params')
示例#8
0
 def test_all_policies_count_by_user(self):
     """Test actual policies count is returned for the the given user
     """
     user_id = 'user_000000BcyxC7NwL6OnB9boEXLUNBw'
     response = self.client.get(build_url('policy_count',
                                          params={'user_id': user_id}),
                                content_type='application/json')
     actual_count = models.Policy.objects.filter(user_id=user_id).count()
     self.assertEqual(actual_count,
                      response.json()['policy_count'],
                      'Expected policies count not matches')
示例#9
0
    def test_all_policies_with_optional_params(self):
        """Test filtered policies are returned with optional params
        """
        test_month = 3
        test_underwriter = 'blue'

        response = self.client.get(build_url('policies',
                                             params={
                                                 'month': test_month,
                                                 'underwriter':
                                                 test_underwriter
                                             }),
                                   content_type='application/json')
        actual_count = models.Policy.objects.filter(
            policy_start_date__month=test_month,
            underwriter=test_underwriter).count()

        self.assertEqual(actual_count, len(response.json()),
                         'Expected length not matches')