Skip to content

Commit

Permalink
Fixed order id in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vokimon committed Dec 9, 2021
1 parent 06249c7 commit 3e2d646
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions sermepa/sermepa_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import unicode_literals

import unittest
import random

import base64
import json
Expand All @@ -21,11 +22,6 @@
except ImportError:
config = None

def randhex(nbytes):
import random
return "{1:0{0}x}".format(nbytes*2,random.getrandbits(nbytes*8))


class Generator_Test(unittest.TestCase):

# back2back data taken from PHP example
Expand Down Expand Up @@ -57,6 +53,9 @@ class Generator_Test(unittest.TestCase):
signature = 'Ejse86yr96Xbr1mf6UvQLoTPwwTyFiLXM+2uT09i9nY='
signatureversion = 'HMAC_SHA256_V1'

def new_order_id(self):
nbytes=6
return "{1:0{0}x}".format(nbytes*2,random.getrandbits(nbytes*8))

def test_encodePayload(self):
self.assertEqual(
Expand Down Expand Up @@ -179,7 +178,7 @@ def test_sendingPost_testing(self):
Ds_Merchant_MerchantData = "COBRAMENT QUOTA SOCI",
Ds_Merchant_MerchantName = "SOM ENERGIA, SCCL",
Ds_Merchant_MerchantURL = "https://testing.somenergia.coop:5001/pagament/notificacio",
Ds_Merchant_Order = randhex(nbytes=6), # "20167db2f375",
Ds_Merchant_Order = self.new_order_id(),
Ds_Merchant_ProductDescription = "Alta de soci SOMENERGIA",
Ds_Merchant_SumTotal = "10000",
Ds_Merchant_Terminal = "1",
Expand Down Expand Up @@ -210,7 +209,7 @@ def test_sendingPost_testing_invalidSignature(self):
Ds_Merchant_MerchantData = "COBRAMENT QUOTA SOCI",
Ds_Merchant_MerchantName = "SOM ENERGIA, SCCL",
Ds_Merchant_MerchantURL = "https://testing.somenergia.coop:5001/pagament/notificacio",
Ds_Merchant_Order = randhex(nbytes=6), # "20167db2f375",
Ds_Merchant_Order = self.new_order_id(),
Ds_Merchant_ProductDescription = "Alta de soci SOMENERGIA",
Ds_Merchant_SumTotal = "10000",
Ds_Merchant_Terminal = "1",
Expand Down Expand Up @@ -241,7 +240,7 @@ def test_sendingPost_testingFails_invalidUser(self):
Ds_Merchant_MerchantData = "COBRAMENT QUOTA SOCI",
Ds_Merchant_MerchantName = "SOM ENERGIA, SCCL",
Ds_Merchant_MerchantURL = "https://testing.somenergia.coop:5001/pagament/notificacio",
Ds_Merchant_Order = randhex(nbytes=6), # "20167db2f375",
Ds_Merchant_Order = self.new_order_id(),
Ds_Merchant_ProductDescription = "Alta de soci SOMENERGIA",
Ds_Merchant_SumTotal = "10000",
Ds_Merchant_Terminal = "1",
Expand Down

0 comments on commit 3e2d646

Please sign in to comment.