Fix broken unit tests
Fix following tests: admin/shares/tests.py: - test_delete_share project/shares/shares/tests.py: - test_create_share - test_create_share_from_snapshot - test_delete_share - test_create_rule Remove test_create_share_from_snapshot_URL in project/shares/shares/tests.py, as Manila does not use data from URL for creation of a share. This test is invalid left-over. Closes-Bug: #1472178 Change-Id: I5c89c19b1ac729cc44bc05712c737ed97350a076
This commit is contained in:
parent
992de84faf
commit
d2efc90396
|
@ -14,7 +14,6 @@
|
|||
|
||||
from django.core.urlresolvers import reverse
|
||||
import mock
|
||||
import unittest
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.project.shares import test_data
|
||||
|
@ -57,15 +56,13 @@ class SharesTests(test.BaseAdminViewTests):
|
|||
self.assertEqual(res.status_code, 200)
|
||||
self.assertTemplateUsed(res, 'admin/shares/index.html')
|
||||
|
||||
@unittest.skip("broken unit test")
|
||||
def test_delete_share(self):
|
||||
share = test_data.share
|
||||
|
||||
formData = {'action':
|
||||
'shares__delete__%s' % share.id}
|
||||
|
||||
snaps = [test_data.snapshot]
|
||||
api_manila.share_snapshot_list = mock.Mock(return_value=snaps)
|
||||
api_manila.share_snapshot_list = mock.Mock(return_value=[])
|
||||
api.keystone.tenant_list = mock.Mock(return_value=([], None))
|
||||
api_manila.share_delete = mock.Mock()
|
||||
api_manila.share_get = mock.Mock(
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
from django.core.urlresolvers import reverse
|
||||
import mock
|
||||
import unittest
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.project.shares import test_data
|
||||
|
@ -28,7 +27,14 @@ SHARE_INDEX_URL = reverse('horizon:project:shares:index')
|
|||
|
||||
class ShareViewTests(test.TestCase):
|
||||
|
||||
@unittest.skip("broken unit test")
|
||||
def setUp(self):
|
||||
super(ShareViewTests, self).setUp()
|
||||
self.fake_share_type = mock.Mock()
|
||||
self.fake_share_type.name = 'fake'
|
||||
self.fake_share_type.id = 'fake_id'
|
||||
self.fake_share_type.get_keys = mock.Mock(
|
||||
return_value={'driver_handles_share_servers': 'True'})
|
||||
|
||||
def test_create_share(self):
|
||||
usage_limit = {'maxTotalVolumeGigabytes': 250,
|
||||
'gigabytesUsed': 20,
|
||||
|
@ -41,23 +47,27 @@ class ShareViewTests(test.TestCase):
|
|||
'method': u'CreateForm',
|
||||
'share_network': share_net.id,
|
||||
'size': 1,
|
||||
'type': 'NFS'
|
||||
'share_proto': u'NFS',
|
||||
'share_type': 'fake',
|
||||
'share-network-choices-fake': share_net.id,
|
||||
}
|
||||
|
||||
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_type_list = mock.Mock(return_value=[])
|
||||
api_manila.share_type_list = mock.Mock(
|
||||
return_value=[self.fake_share_type, ])
|
||||
api.neutron.is_service_enabled = mock.Mock(return_value=[True])
|
||||
quotas.tenant_limit_usages = mock.Mock(return_value=[usage_limit])
|
||||
url = reverse('horizon:project:shares:create')
|
||||
self.client.post(url, formData)
|
||||
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={})
|
||||
|
||||
@unittest.skip("broken unit test")
|
||||
api_manila.share_create.assert_called_with(
|
||||
mock.ANY, size=formData['size'], name=formData['name'],
|
||||
description=formData['description'], proto=formData['share_proto'],
|
||||
snapshot_id=None, is_public=False, share_network=share_net.id,
|
||||
metadata={}, share_type=formData['share_type'])
|
||||
|
||||
def test_create_share_from_snapshot(self):
|
||||
share_net = test_data.active_share_network
|
||||
share_nets = [share_net]
|
||||
|
@ -67,9 +77,11 @@ class ShareViewTests(test.TestCase):
|
|||
'method': u'CreateForm',
|
||||
'share_network': share_net.id,
|
||||
'size': snapshot.size,
|
||||
'type': 'NFS',
|
||||
'share_proto': 'NFS',
|
||||
'share_type': 'fake',
|
||||
'share_source_type': 'snapshot',
|
||||
'snapshot': snapshot.id
|
||||
'snapshot': snapshot.id,
|
||||
'share-network-choices-fake': share_net.id,
|
||||
}
|
||||
|
||||
api_manila.share_create = mock.Mock()
|
||||
|
@ -79,45 +91,22 @@ class ShareViewTests(test.TestCase):
|
|||
return_value=snapshot)
|
||||
api.neutron.is_service_enabled = mock.Mock(return_value=[True])
|
||||
api_manila.share_network_list = mock.Mock(return_value=share_nets)
|
||||
api_manila.share_type_list = mock.Mock(
|
||||
return_value=[self.fake_share_type, ])
|
||||
|
||||
url = reverse('horizon:project:shares:create')
|
||||
res = self.client.post(url, formData)
|
||||
api_manila.share_create.assert_called_with(
|
||||
mock.ANY, formData['size'], formData['name'],
|
||||
formData['description'], formData['type'],
|
||||
snapshot_id=snapshot.id,
|
||||
share_network_id=share_net.id, metadata={})
|
||||
mock.ANY, size=formData['size'], name=formData['name'],
|
||||
description=formData['description'], proto=formData['share_proto'],
|
||||
snapshot_id=snapshot.id, is_public=False,
|
||||
share_network=share_net.id, metadata={},
|
||||
share_type=formData['share_type'])
|
||||
self.assertRedirectsNoFollow(res, SHARE_INDEX_URL)
|
||||
|
||||
@unittest.skip("broken unit test")
|
||||
def test_create_share_from_snapshot_url(self):
|
||||
share_net = test_data.active_share_network
|
||||
share_nets = [share_net]
|
||||
snapshot = test_data.snapshot
|
||||
formData = {'name': u'new_share',
|
||||
'description': u'This is test share',
|
||||
'method': u'CreateForm',
|
||||
'share_network': share_net.id,
|
||||
'size': 1,
|
||||
'type': 'NFS'
|
||||
}
|
||||
|
||||
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.neutron.is_service_enabled = mock.Mock(return_value=[True])
|
||||
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(
|
||||
mock.ANY, formData['size'], formData['name'],
|
||||
formData['description'], formData['type'], snapshot_id=None,
|
||||
share_network_id=share_net.id, metadata={})
|
||||
|
||||
@unittest.skip("broken unit test")
|
||||
def test_delete_share(self):
|
||||
share = test_data.share
|
||||
api_manila.share_snapshot_list = mock.Mock(return_value=[])
|
||||
|
||||
formData = {'action':
|
||||
'shares__delete__%s' % share.id}
|
||||
|
@ -184,20 +173,21 @@ class ShareViewTests(test.TestCase):
|
|||
self.assertEqual(res.status_code, 200)
|
||||
self.assertTemplateUsed(res, 'project/shares/shares/manage_rules.html')
|
||||
|
||||
@unittest.skip("broken unit test")
|
||||
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.neutron.is_service_enabled = mock.Mock(return_value=[True])
|
||||
formData = {'type': 'user',
|
||||
formData = {'access_type': 'user',
|
||||
'method': u'CreateForm',
|
||||
'access_to': 'someuser'}
|
||||
'access_to': 'someuser',
|
||||
'access_level': 'rw'}
|
||||
res = self.client.post(url, formData)
|
||||
api_manila.share_allow.assert_called_once_with(
|
||||
mock.ANY, share.id, access_type=formData['type'],
|
||||
access=formData['access_to'])
|
||||
mock.ANY, share.id, access_type=formData['access_type'],
|
||||
access_to=formData['access_to'],
|
||||
access_level=formData['access_level'])
|
||||
self.assertRedirectsNoFollow(
|
||||
res,
|
||||
reverse('horizon:project:shares:manage_rules', args=[share.id]))
|
||||
|
|
Loading…
Reference in New Issue