Ejemplo n.º 1
0
    def test_multiple_updates(self):
        episode = self.make_episode_case()
        voucher = self.make_voucher()

        res = self.make_request({'response': [{
            'eventType': 'Incentive',
            'id': episode.case_id,
            'status': 'Failure',
            'failureDescription': 'We do not sow',
            'eventID': '106',
            'paymentDate': "2014-11-22 13:23:44.657"
        }, {
            'eventType': 'Voucher',
            'id': voucher.case_id,
            'status': 'Success',
            'amount': 100,
            'paymentDate': "2014-11-22 13:23:44.657"
        }]})
        self.assertResponseStatus(res, 200)

        # check incentive update
        self.assertDictContainsSubset(
            {
                'tb_incentive_106_status': 'rejected',
                'tb_incentive_106_rejection_reason': 'We do not sow',
            },
            get_case(self.domain, episode.case_id).case_json,
        )
        # check voucher update
        self.assertDictContainsSubset(
            {'state': 'paid', 'amount_paid': '100.0'},
            get_case(self.domain, voucher.case_id).case_json,
        )
 def test_full_details(self):
     episode = self.make_episode_case()
     voucher = self.make_voucher()
     res = self.make_request({
         'response': [{
             'eventType': 'Incentive',
             'id': episode.case_id,
             'status': 'Success',
             'eventID': '106',
             'amount': 100,
             'paymentDate': "2014-11-22 13:23:44.657",
             'bankName': "Iron Bank",
         }, {
             'eventType': 'Voucher',
             'id': voucher.case_id,
             'status': 'Success',
             'amount': 100,
             'paymentDate': "2014-11-22 13:23:44.657",
             'comments': "Cool stuff!",
             'checkNumber': "12345",
         }]
     })
     self.assertResponseStatus(res, 200)
     self.assertEqual(
         {
             "weight": "15 stone",
             "test_confirming_diagnosis": "Old Nan's wisdom",
             "tb_incentive_106_amount": "100.0",
             "tb_incentive_106_bank_name": "Iron Bank",
             "tb_incentive_106_check_number": "",
             "tb_incentive_106_comments": "",
             "tb_incentive_106_payment_date": "2014-11-22T13:23:44.657000Z",
             "tb_incentive_106_payment_mode": "",
             "tb_incentive_106_status": "paid",
         },
         get_case(self.domain, episode.case_id).case_json)
     self.assertEqual(
         {
             "bank_name": "",
             "state": "paid",
             "comments": "Cool stuff!",
             "date_paid": "2014-11-22",
             "time_paid": "13:23:44.657000",
             "amount_initial": "105",
             "amount_paid": "100.0",
             "payment_mode": "",
             "check_number": "12345",
         },
         get_case(self.domain, voucher.case_id).case_json)
Ejemplo n.º 3
0
 def test_float_amount(self):
     voucher = self.make_voucher()
     res = self.make_request({'response': [{
         'eventType': 'Voucher',
         'id': voucher.case_id,
         'status': 'Success',
         'amount': '100.2',
         'paymentDate': "2014-11-22 13:23:44.657"
     }]})
     self.assertResponseStatus(res, 200)
     self.assertDictContainsSubset(
         {'state': 'paid', 'amount_paid': '100.2'},
         get_case(self.domain, voucher.case_id).case_json,
     )
Ejemplo n.º 4
0
 def test_update_voucher_failure(self):
     voucher = self.make_voucher()
     res = self.make_request({'response': [{
         'eventType': 'Voucher',
         'id': voucher.case_id,
         'status': 'Failure',
         'failureDescription': 'The Iron Bank will have its due',
         'amount': 0,
         'paymentDate': "2014-11-22 13:23:44.657"
     }]})
     self.assertResponseStatus(res, 200)
     self.assertDictContainsSubset(
         {'state': 'rejected', 'reason_rejected': 'The Iron Bank will have its due'},
         get_case(self.domain, voucher.case_id).case_json,
     )
Ejemplo n.º 5
0
 def test_update_voucher_success(self):
     voucher = self.make_voucher()
     res = self.make_request(
         update_voucher, {
             'voucher_id': voucher.case_id,
             'payment_status': 'success',
             'payment_amount': 100,
         })
     self.assertEqual(res.status_code, 200)
     self.assertDictContainsSubset(
         {
             'state': 'paid',
             'amount_fulfilled': '100'
         },
         get_case(self.domain, voucher.case_id).case_json,
     )
Ejemplo n.º 6
0
 def test_update_voucher_failure(self):
     voucher = self.make_voucher()
     res = self.make_request(
         update_voucher, {
             'voucher_id': voucher.case_id,
             'payment_status': 'failure',
             'failure_description': 'The Iron Bank will have its due',
             'payment_amount': 0,
         })
     self.assertEqual(res.status_code, 200)
     self.assertDictContainsSubset(
         {
             'state': 'rejected',
             'reason_rejected': 'The Iron Bank will have its due'
         },
         get_case(self.domain, voucher.case_id).case_json,
     )
Ejemplo n.º 7
0
 def test_update_incentive_failure(self):
     episode = self.make_episode_case()
     res = self.make_request({'response': [{
         'eventType': 'Incentive',
         'id': episode.case_id,
         'status': 'Failure',
         'failureDescription': 'We do not sow',
         'eventID': '106',
         'paymentDate': "2014-11-22 13:23:44.657"
     }]})
     self.assertResponseStatus(res, 200)
     self.assertDictContainsSubset(
         {
             'tb_incentive_106_status': 'rejected',
             'tb_incentive_106_rejection_reason': 'We do not sow',
         },
         get_case(self.domain, episode.case_id).case_json,
     )
Ejemplo n.º 8
0
 def test_update_incentive_success(self):
     episode = self.make_episode_case()
     res = self.make_request({'response': [{
         'eventType': 'Incentive',
         'id': episode.case_id,
         'status': 'Success',
         'eventID': '106',
         'amount': 100,
         'paymentDate': "2014-11-22 13:23:44.657"
     }]})
     self.assertResponseStatus(res, 200)
     self.assertDictContainsSubset(
         {
             'tb_incentive_106_status': 'paid',
             'tb_incentive_106_amount': '100.0',
         },
         get_case(self.domain, episode.case_id).case_json,
     )
Ejemplo n.º 9
0
 def test_update_incentive_failure(self):
     episode = self.make_episode_case()
     res = self.make_request(
         update_incentive, {
             'beneficiary_id': episode.case_id,
             'episode_id': episode.case_id,
             'payment_status': 'failure',
             'failure_description': 'We do not sow',
             'bets_parent_event_id': '106',
         })
     self.assertEqual(res.status_code, 200)
     self.assertDictContainsSubset(
         {
             'tb_incentive_106_status': 'rejected',
             'tb_incentive_106_rejection_reason': 'We do not sow',
         },
         get_case(self.domain, episode.case_id).case_json,
     )
Ejemplo n.º 10
0
 def test_update_incentive_success(self):
     episode = self.make_episode_case()
     res = self.make_request(
         update_incentive, {
             'beneficiary_id': episode.case_id,
             'episode_id': episode.case_id,
             'payment_status': 'success',
             'bets_parent_event_id': '106',
             'payment_amount': 100,
         })
     self.assertEqual(res.status_code, 200)
     self.assertDictContainsSubset(
         {
             'tb_incentive_106_status': 'paid',
             'tb_incentive_106_amount': '100',
         },
         get_case(self.domain, episode.case_id).case_json,
     )