From d67187fb09b4062ff7540b2da00122a735448388 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Thu, 4 May 2023 13:31:18 +0000
Subject: [PATCH] slapos_cloud:

* test: use Person_addVirtualMaster to create project
* test: login as user to request the instance
---
 .../test.erp5.SlapOSTestCaseDefaultScenarioMixin.py      | 1 +
 .../portal_components/test.erp5.SlapOSTestCaseMixin.py   | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py b/master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
index 09c7a7990..2ae2495b6 100644
--- a/master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
+++ b/master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
@@ -383,6 +383,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
     self.stepCallSlaposAllocateInstanceAlarm()
     self.tic()
 
+    self.login(person_user_id)
     self.personRequestInstance(
       software_release=software_release,
       software_type=software_type,
diff --git a/master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py b/master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
index 72d1a1de6..a3f236f84 100644
--- a/master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
+++ b/master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
@@ -176,7 +176,6 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
   def addProject(self, organisation=None, currency=None, person=None, is_accountable=False):
     assert organisation is None
     assert currency is None
-    assert not is_accountable
     if person is None:
       project = self.portal.project_module.newContent(
         portal_type='Project',
@@ -186,13 +185,19 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
       return project
 
     # Action to submit project subscription
+    return person.Person_addVirtualMaster(
+      'project-%s' % self.generateNewId(),
+      is_accountable,
+      is_accountable,
+      batch=1).getRelativeUrl()
+    """
     service = self.portal.restrictedTraverse('service_module/slapos_virtual_master_subscription')
     subscription_request = service.Resource_createSubscriptionRequest(person, None, None)
     self.tic()
 
     self.logout()
 
-    return subscription_request.getAggregate()
+    return subscription_request.getAggregate()"""
 
   def _addERP5Login(self, document, **kw):
     if document.getPortalType() == "Person":
-- 
2.30.9