Initial attempt to get unit tests working
This commit is contained in:
parent
72cdc8488d
commit
34d6957d30
@ -17,6 +17,7 @@ import mock
|
||||
|
||||
from mox import IsA # noqa
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.project.shares import test_data
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
@ -37,12 +38,12 @@ class SharesTests(test.BaseAdminViewTests):
|
||||
security_services = [test_data.sec_service]
|
||||
|
||||
api.keystone.tenant_list = mock.Mock(return_value=([], None))
|
||||
api.manila.share_list = mock.Mock(return_value=shares)
|
||||
api.manila.share_snapshot_list = mock.Mock(return_value=snaps)
|
||||
api.manila.share_network_list = mock.Mock(return_value=share_networks)
|
||||
api.manila.security_service_list = mock.Mock(
|
||||
api_manila.share_list = mock.Mock(return_value=shares)
|
||||
api_manila.share_snapshot_list = mock.Mock(return_value=snaps)
|
||||
api_manila.share_network_list = mock.Mock(return_value=share_networks)
|
||||
api_manila.security_service_list = mock.Mock(
|
||||
return_value=security_services)
|
||||
api.manila.share_network_get = mock.Mock()
|
||||
api_manila.share_network_get = mock.Mock()
|
||||
api.neutron.network_list = mock.Mock(return_value=[])
|
||||
api.neutron.subnet_list = mock.Mock(return_value=[])
|
||||
quotas.tenant_limit_usages = mock.Mock(
|
||||
@ -60,14 +61,14 @@ class SharesTests(test.BaseAdminViewTests):
|
||||
'shares__delete__%s' % share.id}
|
||||
|
||||
api.keystone.tenant_list = mock.Mock(return_value=([], None))
|
||||
api.manila.share_delete = mock.Mock()
|
||||
api.manila.share_get = mock.Mock(
|
||||
api_manila.share_delete = mock.Mock()
|
||||
api_manila.share_get = mock.Mock(
|
||||
return_value=test_data.share)
|
||||
api.manila.share_list = mock.Mock(
|
||||
api_manila.share_list = mock.Mock(
|
||||
return_value=[test_data.share])
|
||||
url = reverse('horizon:admin:shares:index')
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.share_delete.assert_called_with(
|
||||
api_manila.share_delete.assert_called_with(
|
||||
mock.ANY, test_data.share.id)
|
||||
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
@ -81,15 +82,15 @@ class SharesTests(test.BaseAdminViewTests):
|
||||
api.keystone.tenant_list = mock.Mock(return_value=([], None))
|
||||
api.neutron.network_list = mock.Mock(return_value=[])
|
||||
api.neutron.subnet_list = mock.Mock(return_value=[])
|
||||
api.manila.share_network_delete = mock.Mock()
|
||||
api.manila.share_network_get = mock.Mock(
|
||||
api_manila.share_network_delete = mock.Mock()
|
||||
api_manila.share_network_get = mock.Mock(
|
||||
return_value=[test_data.inactive_share_network])
|
||||
api.manila.share_network_list = mock.Mock(
|
||||
api_manila.share_network_list = mock.Mock(
|
||||
return_value=[test_data.active_share_network,
|
||||
test_data.inactive_share_network])
|
||||
url = reverse('horizon:admin:shares:index')
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.share_network_delete.assert_called_with(
|
||||
api_manila.share_network_delete.assert_called_with(
|
||||
mock.ANY, test_data.inactive_share_network.id)
|
||||
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
@ -102,16 +103,16 @@ class SharesTests(test.BaseAdminViewTests):
|
||||
'snapshots__delete__%s' % snapshot.id}
|
||||
|
||||
api.keystone.tenant_list = mock.Mock(return_value=([], None))
|
||||
api.manila.share_snapshot_delete = mock.Mock()
|
||||
api.manila.share_snapshot_get = mock.Mock(
|
||||
api_manila.share_snapshot_delete = mock.Mock()
|
||||
api_manila.share_snapshot_get = mock.Mock(
|
||||
return_value=snapshot)
|
||||
api.manila.share_snapshot_list = mock.Mock(
|
||||
api_manila.share_snapshot_list = mock.Mock(
|
||||
return_value=[snapshot])
|
||||
api.manila.share_list = mock.Mock(
|
||||
api_manila.share_list = mock.Mock(
|
||||
return_value=[share])
|
||||
url = reverse('horizon:admin:shares:index')
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.share_snapshot_delete.assert_called_with(
|
||||
api_manila.share_snapshot_delete.assert_called_with(
|
||||
mock.ANY, test_data.snapshot.id)
|
||||
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
@ -123,11 +124,11 @@ class SharesTests(test.BaseAdminViewTests):
|
||||
'security_services__delete__%s' % security_service.id}
|
||||
|
||||
api.keystone.tenant_list = mock.Mock(return_value=([], None))
|
||||
api.manila.security_service_delete = mock.Mock()
|
||||
api.manila.security_service_list = mock.Mock(
|
||||
api_manila.security_service_delete = mock.Mock()
|
||||
api_manila.security_service_list = mock.Mock(
|
||||
return_value=[test_data.sec_service])
|
||||
url = reverse('horizon:admin:shares:index')
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.security_service_delete.assert_called_with(
|
||||
api_manila.security_service_delete.assert_called_with(
|
||||
mock.ANY, test_data.sec_service.id)
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
@ -22,10 +22,12 @@ from django.core.urlresolvers import reverse
|
||||
from manilaclient import exceptions as manila_client_exc
|
||||
import mock
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.project.shares import test_data
|
||||
|
||||
from mox import IsA # noqa
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.dashboards.project.shares import test_data
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
|
||||
@ -47,12 +49,12 @@ class SecurityServicesViewTests(test.TestCase):
|
||||
'server': 'testserver'
|
||||
}
|
||||
|
||||
api.manila.security_service_create = mock.Mock()
|
||||
api_manila.security_service_create = mock.Mock()
|
||||
url = reverse('horizon:project:shares:create_security_service')
|
||||
res = self.client.post(url, formData)
|
||||
del formData['method']
|
||||
del formData['confirm_password']
|
||||
api.manila.security_service_create.assert_called_with(
|
||||
api_manila.security_service_create.assert_called_with(
|
||||
mock.ANY, **formData)
|
||||
self.assertRedirectsNoFollow(res, SHARE_INDEX_URL)
|
||||
|
||||
@ -62,18 +64,18 @@ class SecurityServicesViewTests(test.TestCase):
|
||||
formData = {'action':
|
||||
'security_services__delete__%s' % security_service.id}
|
||||
|
||||
api.manila.security_service_delete = mock.Mock()
|
||||
api.manila.security_service_list = mock.Mock(
|
||||
api_manila.security_service_delete = mock.Mock()
|
||||
api_manila.security_service_list = mock.Mock(
|
||||
return_value=[test_data.sec_service])
|
||||
url = reverse('horizon:project:shares:index')
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.security_service_delete.assert_called_with(
|
||||
api_manila.security_service_delete.assert_called_with(
|
||||
mock.ANY, test_data.sec_service.id)
|
||||
self.assertRedirectsNoFollow(res, SHARE_INDEX_URL)
|
||||
|
||||
def test_detail_view(self):
|
||||
sec_service = test_data.sec_service
|
||||
api.manila.security_service_get = mock.Mock(return_value=sec_service)
|
||||
api_manila.security_service_get = mock.Mock(return_value=sec_service)
|
||||
|
||||
url = reverse('horizon:project:shares:security_service_detail',
|
||||
args=[sec_service.id])
|
||||
@ -97,7 +99,7 @@ class SecurityServicesViewTests(test.TestCase):
|
||||
def raise_exc(*args, **kwargs):
|
||||
raise manila_client_exc.NotFound(500)
|
||||
|
||||
api.manila.security_service_get = mock.Mock(
|
||||
api_manila.security_service_get = mock.Mock(
|
||||
side_effect=raise_exc)
|
||||
|
||||
url = reverse('horizon:project:shares:security_service_detail',
|
||||
@ -109,8 +111,8 @@ class SecurityServicesViewTests(test.TestCase):
|
||||
def test_update_security_service(self):
|
||||
sec_service = test_data.sec_service
|
||||
|
||||
api.manila.security_service_get = mock.Mock(return_value=sec_service)
|
||||
api.manila.security_service_update = mock.Mock()
|
||||
api_manila.security_service_get = mock.Mock(return_value=sec_service)
|
||||
api_manila.security_service_update = mock.Mock()
|
||||
|
||||
formData = {'method': 'UpdateForm',
|
||||
'name': sec_service.name,
|
||||
|
@ -17,9 +17,10 @@ import mock
|
||||
|
||||
from neutronclient.client import exceptions
|
||||
|
||||
from manila_ui import api
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.project.shares import test_data
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
|
||||
@ -37,13 +38,13 @@ class ShareNetworksViewTests(test.TestCase):
|
||||
}
|
||||
for net in self.networks.list():
|
||||
formData['subnet-choices-%s' % net.id] = net.subnets[0].id
|
||||
api.manila.share_network_create = mock.Mock()
|
||||
api_manila.share_network_create = mock.Mock()
|
||||
api.neutron.network_list = mock.Mock(return_value=self.networks.list())
|
||||
api.neutron.subnet_list = mock.Mock(return_value=self.subnets.list())
|
||||
api.manila.share_network_create = mock.Mock()
|
||||
api_manila.share_network_create = mock.Mock()
|
||||
url = reverse('horizon:project:shares:create_share_network')
|
||||
self.client.post(url, formData)
|
||||
api.manila.share_network_create.assert_called_with(
|
||||
api_manila.share_network_create.assert_called_with(
|
||||
mock.ANY, name=formData['name'], neutron_net_id=neutron_net_id,
|
||||
neutron_subnet_id=formData['subnet-choices-%s' % neutron_net_id],
|
||||
description=formData['description'])
|
||||
@ -54,15 +55,15 @@ class ShareNetworksViewTests(test.TestCase):
|
||||
formData = {'action':
|
||||
'share_networks__delete__%s' % share_network.id}
|
||||
|
||||
api.manila.share_network_delete = mock.Mock()
|
||||
api.manila.share_network_get = mock.Mock(
|
||||
api_manila.share_network_delete = mock.Mock()
|
||||
api_manila.share_network_get = mock.Mock(
|
||||
return_value=[test_data.inactive_share_network])
|
||||
api.manila.share_network_list = mock.Mock(
|
||||
api_manila.share_network_list = mock.Mock(
|
||||
return_value=[test_data.active_share_network,
|
||||
test_data.inactive_share_network])
|
||||
url = reverse('horizon:project:shares:index')
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.share_network_delete.assert_called_with(
|
||||
api_manila.share_network_delete.assert_called_with(
|
||||
mock.ANY, test_data.inactive_share_network.id)
|
||||
|
||||
self.assertRedirectsNoFollow(res, SHARE_INDEX_URL)
|
||||
@ -70,8 +71,8 @@ class ShareNetworksViewTests(test.TestCase):
|
||||
def test_detail_view(self):
|
||||
share_net = test_data.active_share_network
|
||||
sec_service = test_data.sec_service
|
||||
api.manila.share_network_get = mock.Mock(return_value=share_net)
|
||||
api.manila.share_network_security_service_list = mock.Mock(
|
||||
api_manila.share_network_get = mock.Mock(return_value=share_net)
|
||||
api_manila.share_network_security_service_list = mock.Mock(
|
||||
return_value=[sec_service])
|
||||
network = self.networks.first()
|
||||
subnet = self.subnets.first()
|
||||
@ -97,8 +98,8 @@ class ShareNetworksViewTests(test.TestCase):
|
||||
def test_detail_view_network_not_found(self):
|
||||
share_net = test_data.active_share_network
|
||||
sec_service = test_data.sec_service
|
||||
api.manila.share_network_get = mock.Mock(return_value=share_net)
|
||||
api.manila.share_network_security_service_list = mock.Mock(
|
||||
api_manila.share_network_get = mock.Mock(return_value=share_net)
|
||||
api_manila.share_network_security_service_list = mock.Mock(
|
||||
return_value=[sec_service])
|
||||
|
||||
def raise_neutron_exc(*args, **kwargs):
|
||||
@ -129,10 +130,10 @@ class ShareNetworksViewTests(test.TestCase):
|
||||
def test_update_share_network(self):
|
||||
share_net = test_data.inactive_share_network
|
||||
|
||||
api.manila.share_network_get = mock.Mock(return_value=share_net)
|
||||
api.manila.share_network_update = mock.Mock()
|
||||
api.manila.share_network_security_service_remove = mock.Mock()
|
||||
api.manila.security_service_list = mock.Mock(
|
||||
api_manila.share_network_get = mock.Mock(return_value=share_net)
|
||||
api_manila.share_network_update = mock.Mock()
|
||||
api_manila.share_network_security_service_remove = mock.Mock()
|
||||
api_manila.security_service_list = mock.Mock(
|
||||
return_value=[test_data.sec_service])
|
||||
|
||||
formData = {'method': 'UpdateForm',
|
||||
|
@ -15,7 +15,7 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
import mock
|
||||
|
||||
from manila_ui import api
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.project.shares import test_data
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
@ -36,12 +36,12 @@ class ShareViewTests(test.TestCase):
|
||||
'type': 'NFS'
|
||||
}
|
||||
|
||||
api.manila.share_create = mock.Mock()
|
||||
api.manila.share_snapshot_list = mock.Mock(return_value=[])
|
||||
api.manila.share_network_list = mock.Mock(return_value=share_nets)
|
||||
api_manila.share_create = mock.Mock()
|
||||
api_manila.share_snapshot_list = mock.Mock(return_value=[])
|
||||
api_manila.share_network_list = mock.Mock(return_value=share_nets)
|
||||
url = reverse('horizon:project:shares:create')
|
||||
self.client.post(url, formData)
|
||||
api.manila.share_create.assert_called_with(
|
||||
api_manila.share_create.assert_called_with(
|
||||
mock.ANY, formData['size'], formData['name'],
|
||||
formData['description'], formData['type'], snapshot_id=None,
|
||||
share_network_id=share_net.id, metadata={})
|
||||
@ -60,15 +60,15 @@ class ShareViewTests(test.TestCase):
|
||||
'snapshot': snapshot.id
|
||||
}
|
||||
|
||||
api.manila.share_create = mock.Mock()
|
||||
api.manila.share_snapshot_list = mock.Mock(
|
||||
api_manila.share_create = mock.Mock()
|
||||
api_manila.share_snapshot_list = mock.Mock(
|
||||
return_value=[snapshot])
|
||||
api.manila.share_snapshot_get = mock.Mock(
|
||||
api_manila.share_snapshot_get = mock.Mock(
|
||||
return_value=snapshot)
|
||||
api.manila.share_network_list = mock.Mock(return_value=share_nets)
|
||||
api_manila.share_network_list = mock.Mock(return_value=share_nets)
|
||||
url = reverse('horizon:project:shares:create')
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.share_create.assert_called_with(
|
||||
api_manila.share_create.assert_called_with(
|
||||
mock.ANY, formData['size'], formData['name'],
|
||||
formData['description'], formData['type'],
|
||||
snapshot_id=snapshot.id,
|
||||
@ -87,15 +87,15 @@ class ShareViewTests(test.TestCase):
|
||||
'type': 'NFS'
|
||||
}
|
||||
|
||||
api.manila.share_create = mock.Mock()
|
||||
api.manila.share_snapshot_list = mock.Mock(return_value=[])
|
||||
api.manila.share_snapshot_get = mock.Mock(
|
||||
api_manila.share_create = mock.Mock()
|
||||
api_manila.share_snapshot_list = mock.Mock(return_value=[])
|
||||
api_manila.share_snapshot_get = mock.Mock(
|
||||
return_value=snapshot)
|
||||
api.manila.share_network_list = mock.Mock(return_value=share_nets)
|
||||
api_manila.share_network_list = mock.Mock(return_value=share_nets)
|
||||
url = reverse('horizon:project:shares:create')
|
||||
url = url + '?snapshot_id=%s' % snapshot.id
|
||||
self.client.post(url, formData)
|
||||
api.manila.share_create.assert_called_with(
|
||||
api_manila.share_create.assert_called_with(
|
||||
mock.ANY, formData['size'], formData['name'],
|
||||
formData['description'], formData['type'], snapshot_id=None,
|
||||
share_network_id=share_net.id, metadata={})
|
||||
@ -106,14 +106,14 @@ class ShareViewTests(test.TestCase):
|
||||
formData = {'action':
|
||||
'shares__delete__%s' % share.id}
|
||||
|
||||
api.manila.share_delete = mock.Mock()
|
||||
api.manila.share_get = mock.Mock(
|
||||
api_manila.share_delete = mock.Mock()
|
||||
api_manila.share_get = mock.Mock(
|
||||
return_value=test_data.share)
|
||||
api.manila.share_list = mock.Mock(
|
||||
api_manila.share_list = mock.Mock(
|
||||
return_value=[test_data.share])
|
||||
url = reverse('horizon:project:shares:index')
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.share_delete.assert_called_with(
|
||||
api_manila.share_delete.assert_called_with(
|
||||
mock.ANY, test_data.share.id)
|
||||
|
||||
self.assertRedirectsNoFollow(res, SHARE_INDEX_URL)
|
||||
@ -122,9 +122,9 @@ class ShareViewTests(test.TestCase):
|
||||
share_net = test_data.active_share_network
|
||||
share = test_data.share
|
||||
rules = [test_data.ip_rule, test_data.user_rule]
|
||||
api.manila.share_get = mock.Mock(return_value=share)
|
||||
api.manila.share_network_get = mock.Mock(return_value=share_net)
|
||||
api.manila.share_rules_list = mock.Mock(return_value=rules)
|
||||
api_manila.share_get = mock.Mock(return_value=share)
|
||||
api_manila.share_network_get = mock.Mock(return_value=share_net)
|
||||
api_manila.share_rules_list = mock.Mock(return_value=rules)
|
||||
|
||||
url = reverse('horizon:project:shares:detail',
|
||||
args=[share.id])
|
||||
@ -147,8 +147,8 @@ class ShareViewTests(test.TestCase):
|
||||
def test_update_share(self):
|
||||
share = test_data.share
|
||||
|
||||
api.manila.share_get = mock.Mock(return_value=share)
|
||||
api.manila.share_update = mock.Mock()
|
||||
api_manila.share_get = mock.Mock(return_value=share)
|
||||
api_manila.share_update = mock.Mock()
|
||||
|
||||
formData = {'method': 'UpdateForm',
|
||||
'name': share.name,
|
||||
@ -161,7 +161,7 @@ class ShareViewTests(test.TestCase):
|
||||
def test_list_rules(self):
|
||||
share = test_data.share
|
||||
rules = [test_data.ip_rule, test_data.user_rule]
|
||||
api.manila.share_rules_list = mock.Mock(return_value=rules)
|
||||
api_manila.share_rules_list = mock.Mock(return_value=rules)
|
||||
|
||||
url = reverse('horizon:project:shares:manage_rules', args=[share.id])
|
||||
res = self.client.get(url)
|
||||
@ -171,13 +171,13 @@ class ShareViewTests(test.TestCase):
|
||||
def test_create_rule(self):
|
||||
share = test_data.share
|
||||
url = reverse('horizon:project:shares:rule_add', args=[share.id])
|
||||
api.manila.share_get = mock.Mock(return_value=share)
|
||||
api.manila.share_allow = mock.Mock()
|
||||
api_manila.share_get = mock.Mock(return_value=share)
|
||||
api_manila.share_allow = mock.Mock()
|
||||
formData = {'type': 'user',
|
||||
'method': u'CreateForm',
|
||||
'access_to': 'someuser'}
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.share_allow.assert_called_once_with(
|
||||
api_manila.share_allow.assert_called_once_with(
|
||||
mock.ANY, share.id, access_type=formData['type'],
|
||||
access=formData['access_to'])
|
||||
self.assertRedirectsNoFollow(
|
||||
@ -190,12 +190,12 @@ class ShareViewTests(test.TestCase):
|
||||
formData = {'action':
|
||||
'rules__delete__%s' % rule.id}
|
||||
|
||||
api.manila.share_deny = mock.Mock()
|
||||
api.manila.share_get = mock.Mock(
|
||||
api_manila.share_deny = mock.Mock()
|
||||
api_manila.share_get = mock.Mock(
|
||||
return_value=test_data.share)
|
||||
api.manila.share_rules_list = mock.Mock(
|
||||
api_manila.share_rules_list = mock.Mock(
|
||||
return_value=[rule])
|
||||
url = reverse('horizon:project:shares:manage_rules', args=[share.id])
|
||||
self.client.post(url, formData)
|
||||
api.manila.share_deny.assert_called_with(
|
||||
api_manila.share_deny.assert_called_with(
|
||||
mock.ANY, test_data.share.id, rule.id)
|
||||
|
@ -15,7 +15,7 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
import mock
|
||||
|
||||
from manila_ui import api
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.project.shares import test_data
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
@ -35,12 +35,12 @@ class SnapshotSnapshotViewTests(test.TestCase):
|
||||
'share_id': share.id
|
||||
}
|
||||
|
||||
api.manila.share_snapshot_create = mock.Mock()
|
||||
api.manila.share_get = mock.Mock(return_value=share)
|
||||
api_manila.share_snapshot_create = mock.Mock()
|
||||
api_manila.share_get = mock.Mock(return_value=share)
|
||||
url = reverse('horizon:project:shares:create_snapshot',
|
||||
args=[share.id])
|
||||
self.client.post(url, formData)
|
||||
api.manila.share_snapshot_create.assert_called_with(
|
||||
api_manila.share_snapshot_create.assert_called_with(
|
||||
mock.ANY, share.id, formData['name'], formData['description'],
|
||||
force=False)
|
||||
|
||||
@ -51,16 +51,16 @@ class SnapshotSnapshotViewTests(test.TestCase):
|
||||
formData = {'action':
|
||||
'snapshots__delete__%s' % snapshot.id}
|
||||
|
||||
api.manila.share_snapshot_delete = mock.Mock()
|
||||
api.manila.share_snapshot_get = mock.Mock(
|
||||
api_manila.share_snapshot_delete = mock.Mock()
|
||||
api_manila.share_snapshot_get = mock.Mock(
|
||||
return_value=snapshot)
|
||||
api.manila.share_snapshot_list = mock.Mock(
|
||||
api_manila.share_snapshot_list = mock.Mock(
|
||||
return_value=[snapshot])
|
||||
api.manila.share_list = mock.Mock(
|
||||
api_manila.share_list = mock.Mock(
|
||||
return_value=[share])
|
||||
url = reverse('horizon:project:shares:index')
|
||||
res = self.client.post(url, formData)
|
||||
api.manila.share_snapshot_delete.assert_called_with(
|
||||
api_manila.share_snapshot_delete.assert_called_with(
|
||||
mock.ANY, test_data.snapshot.id)
|
||||
|
||||
self.assertRedirectsNoFollow(res, SHARE_INDEX_URL)
|
||||
@ -68,8 +68,8 @@ class SnapshotSnapshotViewTests(test.TestCase):
|
||||
def test_detail_view(self):
|
||||
snapshot = test_data.snapshot
|
||||
share = test_data.share
|
||||
api.manila.snapshot_get = mock.Mock(return_value=snapshot)
|
||||
api.manila.share_get = mock.Mock(return_value=share)
|
||||
api_manila.snapshot_get = mock.Mock(return_value=snapshot)
|
||||
api_manila.share_get = mock.Mock(return_value=share)
|
||||
|
||||
url = reverse('horizon:project:shares:snapshot-detail',
|
||||
args=[snapshot.id])
|
||||
@ -87,8 +87,8 @@ class SnapshotSnapshotViewTests(test.TestCase):
|
||||
def test_update_snapshot(self):
|
||||
snapshot = test_data.snapshot
|
||||
|
||||
api.manila.share_snapshot_get = mock.Mock(return_value=snapshot)
|
||||
api.manila.share_snapshot_update = mock.Mock()
|
||||
api_manila.share_snapshot_get = mock.Mock(return_value=snapshot)
|
||||
api_manila.share_snapshot_update = mock.Mock()
|
||||
|
||||
formData = {'method': 'UpdateForm',
|
||||
'name': snapshot.name,
|
||||
@ -99,6 +99,6 @@ class SnapshotSnapshotViewTests(test.TestCase):
|
||||
res = self.client.post(url, formData)
|
||||
self.assertRedirectsNoFollow(
|
||||
res, SHARE_INDEX_URL + '?tab=share_tabs__snapshots_tab')
|
||||
api.manila.share_snapshot_update.assert_called_once_with(
|
||||
api_manila.share_snapshot_update.assert_called_once_with(
|
||||
mock.ANY, snapshot, display_name=formData['name'],
|
||||
display_description=formData['description'])
|
||||
|
@ -17,8 +17,10 @@ import mock
|
||||
|
||||
from mox import IsA # noqa
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.project.shares import test_data
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.dashboards.project.shares import test_data
|
||||
from openstack_dashboard.test import helpers as test
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
||||
@ -36,12 +38,12 @@ class SharesTests(test.TestCase):
|
||||
test_data.active_share_network]
|
||||
security_services = [test_data.sec_service]
|
||||
|
||||
api.manila.share_list = mock.Mock(return_value=shares)
|
||||
api.manila.share_snapshot_list = mock.Mock(return_value=snaps)
|
||||
api.manila.share_network_list = mock.Mock(return_value=share_networks)
|
||||
api.manila.security_service_list = mock.Mock(
|
||||
api_manila.share_list = mock.Mock(return_value=shares)
|
||||
api_manila.share_snapshot_list = mock.Mock(return_value=snaps)
|
||||
api_manila.share_network_list = mock.Mock(return_value=share_networks)
|
||||
api_manila.security_service_list = mock.Mock(
|
||||
return_value=security_services)
|
||||
api.manila.share_network_get = mock.Mock()
|
||||
api_manila.share_network_get = mock.Mock()
|
||||
api.neutron.network_list = mock.Mock(return_value=[])
|
||||
api.neutron.subnet_list = mock.Mock(return_value=[])
|
||||
quotas.tenant_limit_usages = mock.Mock(
|
||||
|
0
manila_ui/test/__init__.py
Normal file
0
manila_ui/test/__init__.py
Normal file
154
manila_ui/test/settings.py
Normal file
154
manila_ui/test/settings.py
Normal file
@ -0,0 +1,154 @@
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon.test.settings import * # noqa
|
||||
from horizon.utils import secret_key as secret_key_utils
|
||||
|
||||
from openstack_dashboard import exceptions
|
||||
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
ROOT_PATH = os.path.abspath(os.path.join(TEST_DIR, ".."))
|
||||
|
||||
MEDIA_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'media'))
|
||||
MEDIA_URL = '/media/'
|
||||
STATIC_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'static'))
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
SECRET_KEY = secret_key_utils.generate_or_read_from_file(
|
||||
os.path.join(TEST_DIR, '.secret_key_store'))
|
||||
ROOT_URLCONF = 'manila_ui.test.urls'
|
||||
TEMPLATE_DIRS = (
|
||||
os.path.join(TEST_DIR, 'templates'),
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS += (
|
||||
'openstack_dashboard.context_processors.openstack',
|
||||
)
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.humanize',
|
||||
'django_nose',
|
||||
'openstack_auth',
|
||||
'compressor',
|
||||
'horizon',
|
||||
'openstack_dashboard',
|
||||
'openstack_dashboard.dashboards.project',
|
||||
'openstack_dashboard.dashboards.admin',
|
||||
'openstack_dashboard.dashboards.identity',
|
||||
'openstack_dashboard.dashboards.settings',
|
||||
'manila_ui.dashboards',
|
||||
)
|
||||
|
||||
AUTHENTICATION_BACKENDS = ('openstack_auth.backend.KeystoneBackend',)
|
||||
|
||||
SITE_BRANDING = 'OpenStack'
|
||||
|
||||
HORIZON_CONFIG = {
|
||||
'dashboards': ('project', 'admin', 'identity', 'settings'),
|
||||
'default_dashboard': 'project',
|
||||
"password_validator": {
|
||||
"regex": '^.{8,18}$',
|
||||
"help_text": _("Password must be between 8 and 18 characters.")
|
||||
},
|
||||
'user_home': None,
|
||||
'help_url': "http://docs.openstack.org",
|
||||
'exceptions': {'recoverable': exceptions.RECOVERABLE,
|
||||
'not_found': exceptions.NOT_FOUND,
|
||||
'unauthorized': exceptions.UNAUTHORIZED},
|
||||
}
|
||||
|
||||
# Set to True to allow users to upload images to glance via Horizon server.
|
||||
# When enabled, a file form field will appear on the create image form.
|
||||
# See documentation for deployment considerations.
|
||||
HORIZON_IMAGES_ALLOW_UPLOAD = True
|
||||
|
||||
AVAILABLE_REGIONS = [
|
||||
('http://localhost:5000/v2.0', 'local'),
|
||||
('http://remote:5000/v2.0', 'remote'),
|
||||
]
|
||||
|
||||
OPENSTACK_KEYSTONE_URL = "http://localhost:5000/v2.0"
|
||||
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "Member"
|
||||
|
||||
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
|
||||
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = 'test_domain'
|
||||
|
||||
OPENSTACK_KEYSTONE_BACKEND = {
|
||||
'name': 'native',
|
||||
'can_edit_user': True,
|
||||
'can_edit_group': True,
|
||||
'can_edit_project': True,
|
||||
'can_edit_domain': True,
|
||||
'can_edit_role': True
|
||||
}
|
||||
|
||||
OPENSTACK_NEUTRON_NETWORK = {
|
||||
'enable_lb': True
|
||||
}
|
||||
|
||||
OPENSTACK_HYPERVISOR_FEATURES = {
|
||||
'can_set_mount_point': True,
|
||||
|
||||
# NOTE: as of Grizzly this is not yet supported in Nova so enabling this
|
||||
# setting will not do anything useful
|
||||
'can_encrypt_volumes': False
|
||||
}
|
||||
|
||||
LOGGING['loggers']['openstack_dashboard'] = {
|
||||
'handlers': ['test'],
|
||||
'propagate': False,
|
||||
}
|
||||
|
||||
LOGGING['loggers']['selenium'] = {
|
||||
'handlers': ['test'],
|
||||
'propagate': False,
|
||||
}
|
||||
|
||||
LOGGING['loggers']['manila_ui'] = {
|
||||
'handlers': ['test'],
|
||||
'propagate': False,
|
||||
}
|
||||
|
||||
SECURITY_GROUP_RULES = {
|
||||
'all_tcp': {
|
||||
'name': 'ALL TCP',
|
||||
'ip_protocol': 'tcp',
|
||||
'from_port': '1',
|
||||
'to_port': '65535',
|
||||
},
|
||||
'http': {
|
||||
'name': 'HTTP',
|
||||
'ip_protocol': 'tcp',
|
||||
'from_port': '80',
|
||||
'to_port': '80',
|
||||
},
|
||||
}
|
||||
|
||||
NOSE_ARGS = ['--nocapture',
|
||||
'--nologcapture',
|
||||
'--cover-package=openstack_dashboard',
|
||||
'--cover-inclusive',
|
||||
'--all-modules']
|
20
manila_ui/test/urls.py
Normal file
20
manila_ui/test/urls.py
Normal file
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf import urls
|
||||
import openstack_dashboard.urls
|
||||
|
||||
urlpatterns = urls.patterns(
|
||||
'',
|
||||
urls.url(r'', urls.include(openstack_dashboard.urls))
|
||||
)
|
@ -15,9 +15,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslotest import base
|
||||
import testtools
|
||||
|
||||
|
||||
class TestCase(base.BaseTestCase):
|
||||
class TestCase(testtools.TestCase):
|
||||
|
||||
"""Test case base class for all unit tests."""
|
||||
|
@ -8,7 +8,6 @@ discover
|
||||
python-subunit>=0.0.18
|
||||
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
|
||||
oslosphinx>=2.2.0 # Apache-2.0
|
||||
oslotest>=1.2.0 # Apache-2.0
|
||||
testrepository>=0.0.18
|
||||
testscenarios>=0.4
|
||||
testtools>=0.9.36,!=1.2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user