Commit a6030b16 authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: subscription scenario needs project now

parent 9bae8434
...@@ -75,8 +75,10 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -75,8 +75,10 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
slapos_pre_payment_template.\ slapos_pre_payment_template.\
updateLocalRolesOnSecurityGroups() updateLocalRolesOnSecurityGroups()
self.subscription_project = self.createProject()
# One user to create compute_nodes to deploy the subscription # One user to create compute_nodes to deploy the subscription
self.createAdminUser() self.createAdminUser(self.subscription_project)
self.cleanUpNotificationMessage() self.cleanUpNotificationMessage()
self.portal.portal_catalog.searchAndActivate( self.portal.portal_catalog.searchAndActivate(
portal_type='Active Process', portal_type='Active Process',
...@@ -161,6 +163,14 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -161,6 +163,14 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
if str(notification_message.getVersion("")) == "999": if str(notification_message.getVersion("")) == "999":
notification_message.invalidate() notification_message.invalidate()
def createProject(self):
project = self.portal.project_module.newContent(
portal_type='Project',
title='project-%s' % self.generateNewId()
)
project.validate()
return project
def createNotificationMessage(self, reference, def createNotificationMessage(self, reference,
content_type='text/html', language="en", text_content='${name} ${login_name} ${login_password}'): content_type='text/html', language="en", text_content='${name} ${login_name} ${login_password}'):
...@@ -177,7 +187,7 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -177,7 +187,7 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
notification_message.validate() notification_message.validate()
return notification_message return notification_message
def createAdminUser(self): def createAdminUser(self, project):
""" Create a Admin user, to manage compute_nodes and instances eventually """ """ Create a Admin user, to manage compute_nodes and instances eventually """
admin_user_login = self.portal.portal_catalog.getResultValue( admin_user_login = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login", portal_type="ERP5 Login",
...@@ -193,15 +203,18 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -193,15 +203,18 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
portal_type="ERP5 Login", portal_type="ERP5 Login",
reference="admin_user").validate() reference="admin_user").validate()
admin_user.newContent(
portal_type='Assignment',
destination_project_value=project,
function='computer/manager'
).open()
admin_user.edit( admin_user.edit(
first_name="Admin User", first_name="Admin User",
reference="Admin_user", reference="Admin_user",
default_email_text="do_not_reply_to_admin@example.org", default_email_text="do_not_reply_to_admin@example.org",
) )
for assignment in admin_user.contentValues(portal_type="Assignment"):
assignment.open()
admin_user.validate() admin_user.validate()
self.admin_user = admin_user self.admin_user = admin_user
else: else:
...@@ -290,7 +303,8 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -290,7 +303,8 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
source_payment=self.expected_source_section + "/bank_account", source_payment=self.expected_source_section + "/bank_account",
price_currency="currency_module/EUR", price_currency="currency_module/EUR",
payment_mode='payzen', payment_mode='payzen',
specialise="sale_trade_condition_module/slapos_subscription_trade_condition" specialise="sale_trade_condition_module/slapos_subscription_trade_condition",
#follow_up_value=self.subscription_project
) )
# XXX TODO clarify the with / without tax # XXX TODO clarify the with / without tax
sale_trade_condition.newContent( sale_trade_condition.newContent(
...@@ -318,7 +332,8 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -318,7 +332,8 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
sla_xml='<?xml version="1.0" encoding="utf-8"?>\n<instance>\n</instance>', sla_xml='<?xml version="1.0" encoding="utf-8"?>\n<instance>\n</instance>',
text_content='<?xml version="1.0" encoding="utf-8"?>\n<instance>\n</instance>', text_content='<?xml version="1.0" encoding="utf-8"?>\n<instance>\n</instance>',
user_input={}, user_input={},
specialise_value=sale_trade_condition specialise_value=sale_trade_condition,
follow_up_value=self.subscription_project
) )
self.subscription_condition.validate() self.subscription_condition.validate()
self.tic() self.tic()
...@@ -1235,12 +1250,13 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -1235,12 +1250,13 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
# Create a Public Server for admin user, and allow # Create a Public Server for admin user, and allow
subscription_server_title = 'Trial Public Server for Admin User %s' % self.new_id subscription_server_title = 'Trial Public Server for Admin User %s' % self.new_id
subscription_server_id = self.requestComputeNode(subscription_server_title) subscription_server_id = self.requestComputeNode(subscription_server_title,
self.subscription_project.getReference())
subscription_server = self.portal.portal_catalog.getResultValue( subscription_server = self.portal.portal_catalog.getResultValue(
portal_type='Compute Node', reference=subscription_server_id) portal_type='Compute Node', reference=subscription_server_id)
self.setAccessToMemcached(subscription_server) self.setAccessToMemcached(subscription_server)
self.assertNotEqual(None, subscription_server) self.assertNotEqual(None, subscription_server)
self.setServerOpenSubscription(subscription_server) self.assertEqual('open', subscription_server.getCapacityScope())
# and install some software on them # and install some software on them
subscription_server_software = self.subscription_condition.getUrlString() subscription_server_software = self.subscription_condition.getUrlString()
...@@ -1893,6 +1909,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -1893,6 +1909,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
class TestSlapOSSubscriptionScenario(TestSlapOSSubscriptionScenarioMixin): class TestSlapOSSubscriptionScenario(TestSlapOSSubscriptionScenarioMixin):
def test_new_subscription_scenario_with_single_vm(self):
self._test_subscription_scenario(amount=1)
def test_subscription_scenario_with_single_vm(self): def test_subscription_scenario_with_single_vm(self):
self._test_subscription_scenario(amount=1) self._test_subscription_scenario(amount=1)
......
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