summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-07-04 11:29:30 +0000
committerGerrit Code Review <review@openstack.org>2014-07-04 11:29:30 +0000
commitc1ecea1dd7639c0c0746cf300adeccc6382bb481 (patch)
tree2362c73299745ad2ca6eb2b141589e7ab9463eed /openstack_dashboard/dashboards
parent7e5e0fa455c750a4c70458a9f182bac840da5374 (diff)
parentda1ed65a46a32a0cde7bc28e4e0a755222c27f7a (diff)
downloadhorizon-c1ecea1dd7639c0c0746cf300adeccc6382bb481.tar.gz
Merge "Users can now be deleted within trove."
Diffstat (limited to 'openstack_dashboard/dashboards')
-rw-r--r--openstack_dashboard/dashboards/project/databases/tables.py2
-rw-r--r--openstack_dashboard/dashboards/project/databases/tests.py43
2 files changed, 42 insertions, 3 deletions
diff --git a/openstack_dashboard/dashboards/project/databases/tables.py b/openstack_dashboard/dashboards/project/databases/tables.py
index 98a553b05..69e7f8401 100644
--- a/openstack_dashboard/dashboards/project/databases/tables.py
+++ b/openstack_dashboard/dashboards/project/databases/tables.py
@@ -67,7 +67,7 @@ class DeleteUser(tables.DeleteAction):
def delete(self, request, obj_id):
datum = self.table.get_object_by_id(obj_id)
try:
- api.trove.users_delete(request, datum.instance.id, datum.name)
+ api.trove.user_delete(request, datum.instance.id, datum.name)
except Exception:
msg = _('Error deleting database user.')
exceptions.handle(request, msg)
diff --git a/openstack_dashboard/dashboards/project/databases/tests.py b/openstack_dashboard/dashboards/project/databases/tests.py
index d44753946..0feb2c433 100644
--- a/openstack_dashboard/dashboards/project/databases/tests.py
+++ b/openstack_dashboard/dashboards/project/databases/tests.py
@@ -82,8 +82,7 @@ class DatabaseTests(test.TestCase):
# Mock database instances
databases = self.databases.list()
last_record = databases[-1]
- databases = common.Paginated(databases,
- next_marker="foo")
+ databases = common.Paginated(databases, next_marker="foo")
api.trove.instance_list(IsA(http.HttpRequest), marker=None)\
.AndReturn(databases)
# Mock flavors
@@ -236,3 +235,43 @@ class DatabaseTests(test.TestCase):
def test_details_with_hostname(self):
database = self.databases.list()[1]
self._test_details(database, with_designate=True)
+
+ @test.create_stubs(
+ {api.trove: ('instance_get', 'flavor_get', 'users_list',
+ 'user_list_access', 'user_delete')})
+ def test_user_delete(self):
+ database = self.databases.first()
+ user = self.database_users.first()
+ user_db = self.database_user_dbs.first()
+
+ database_id = database.id
+ # Instead of using the user's ID, the api uses the user's name. BOOO!
+ user_id = user.name
+
+ # views.py: DetailView.get_data
+ api.trove.instance_get(IsA(http.HttpRequest), IsA(unicode))\
+ .AndReturn(database)
+ api.trove.flavor_get(IsA(http.HttpRequest), IsA(str))\
+ .AndReturn(self.flavors.first())
+
+ # tabs.py: UserTab.get_user_data
+ api.trove.users_list(IsA(http.HttpRequest),
+ database_id).AndReturn([user])
+ api.trove.user_list_access(IsA(http.HttpRequest),
+ database_id,
+ user_id).AndReturn([user_db])
+
+ # tables.py: DeleteUser.delete
+ api.trove.user_delete(IsA(http.HttpRequest),
+ database_id,
+ user_id).AndReturn(None)
+
+ self.mox.ReplayAll()
+
+ details_url = reverse('horizon:project:databases:detail',
+ args=[database_id])
+ url = details_url + '?tab=instance_details__users_tab'
+ action_string = u"users__delete__%s" % user_id
+ form_data = {'action': action_string}
+ res = self.client.post(url, form_data)
+ self.assertRedirectsNoFollow(res, url)