def test_build_request_no_projectid(self): # Exception should be thrown if project id is not given data = {'orderid': '123', 'accepturl': 'http://local.test/accept', 'cancelurl': 'http://local.test/cancel', 'callbackurl': 'http://local.test/callback', 'sign_password': '******' } with self.assertRaisesRegexp(webtopay.WebToPayException, 'sign_password or projectid is not ' 'provided'): webtopay.build_request(data)
def test_build_request(self): rq = webtopay.build_request({'projectid': '123', 'sign_password': '******', 'orderid': 123, 'accepturl': 'http://local.test/', 'cancelurl': 'http://local.test/', 'callbackurl': 'http://local.test/', 'amount': 100, 'some-other-parameter': 'abc'}) self.assertEqual(rq['sign'], '7461dff3e05d67d6e19e4c1021ce6163') self.assertRegexpMatches(rq['data'], r'b3JkZXJpZD0xMjMmc29tZS.*kZsb2NhbC50ZXN0JTJG')