Commit 676faad9 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: fix Computer Network creation test

parent f6d1cc42
...@@ -827,6 +827,8 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin): ...@@ -827,6 +827,8 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self.project = self.addProject() self.project = self.addProject()
person_user = self.makePerson(self.project) person_user = self.makePerson(self.project)
# Only admin can create computer network
self.addProjectProductionManagerAssignment(person_user, self.project)
self.tic() self.tic()
# Login as new user # Login as new user
...@@ -837,14 +839,21 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin): ...@@ -837,14 +839,21 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin):
def beforeTearDown(self): def beforeTearDown(self):
pass pass
def test_Person_requestNetwork_title_is_mandatoty(self): def test_Person_requestNetwork_title_is_mandatory(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue() person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertRaises(TypeError, person.requestNetwork) self.assertRaises(TypeError, person.requestNetwork,
project_reference=self.project.getReference())
def test_Person_requestNetwork_project_is_mandatory(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertRaises(TypeError, person.requestNetwork,
network_title=self.generateNewNetworkTitle())
def test_Person_requestNetwork(self): def test_Person_requestNetwork(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue() person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
network_title = self.generateNewNetworkTitle() network_title = self.generateNewNetworkTitle()
person.requestNetwork(network_title=network_title) person.requestNetwork(network_title=network_title,
project_reference=self.project.getReference())
self.tic() self.tic()
self.login() self.login()
...@@ -852,10 +861,10 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin): ...@@ -852,10 +861,10 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin):
network_relative_url = person.REQUEST.get('computer_network_relative_url') network_relative_url = person.REQUEST.get('computer_network_relative_url')
self.assertNotEqual(None, network_relative_url) self.assertNotEqual(None, network_relative_url)
network = person.restrictedTraverse(network_relative_url) network = person.restrictedTraverse(network_relative_url)
self.assertEqual(network.getSourceAdministration(), self.assertEqual(network.getFollowUp(),
person.getRelativeUrl()) self.project.getRelativeUrl())
self.assertEqual(network.getTitle(), network_title) self.assertEqual(network.getTitle(), network_title)
self.assertEqual(network.getValidationState(), "validated") self.assertEqual(network.getValidationState(), "validated")
self.assertIn("NET-", network.getReference()) self.assertIn("NET-", network.getReference())
...@@ -864,7 +873,8 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin): ...@@ -864,7 +873,8 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin):
def test_Person_requestNetwork_duplicated(self): def test_Person_requestNetwork_duplicated(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue() person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
network_title = self.generateNewNetworkTitle() network_title = self.generateNewNetworkTitle()
person.requestNetwork(network_title=network_title) person.requestNetwork(network_title=network_title,
project_reference=self.project.getReference())
self.tic() self.tic()
self.login() self.login()
...@@ -874,8 +884,8 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin): ...@@ -874,8 +884,8 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin):
self.assertNotEqual(None, network_relative_url) self.assertNotEqual(None, network_relative_url)
network = person.restrictedTraverse(network_relative_url) network = person.restrictedTraverse(network_relative_url)
self.assertEqual(network.getSourceAdministration(), self.assertEqual(network.getFollowUp(),
person.getRelativeUrl()) self.project.getRelativeUrl())
self.assertEqual(network.getTitle(), network_title) self.assertEqual(network.getTitle(), network_title)
self.assertEqual(network.getValidationState(), "validated") self.assertEqual(network.getValidationState(), "validated")
self.assertIn("NET-", network.getReference()) self.assertIn("NET-", network.getReference())
...@@ -886,12 +896,14 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin): ...@@ -886,12 +896,14 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin):
self.login(person.getUserId()) self.login(person.getUserId())
self.assertRaises(NotImplementedError, person.requestNetwork, self.assertRaises(NotImplementedError, person.requestNetwork,
network_title=network_title) network_title=network_title,
project_reference=self.project.getReference())
def test_Person_requestNetwork_request_again(self): def test_Person_requestNetwork_request_again(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue() person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
network_title = self.generateNewNetworkTitle() network_title = self.generateNewNetworkTitle()
person.requestNetwork(network_title=network_title) person.requestNetwork(network_title=network_title,
project_reference=self.project.getReference())
# check what is returned via request # check what is returned via request
network_relative_url = person.REQUEST.get('computer_network_relative_url') network_relative_url = person.REQUEST.get('computer_network_relative_url')
...@@ -904,7 +916,8 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin): ...@@ -904,7 +916,8 @@ class TestSlapOSCorePersonRequestNetwork(SlapOSTestCaseMixin):
person.REQUEST.set('computer_network_relative_url', None) person.REQUEST.set('computer_network_relative_url', None)
self.login(person.getUserId()) self.login(person.getUserId())
person.requestNetwork(network_title=network_title) person.requestNetwork(network_title=network_title,
project_reference=self.project.getReference())
# check what is returned via request # check what is returned via request
same_network_relative_url = person.REQUEST.get('computer_network_relative_url') same_network_relative_url = person.REQUEST.get('computer_network_relative_url')
......
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