Exemple #1
0
    def test_add_counterparty_personal(self):
        cpt_id = '6aa7d45f-ea8a-42cf-b69a-c53848d1ffd1'
        responses.add(responses.POST,
                      'https://sandbox-b2b.revolut.com/api/1.0/counterparty',
                      json=self._read('counterparty-{}.json'.format(cpt_id)),
                      status=200)
        responses.add(responses.GET,
                      'https://sandbox-b2b.revolut.com/api/1.0/counterparties',
                      json=self._read('counterparties.json'),
                      status=200)
        responses.add(
            responses.GET,
            'https://sandbox-b2b.revolut.com/api/1.0/counterparty/{}'.format(
                cpt_id),
            json=self._read('counterparty-{}.json'.format(cpt_id)),
            status=200)
        responses.add(responses.POST,
                      'https://sandbox-b2b.revolut.com/api/1.0/counterparty',
                      json={'message': 'This counterparty already exists'},
                      status=422)
        responses.add(responses.POST,
                      'https://sandbox-b2b.revolut.com/api/1.0/counterparty',
                      json={'message': 'This counterparty already exists'},
                      status=422)

        cli = Client(self.key)
        cpt = Counterparty(client=cli,
                           profile_type='personal',
                           name='Alice Tester',
                           phone='+4412345678901')
        self.assertEqual(str(cpt),
                         'Id: NO ID personal Alice Tester +4412345678901')
        cpt.save()
        self.assertEqual(repr(cpt), '<Counterparty {}>'.format(cpt_id))
        self.assertEqual(
            str(cpt),
            'Id: 6aa7d45f-ea8a-42cf-b69a-c53848d1ffd1 personal Alice Tester +4412345678901'
        )
        self.assertIsInstance(cpt.created_at, datetime)
        self.assertIsInstance(cpt.updated_at, datetime)
        for accid, acc in cpt.accounts.items():
            self.assertIsInstance(acc, CounterpartyAccount)
            self.assertEqual(accid, acc.id)
        self.assertRaises(exceptions.CounterpartyAlreadyExists, cpt.save)
        self.assertIs(cpt, cpt.refresh())
        cpt = Counterparty(client=cli,
                           profile_type='personal',
                           name='Bob Tester',
                           phone='+4412345678901')
        self.assertRaises(exceptions.CounterpartyAlreadyExists, cpt.save)
Exemple #2
0
    def test_add_counterparty_business(self):
        cpt_id = 'a630f150-4a22-42d7-82f2-74d9c5da7c35'
        responses.add(responses.POST,
                      'https://sandbox-b2b.revolut.com/api/1.0/counterparty',
                      json=self._read('counterparty-{}.json'.format(cpt_id)),
                      status=200)
        responses.add(responses.GET,
                      'https://sandbox-b2b.revolut.com/api/1.0/counterparties',
                      json=self._read('counterparties.json'),
                      status=200)
        responses.add(
            responses.GET,
            'https://sandbox-b2b.revolut.com/api/1.0/counterparty/{}'.format(
                cpt_id),
            json=self._read('counterparty-{}.json'.format(cpt_id)),
            status=200)
        responses.add(responses.POST,
                      'https://sandbox-b2b.revolut.com/api/1.0/counterparty',
                      json={'message': 'This counterparty already exists'},
                      status=422)
        responses.add(responses.POST,
                      'https://sandbox-b2b.revolut.com/api/1.0/counterparty',
                      json={'message': 'This counterparty already exists'},
                      status=422)

        cli = Client(self.key)
        cpt = Counterparty(client=cli,
                           profile_type='business',
                           email='*****@*****.**')
        self.assertEqual(str(cpt), 'Id: NO ID business  [email protected]')
        cpt.save()
        self.assertEqual(repr(cpt), '<Counterparty {}>'.format(cpt_id))
        self.assertEqual(
            str(cpt),
            'Id: a630f150-4a22-42d7-82f2-74d9c5da7c35 business The sandbox corp [email protected]'
        )
        self.assertIsInstance(cpt.created_at, datetime)
        self.assertIsInstance(cpt.updated_at, datetime)
        for accid, acc in cpt.accounts.items():
            self.assertIsInstance(acc, CounterpartyAccount)
            self.assertEqual(accid, acc.id)
        self.assertRaises(exceptions.CounterpartyAlreadyExists, cpt.save)
        self.assertIs(cpt, cpt.refresh())
        cpt = Counterparty(client=cli,
                           profile_type='business',
                           email='*****@*****.**')
        self.assertRaises(exceptions.CounterpartyAlreadyExists, cpt.save)
 def test_add_counterparty_invalid(self):
     tssn = TemporarySession(self.access_token)
     cli = Client(tssn)
     cpt = Counterparty(client=cli, profile_type='whatever')
     self.assertRaises(ValueError, cpt.save)
Exemple #4
0
 def test_add_counterparty_invalid(self):
     cli = Client(self.key)
     cpt = Counterparty(client=cli, profile_type='whatever')
     self.assertRaises(ValueError, cpt.save)