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):
self.assertEqual(line.getQuantity(), quantity)
self.assertEqual(round(line.getPrice(), 2), 20.83)
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(invoice.getTotalPrice(), 2), 25.0*quantity)
......
......@@ -46,10 +46,10 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:254, 4: Unused variable \'email\' (unused-variable)</string>
<string>W:255, 4: Unused variable \'name\' (unused-variable)</string>
<string>W:266, 4: Unused variable \'name\' (unused-variable)</string>
<string>W:275, 4: Unused variable \'name\' (unused-variable)</string>
<string>W:255, 4: Unused variable \'email\' (unused-variable)</string>
<string>W:256, 4: Unused variable \'name\' (unused-variable)</string>
<string>W:267, 4: Unused variable \'name\' (unused-variable)</string>
<string>W:276, 4: Unused variable \'name\' (unused-variable)</string>
</tuple>
</value>
</item>
......
......@@ -31,15 +31,20 @@ class TestTrialSkinsMixin(SlapOSTestCaseMixinWithAbort):
def makeFreeTrialUser(self):
person = self.portal.portal_catalog.getResultValue(
portal_type="Person",
reference="free_trial_user")
if person:
return person
login = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference="free_trial_user",
validation_state="validated")
if login:
return login.getParentValue()
person = self.makePerson()
person.setReference("free_trial_user")
person.newContent(
portal_type="ERP5 Login",
reference="free_trial_user").validate()
self.tic()
return person
def newTrialCondition(self):
......@@ -235,12 +240,12 @@ class TestSlapOSTrialCondition_requestFreeTrialProxy(TestTrialSkinsMixin):
class TestTrialRequest_processRequest(TestTrialSkinsMixin):
def test_free_trial_use_dont_exist(self):
person_list = self.portal.portal_catalog(
portal_type="Person",
login_list = self.portal.portal_catalog(
portal_type="ERP5 Login",
reference="free_trial_user")
for person in person_list:
person.setReference("XXXX")
for login in login_list:
login.setReference("%s_test_free_trial_use_dont_exist" % self.generateNewId())
self.tic()
try:
......@@ -248,8 +253,8 @@ class TestTrialRequest_processRequest(TestTrialSkinsMixin):
self.assertEqual(None, trial_request.TrialRequest_processRequest())
self.assertEqual(None, trial_request.getAggregate())
finally:
for person in person_list:
person.setReference("free_trial_user")
for login in login_list:
login.setReference("free_trial_user")
self.tic()
def test_already_validated(self):
......@@ -299,20 +304,20 @@ class TestTrialRequest_processRequest(TestTrialSkinsMixin):
class TestTrialRequest_processNotify(TestTrialSkinsMixin):
def test_free_trial_use_dont_exist(self):
person_list = self.portal.portal_catalog(
portal_type="Person",
login_list = self.portal.portal_catalog(
portal_type="ERP5 Login",
reference="free_trial_user")
for person in person_list:
person.setReference("XXXX")
for login in login_list:
login.setReference("%s_test_free_trial_use_dont_exist" % self.generateNewId())
self.tic()
try:
trial_request = self.newTrialRequest()
self.assertEqual("Free Trial Person not Found", trial_request.TrialRequest_processNotify())
finally:
for person in person_list:
person.setReference("free_trial_user")
for login in login_list:
login.setReference("free_trial_user")
self.tic()
def test_already_validated(self):
......@@ -464,12 +469,12 @@ class TestTrialRequest_sendMailMessage(TestTrialSkinsMixin):
class TestTrialRequest_processDestroy(TestTrialSkinsMixin):
def test_free_trial_use_dont_exist(self):
person_list = self.portal.portal_catalog(
portal_type="Person",
login_list = self.portal.portal_catalog(
portal_type="ERP5 Login",
reference="free_trial_user")
for person in person_list:
person.setReference("XXXX")
for login in login_list:
login.setReference("%s_test_free_trial_use_dont_exist" % self.generateNewId())
self.tic()
try:
......@@ -479,8 +484,8 @@ class TestTrialRequest_processDestroy(TestTrialSkinsMixin):
self.assertEqual(None, trial_request.TrialRequest_processDestroy())
finally:
for person in person_list:
person.setReference("free_trial_user")
for login in login_list:
login.setReference("free_trial_user")
self.tic()
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