Merge "Unittest Case for get_user"
This commit is contained in:
commit
5eede25ae4
@ -448,6 +448,25 @@ class MySqlAdminTest(testtools.TestCase):
|
|||||||
|
|
||||||
self.assertTrue("AND Marker >= '" + marker + "'" in args[0].text)
|
self.assertTrue("AND Marker >= '" + marker + "'" in args[0].text)
|
||||||
|
|
||||||
|
def test_get_user(self):
|
||||||
|
"""
|
||||||
|
Unit tests for mySqlAdmin.get_user.
|
||||||
|
This test case checks if the sql query formed by the get_user method
|
||||||
|
is correct or not by checking with expected query.
|
||||||
|
"""
|
||||||
|
username = "user1"
|
||||||
|
hostname = "host"
|
||||||
|
self.mySqlAdmin.get_user(username, hostname)
|
||||||
|
args, _ = dbaas.LocalSqlClient.execute.call_args
|
||||||
|
expected = ["SELECT User, Host",
|
||||||
|
"FROM mysql.user",
|
||||||
|
"WHERE Host != 'localhost' AND User = 'user1'",
|
||||||
|
"ORDER BY User, Host",
|
||||||
|
]
|
||||||
|
|
||||||
|
for text in expected:
|
||||||
|
self.assertTrue(text in args[0].text, "%s not in query." % text)
|
||||||
|
|
||||||
|
|
||||||
class MySqlAppTest(testtools.TestCase):
|
class MySqlAppTest(testtools.TestCase):
|
||||||
|
|
||||||
|
@ -100,6 +100,15 @@ class GuestAgentManagerTest(testtools.TestCase):
|
|||||||
self.assertThat(users, Equals(['user1']))
|
self.assertThat(users, Equals(['user1']))
|
||||||
verify(dbaas.MySqlAdmin).list_users(None, None, False)
|
verify(dbaas.MySqlAdmin).list_users(None, None, False)
|
||||||
|
|
||||||
|
def test_get_users(self):
|
||||||
|
username = ['user1']
|
||||||
|
hostname = ['host']
|
||||||
|
when(dbaas.MySqlAdmin).get_user(username,
|
||||||
|
hostname).thenReturn(['user1'])
|
||||||
|
users = self.manager.get_user(self.context, username, hostname)
|
||||||
|
self.assertThat(users, Equals(['user1']))
|
||||||
|
verify(dbaas.MySqlAdmin).get_user(username, hostname)
|
||||||
|
|
||||||
def test_enable_root(self):
|
def test_enable_root(self):
|
||||||
when(dbaas.MySqlAdmin).enable_root().thenReturn('user_id_stuff')
|
when(dbaas.MySqlAdmin).enable_root().thenReturn('user_id_stuff')
|
||||||
user_id = self.manager.enable_root(self.context)
|
user_id = self.manager.enable_root(self.context)
|
||||||
|
Loading…
Reference in New Issue
Block a user