Commit 11b1af30 by Fábián János

during migration, Operation::asnyc was replaced by _async

parent 75fd8d40
...@@ -137,7 +137,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -137,7 +137,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
inst.set_level(self.u2, 'owner') inst.set_level(self.u2, 'owner')
interface_count = inst.interface_set.count() interface_count = inst.interface_set.count()
with patch.object(AddInterfaceOperation, 'async') as _async: with patch.object(AddInterfaceOperation, '_async') as _async:
_async.side_effect = inst.add_interface.call _async.side_effect = inst.add_interface.call
with patch.object(VmAddInterfaceView, 'get_form_kwargs', with patch.object(VmAddInterfaceView, 'get_form_kwargs',
autospec=True) as get_form_kwargs: autospec=True) as get_form_kwargs:
...@@ -156,7 +156,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -156,7 +156,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
vlan = Vlan.objects.get(id=1) vlan = Vlan.objects.get(id=1)
vlan.set_level(self.u1, 'user') vlan.set_level(self.u1, 'user')
interface_count = inst.interface_set.count() interface_count = inst.interface_set.count()
with patch.object(AddInterfaceOperation, 'async') as mock_method: with patch.object(AddInterfaceOperation, '_async') as mock_method:
mock_method.side_effect = inst.add_interface mock_method.side_effect = inst.add_interface
response = c.post("/dashboard/vm/1/op/add_interface/", response = c.post("/dashboard/vm/1/op/add_interface/",
{'vlan': 1}) {'vlan': 1})
...@@ -174,7 +174,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -174,7 +174,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
inst.save() inst.save()
iface_count = inst.interface_set.count() iface_count = inst.interface_set.count()
with patch.object(RemoveInterfaceOperation, 'async') as mock_method: with patch.object(RemoveInterfaceOperation, '_async') as mock_method:
mock_method.side_effect = inst.remove_interface mock_method.side_effect = inst.remove_interface
response = c.post("/dashboard/vm/1/op/remove_interface/", response = c.post("/dashboard/vm/1/op/remove_interface/",
{'interface': 1}) {'interface': 1})
...@@ -190,7 +190,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -190,7 +190,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
inst.add_interface(vlan=Vlan.objects.get(pk=1), user=self.us) inst.add_interface(vlan=Vlan.objects.get(pk=1), user=self.us)
iface_count = inst.interface_set.count() iface_count = inst.interface_set.count()
with patch.object(RemoveInterfaceOperation, 'async') as mock_method: with patch.object(RemoveInterfaceOperation, '_async') as mock_method:
mock_method.side_effect = inst.remove_interface mock_method.side_effect = inst.remove_interface
response = c.post("/dashboard/vm/1/op/remove_interface/", response = c.post("/dashboard/vm/1/op/remove_interface/",
{'interface': 1}) {'interface': 1})
...@@ -222,7 +222,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -222,7 +222,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
self.login(c, 'user1') self.login(c, 'user1')
InstanceTemplate.objects.get(id=1).set_level(self.u1, 'user') InstanceTemplate.objects.get(id=1).set_level(self.u1, 'user')
Vlan.objects.get(id=1).set_level(self.u1, 'user') Vlan.objects.get(id=1).set_level(self.u1, 'user')
with patch.object(DeployOperation, 'async') as _async: with patch.object(DeployOperation, '_async') as _async:
response = c.post('/dashboard/vm/create/', response = c.post('/dashboard/vm/create/',
{'template': 1, {'template': 1,
'system': "bubi", 'system': "bubi",
...@@ -234,7 +234,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -234,7 +234,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
def test_use_permitted_template_superuser(self): def test_use_permitted_template_superuser(self):
c = Client() c = Client()
self.login(c, 'superuser') self.login(c, 'superuser')
with patch.object(DeployOperation, 'async') as _async: with patch.object(DeployOperation, '_async') as _async:
response = c.post('/dashboard/vm/create/', response = c.post('/dashboard/vm/create/',
{'template': 1, {'template': 1,
'system': "bubi", 'system': "bubi",
...@@ -312,7 +312,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -312,7 +312,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
inst.add_interface(user=self.u2, vlan=vlan) inst.add_interface(user=self.u2, vlan=vlan)
host = Host.objects.get( host = Host.objects.get(
interface__in=inst.interface_set.all()) interface__in=inst.interface_set.all())
with patch.object(AddPortOperation, 'async') as mock_method: with patch.object(AddPortOperation, '_async') as mock_method:
mock_method.side_effect = inst.add_port mock_method.side_effect = inst.add_port
response = c.post("/dashboard/vm/1/op/add_port/", { response = c.post("/dashboard/vm/1/op/add_port/", {
'proto': 'tcp', 'host': host.pk, 'port': '1337'}) 'proto': 'tcp', 'host': host.pk, 'port': '1337'})
...@@ -329,7 +329,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -329,7 +329,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
interface__in=inst.interface_set.all()) interface__in=inst.interface_set.all())
self.u2.user_permissions.add(Permission.objects.get( self.u2.user_permissions.add(Permission.objects.get(
name='Can configure port forwards.')) name='Can configure port forwards.'))
with patch.object(AddPortOperation, 'async') as mock_method: with patch.object(AddPortOperation, '_async') as mock_method:
mock_method.side_effect = inst.add_port mock_method.side_effect = inst.add_port
response = c.post("/dashboard/vm/1/op/add_port/", { response = c.post("/dashboard/vm/1/op/add_port/", {
'proto': 'tcp', 'host': host.pk, 'port': '1337'}) 'proto': 'tcp', 'host': host.pk, 'port': '1337'})
...@@ -343,7 +343,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -343,7 +343,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
inst.set_level(self.u2, 'owner') inst.set_level(self.u2, 'owner')
self.u2.user_permissions.add(Permission.objects.get( self.u2.user_permissions.add(Permission.objects.get(
name='Can configure port forwards.')) name='Can configure port forwards.'))
with patch.object(AddPortOperation, 'async') as mock_method: with patch.object(AddPortOperation, '_async') as mock_method:
mock_method.side_effect = inst.add_port mock_method.side_effect = inst.add_port
response = c.post("/dashboard/vm/1/op/add_port/", { response = c.post("/dashboard/vm/1/op/add_port/", {
'proto': 'tcp', 'host': '9999', 'port': '1337'}) 'proto': 'tcp', 'host': '9999', 'port': '1337'})
...@@ -360,10 +360,11 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -360,10 +360,11 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
inst.add_interface(user=self.u2, vlan=vlan) inst.add_interface(user=self.u2, vlan=vlan)
host = Host.objects.get( host = Host.objects.get(
interface__in=inst.interface_set.all()) interface__in=inst.interface_set.all())
#import pdb; pdb.set_trace()
self.u2.user_permissions.add(Permission.objects.get( self.u2.user_permissions.add(Permission.objects.get(
name='Can configure port forwards.')) name='Can configure port forwards.'))
port_count = len(host.list_ports()) port_count = len(host.list_ports())
with patch.object(AddPortOperation, 'async') as mock_method: with patch.object(AddPortOperation, '_async') as mock_method:
mock_method.side_effect = inst.add_port mock_method.side_effect = inst.add_port
response = c.post("/dashboard/vm/1/op/add_port/", { response = c.post("/dashboard/vm/1/op/add_port/", {
'proto': 'tcp', 'host': host.pk, 'port': '1337'}) 'proto': 'tcp', 'host': host.pk, 'port': '1337'})
...@@ -437,7 +438,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -437,7 +438,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
def test_unpermitted_set_name(self): def test_unpermitted_set_name(self):
c = Client() c = Client()
self.login(c, "user2") self.login(c, "user2")
with patch.object(RenameOperation, 'async') as mock_method: with patch.object(RenameOperation, '_async') as mock_method:
inst = Instance.objects.get(pk=1) inst = Instance.objects.get(pk=1)
mock_method.side_effect = inst.rename mock_method.side_effect = inst.rename
inst.set_level(self.u2, 'user') inst.set_level(self.u2, 'user')
...@@ -451,7 +452,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -451,7 +452,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
def test_permitted_set_name(self): def test_permitted_set_name(self):
c = Client() c = Client()
self.login(c, "user2") self.login(c, "user2")
with patch.object(RenameOperation, 'async') as mock_method: with patch.object(RenameOperation, '_async') as mock_method:
inst = Instance.objects.get(pk=1) inst = Instance.objects.get(pk=1)
mock_method.side_effect = inst.rename mock_method.side_effect = inst.rename
inst.set_level(self.u2, 'owner') inst.set_level(self.u2, 'owner')
...@@ -465,7 +466,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -465,7 +466,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
c = Client() c = Client()
self.login(c, "user2") self.login(c, "user2")
inst = Instance.objects.get(pk=1) inst = Instance.objects.get(pk=1)
with patch.object(RenameOperation, 'async') as mock_method: with patch.object(RenameOperation, '_async') as mock_method:
inst.set_level(self.u2, 'owner') inst.set_level(self.u2, 'owner')
mock_method.side_effect = inst.rename mock_method.side_effect = inst.rename
response = c.post("/dashboard/vm/1/op/rename/", response = c.post("/dashboard/vm/1/op/rename/",
...@@ -478,7 +479,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -478,7 +479,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
def test_permitted_wake_up_wrong_state(self): def test_permitted_wake_up_wrong_state(self):
c = Client() c = Client()
self.login(c, "user2") self.login(c, "user2")
with patch.object(WakeUpOperation, 'async') as mock_method, \ with patch.object(WakeUpOperation, '_async') as mock_method, \
patch.object(Instance.WrongStateError, 'send_message') as wro: patch.object(Instance.WrongStateError, 'send_message') as wro:
inst = Instance.objects.get(pk=1) inst = Instance.objects.get(pk=1)
mock_method.side_effect = inst.wake_up mock_method.side_effect = inst.wake_up
...@@ -494,7 +495,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -494,7 +495,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
c = Client() c = Client()
self.login(c, "user2") self.login(c, "user2")
with patch.object(Instance, 'select_node', return_value=None), \ with patch.object(Instance, 'select_node', return_value=None), \
patch.object(WakeUpOperation, 'async') as new_wake_up, \ patch.object(WakeUpOperation, '_async') as new_wake_up, \
patch.object(Instance.WrongStateError, 'send_message') as wro: patch.object(Instance.WrongStateError, 'send_message') as wro:
inst = Instance.objects.get(pk=1) inst = Instance.objects.get(pk=1)
new_wake_up.side_effect = inst.wake_up new_wake_up.side_effect = inst.wake_up
...@@ -531,7 +532,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -531,7 +532,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
self.login(c, "superuser") self.login(c, "superuser")
instance_count = Instance.objects.all().count() instance_count = Instance.objects.all().count()
with patch.object(DeployOperation, 'async') as _async: with patch.object(DeployOperation, '_async') as _async:
response = c.post("/dashboard/vm/create/", { response = c.post("/dashboard/vm/create/", {
'name': 'vm', 'name': 'vm',
'amount': 1, 'amount': 1,
...@@ -627,6 +628,7 @@ class NodeDetailTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -627,6 +628,7 @@ class NodeDetailTest(LoginMixin, MockCeleryMixin, TestCase):
def test_200_superuser_node_page(self): def test_200_superuser_node_page(self):
c = Client() c = Client()
#import pdb; pdb.set_trace()
self.login(c, 'superuser') self.login(c, 'superuser')
response = c.get('/dashboard/node/1/') response = c.get('/dashboard/node/1/')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
...@@ -828,6 +830,7 @@ class GroupCreateTest(LoginMixin, MockCeleryMixin, TestCase): ...@@ -828,6 +830,7 @@ class GroupCreateTest(LoginMixin, MockCeleryMixin, TestCase):
c = Client() c = Client()
groupnum = Group.objects.count() groupnum = Group.objects.count()
self.login(c, 'user1') self.login(c, 'user1')
#import pdb; pdb.set_trace()
response = c.post('/dashboard/group/create/', {'name': 'newgroup'}) response = c.post('/dashboard/group/create/', {'name': 'newgroup'})
self.assertEqual(response.status_code, 403) self.assertEqual(response.status_code, 403)
self.assertEqual(Group.objects.count(), groupnum) self.assertEqual(Group.objects.count(), groupnum)
...@@ -1811,6 +1814,7 @@ class LeaseDetailTest(LoginMixin, TestCase): ...@@ -1811,6 +1814,7 @@ class LeaseDetailTest(LoginMixin, TestCase):
c = Client() c = Client()
self.login(c, 'superuser') self.login(c, 'superuser')
leases = Lease.objects.count() leases = Lease.objects.count()
#import pdb; pdb.set_trace()
response = c.post("/dashboard/lease/delete/1/") response = c.post("/dashboard/lease/delete/1/")
self.assertEqual(response.status_code, 400) self.assertEqual(response.status_code, 400)
self.assertEqual(leases, Lease.objects.count()) self.assertEqual(leases, Lease.objects.count())
......
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 sign in to comment