Commit 154f1d6c authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Fixes for Tests

- Round tax comparation, else we hit floating point impression.
- Free trial user is defined by ERP5 Login reference and not Person Reference.
parent 32c8d21a
...@@ -229,7 +229,7 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin): ...@@ -229,7 +229,7 @@ class TestSlapOSTrialScenario(DefaultScenarioMixin):
self.assertEqual(line.getQuantity(), quantity) self.assertEqual(line.getQuantity(), quantity)
self.assertEqual(round(line.getPrice(), 2), 20.83) self.assertEqual(round(line.getPrice(), 2), 20.83)
if line.getResource() == "service_module/slapos_tax": if line.getResource() == "service_module/slapos_tax":
self.assertEqual(line.getQuantity(), 20.833333333333333*quantity) self.assertEqual(round(line.getQuantity(), 2), round(20.833333333333333*quantity, 2))
self.assertEqual(round(line.getTotalPrice(), 2), round(4.166666666666667*quantity, 2)) self.assertEqual(round(line.getTotalPrice(), 2), round(4.166666666666667*quantity, 2))
self.assertEqual(round(invoice.getTotalPrice(), 2), 25.0*quantity) self.assertEqual(round(invoice.getTotalPrice(), 2), 25.0*quantity)
......
...@@ -46,10 +46,10 @@ ...@@ -46,10 +46,10 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W:254, 4: Unused variable \'email\' (unused-variable)</string> <string>W:255, 4: Unused variable \'email\' (unused-variable)</string>
<string>W:255, 4: Unused variable \'name\' (unused-variable)</string> <string>W:256, 4: Unused variable \'name\' (unused-variable)</string>
<string>W:266, 4: Unused variable \'name\' (unused-variable)</string> <string>W:267, 4: Unused variable \'name\' (unused-variable)</string>
<string>W:275, 4: Unused variable \'name\' (unused-variable)</string> <string>W:276, 4: Unused variable \'name\' (unused-variable)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -31,15 +31,20 @@ class TestTrialSkinsMixin(SlapOSTestCaseMixinWithAbort): ...@@ -31,15 +31,20 @@ class TestTrialSkinsMixin(SlapOSTestCaseMixinWithAbort):
def makeFreeTrialUser(self): def makeFreeTrialUser(self):
person = self.portal.portal_catalog.getResultValue( login = self.portal.portal_catalog.getResultValue(
portal_type="Person", portal_type="ERP5 Login",
reference="free_trial_user") reference="free_trial_user",
if person: validation_state="validated")
return person
if login:
return login.getParentValue()
person = self.makePerson() person = self.makePerson()
person.setReference("free_trial_user") person.newContent(
portal_type="ERP5 Login",
reference="free_trial_user").validate()
self.tic() self.tic()
return person return person
def newTrialCondition(self): def newTrialCondition(self):
...@@ -235,12 +240,12 @@ class TestSlapOSTrialCondition_requestFreeTrialProxy(TestTrialSkinsMixin): ...@@ -235,12 +240,12 @@ class TestSlapOSTrialCondition_requestFreeTrialProxy(TestTrialSkinsMixin):
class TestTrialRequest_processRequest(TestTrialSkinsMixin): class TestTrialRequest_processRequest(TestTrialSkinsMixin):
def test_free_trial_use_dont_exist(self): def test_free_trial_use_dont_exist(self):
person_list = self.portal.portal_catalog( login_list = self.portal.portal_catalog(
portal_type="Person", portal_type="ERP5 Login",
reference="free_trial_user") reference="free_trial_user")
for person in person_list: for login in login_list:
person.setReference("XXXX") login.setReference("%s_test_free_trial_use_dont_exist" % self.generateNewId())
self.tic() self.tic()
try: try:
...@@ -248,8 +253,8 @@ class TestTrialRequest_processRequest(TestTrialSkinsMixin): ...@@ -248,8 +253,8 @@ class TestTrialRequest_processRequest(TestTrialSkinsMixin):
self.assertEqual(None, trial_request.TrialRequest_processRequest()) self.assertEqual(None, trial_request.TrialRequest_processRequest())
self.assertEqual(None, trial_request.getAggregate()) self.assertEqual(None, trial_request.getAggregate())
finally: finally:
for person in person_list: for login in login_list:
person.setReference("free_trial_user") login.setReference("free_trial_user")
self.tic() self.tic()
def test_already_validated(self): def test_already_validated(self):
...@@ -299,20 +304,20 @@ class TestTrialRequest_processRequest(TestTrialSkinsMixin): ...@@ -299,20 +304,20 @@ class TestTrialRequest_processRequest(TestTrialSkinsMixin):
class TestTrialRequest_processNotify(TestTrialSkinsMixin): class TestTrialRequest_processNotify(TestTrialSkinsMixin):
def test_free_trial_use_dont_exist(self): def test_free_trial_use_dont_exist(self):
person_list = self.portal.portal_catalog( login_list = self.portal.portal_catalog(
portal_type="Person", portal_type="ERP5 Login",
reference="free_trial_user") reference="free_trial_user")
for person in person_list: for login in login_list:
person.setReference("XXXX") login.setReference("%s_test_free_trial_use_dont_exist" % self.generateNewId())
self.tic() self.tic()
try: try:
trial_request = self.newTrialRequest() trial_request = self.newTrialRequest()
self.assertEqual("Free Trial Person not Found", trial_request.TrialRequest_processNotify()) self.assertEqual("Free Trial Person not Found", trial_request.TrialRequest_processNotify())
finally: finally:
for person in person_list: for login in login_list:
person.setReference("free_trial_user") login.setReference("free_trial_user")
self.tic() self.tic()
def test_already_validated(self): def test_already_validated(self):
...@@ -464,12 +469,12 @@ class TestTrialRequest_sendMailMessage(TestTrialSkinsMixin): ...@@ -464,12 +469,12 @@ class TestTrialRequest_sendMailMessage(TestTrialSkinsMixin):
class TestTrialRequest_processDestroy(TestTrialSkinsMixin): class TestTrialRequest_processDestroy(TestTrialSkinsMixin):
def test_free_trial_use_dont_exist(self): def test_free_trial_use_dont_exist(self):
person_list = self.portal.portal_catalog( login_list = self.portal.portal_catalog(
portal_type="Person", portal_type="ERP5 Login",
reference="free_trial_user") reference="free_trial_user")
for person in person_list: for login in login_list:
person.setReference("XXXX") login.setReference("%s_test_free_trial_use_dont_exist" % self.generateNewId())
self.tic() self.tic()
try: try:
...@@ -479,8 +484,8 @@ class TestTrialRequest_processDestroy(TestTrialSkinsMixin): ...@@ -479,8 +484,8 @@ class TestTrialRequest_processDestroy(TestTrialSkinsMixin):
self.assertEqual(None, trial_request.TrialRequest_processDestroy()) self.assertEqual(None, trial_request.TrialRequest_processDestroy())
finally: finally:
for person in person_list: for login in login_list:
person.setReference("free_trial_user") login.setReference("free_trial_user")
self.tic() self.tic()
def test_stop_date_didnt_arrive(self): def test_stop_date_didnt_arrive(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment