Esempio n. 1
0
 def test_handle_update_users(self, mock_client, mock_plugin):
     prop_diff = {
         "users": [{
             "name": "baz",
             "password": "******",
             "databases": ["bar", "biff"]
         }, {
             'name': "user2",
             "password": "******",
             "databases": ["biff", "bar"]
         }]
     }
     uget = mock_client().users
     mbaz = mock.Mock(name='baz')
     mbaz.name = 'baz'
     mdel = mock.Mock(name='deleted')
     mdel.name = 'deleted'
     uget.list.return_value = [mbaz, mdel]
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     expected = {
         'users': [{
             'databases': ['bar', 'biff'],
             'name': 'baz',
             'password': '******'
         }, {
             'ACTION': 'CREATE',
             'databases': ['biff', 'bar'],
             'name': 'user2',
             'password': '******'
         }, {
             'ACTION': 'DELETE',
             'name': 'deleted'
         }]
     }
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 2
0
 def test_handle_update_users(self, mock_client, mock_plugin):
     prop_diff = {
         "users": [
             {"name": "baz",
              "password": "******",
              "databases": ["bar", "biff"]},
             {'name': "user2",
              "password": "******",
              "databases": ["biff", "bar"]}
         ]
     }
     uget = mock_client().users
     mbaz = mock.Mock(name='baz')
     mbaz.name = 'baz'
     mdel = mock.Mock(name='deleted')
     mdel.name = 'deleted'
     uget.list.return_value = [mbaz, mdel]
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     expected = {
         'users': [{
             'databases': ['bar', 'biff'],
             'name': 'baz',
             'password': '******'
         }, {
             'ACTION': 'CREATE',
             'databases': ['biff', 'bar'],
             'name': 'user2',
             'password': '******'
         }, {
             'ACTION': 'DELETE',
             'name': 'deleted'
         }]}
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 3
0
 def test_handle_update_databases(self, mock_client, mock_plugin):
     prop_diff = {
         "databases": [{
             "name": "bar",
             "character_set": "ascii"
         }, {
             'name': "baz"
         }]
     }
     mget = mock_client().databases.list
     mbar = mock.Mock(name='bar')
     mbar.name = 'bar'
     mbiff = mock.Mock(name='biff')
     mbiff.name = 'biff'
     mget.return_value = [mbar, mbiff]
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     expected = {
         'databases': [{
             'character_set': 'ascii',
             'name': 'bar'
         }, {
             'ACTION': 'CREATE',
             'name': 'baz'
         }, {
             'ACTION': 'DELETE',
             'name': 'biff'
         }]
     }
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 4
0
 def test_handle_update_size(self, mock_client, mock_plugin):
     prop_diff = {
         "size": 42
     }
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     expected = {
         "size": 42
     }
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 5
0
 def test_handle_update_flavor(self, mock_client, mock_plugin):
     prop_diff = {
         "flavor": "changed"
     }
     mock_plugin().get_flavor_id.return_value = 1234
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     expected = {
         "flavor": 1234
     }
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 6
0
 def test_handle_update_flavor(self, mock_client, mock_plugin):
     # Translation mechanism already resolved flavor name to id.
     prop_diff = {
         "flavor": 1234
     }
     trove = dbinstance.Instance('test', self._rdef, self._stack)
     expected = {
         "flavor": 1234
     }
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 7
0
 def test_handle_update_databases(self, mock_client, mock_plugin):
     prop_diff = {
         "databases": [
             {"name": "bar",
              "character_set": "ascii"},
             {'name': "baz"}
         ]
     }
     mget = mock_client().databases.list
     mbar = mock.Mock(name='bar')
     mbar.name = 'bar'
     mbiff = mock.Mock(name='biff')
     mbiff.name = 'biff'
     mget.return_value = [mbar, mbiff]
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     expected = {
         'databases': [
             {'character_set': 'ascii', 'name': 'bar'},
             {'ACTION': 'CREATE', 'name': 'baz'},
             {'ACTION': 'DELETE', 'name': 'biff'}
         ]}
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 8
0
 def test_handle_update_size(self, mock_client, mock_plugin):
     prop_diff = {"size": 42}
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     expected = {"size": 42}
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 9
0
 def test_handle_update_flavor(self, mock_client, mock_plugin):
     prop_diff = {"flavor": "changed"}
     mock_plugin().get_flavor_id.return_value = 1234
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     expected = {"flavor": 1234}
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 10
0
 def test_handle_update_name(self, mock_client, mock_plugin):
     prop_diff = {"name": "changed"}
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     self.assertEqual(prop_diff, trove.handle_update(None, None, prop_diff))
Esempio n. 11
0
 def test_handle_no_update(self, mock_client, mock_plugin):
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     self.assertEqual({}, trove.handle_update(None, None, {}))
Esempio n. 12
0
 def test_handle_update_flavor(self, mock_client, mock_plugin):
     # Translation mechanism already resolved flavor name to id.
     prop_diff = {"flavor": 1234}
     trove = dbinstance.Instance('test', self._rdef, self._stack)
     expected = {"flavor": 1234}
     self.assertEqual(expected, trove.handle_update(None, None, prop_diff))
Esempio n. 13
0
 def test_handle_update_name(self, mock_client, mock_plugin):
     prop_diff = {
         "name": "changed"
     }
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     self.assertEqual(prop_diff, trove.handle_update(None, None, prop_diff))
Esempio n. 14
0
 def test_handle_no_update(self, mock_client, mock_plugin):
     trove = os_database.OSDBInstance('test', self._rdef, self._stack)
     self.assertEqual({}, trove.handle_update(None, None, {}))