Add action update unit test for sql
The patch add action update unit test case Change-Id: I42460db62bcee18877b4bcd01984bfaad2d31f5b
This commit is contained in:
parent
99ba27b359
commit
c0f34491e9
|
@ -355,6 +355,24 @@ fake_action_1 = {
|
||||||
"project_id": "project_id-is-tecs"
|
"project_id": "project_id-is-tecs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fake_action_2 = {
|
||||||
|
"freezer_action":
|
||||||
|
{
|
||||||
|
"action": "restore",
|
||||||
|
"mode": "fs",
|
||||||
|
"src_file": "/home/tecs/project_tecs",
|
||||||
|
"backup_name": "project_tecs_restore",
|
||||||
|
"container": "my_restore_container",
|
||||||
|
},
|
||||||
|
"exit_status": "success",
|
||||||
|
"max_retries": 5,
|
||||||
|
"max_retries_interval": 70,
|
||||||
|
"mandatory": False,
|
||||||
|
"action_id": "qwerqwerqwerrewq",
|
||||||
|
"user_id": "user_id-is-provided-by-keystone",
|
||||||
|
"project_id": "project_id-is-tecs"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_fake_action_0():
|
def get_fake_action_0():
|
||||||
return copy.deepcopy(fake_action_0)
|
return copy.deepcopy(fake_action_0)
|
||||||
|
@ -364,6 +382,10 @@ def get_fake_action_1():
|
||||||
return copy.deepcopy(fake_action_1)
|
return copy.deepcopy(fake_action_1)
|
||||||
|
|
||||||
|
|
||||||
|
def get_fake_action_2():
|
||||||
|
return copy.deepcopy(fake_action_2)
|
||||||
|
|
||||||
|
|
||||||
fake_session_0 = {
|
fake_session_0 = {
|
||||||
"session_id": 'turistidellademocrazia',
|
"session_id": 'turistidellademocrazia',
|
||||||
"session_tag": 5,
|
"session_tag": 5,
|
||||||
|
|
|
@ -26,17 +26,20 @@ class DbActionTestCase(base.DbTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DbActionTestCase, self).setUp()
|
super(DbActionTestCase, self).setUp()
|
||||||
self.fake_action_0 = common.get_fake_action_0()
|
self.fake_action_0 = common.get_fake_action_0()
|
||||||
|
self.fake_action_2 = common.get_fake_action_2()
|
||||||
self.freezer_action_0 = self.fake_action_0.get('freezer_action')
|
self.freezer_action_0 = self.fake_action_0.get('freezer_action')
|
||||||
|
self.freezer_action_2 = self.fake_action_2.get('freezer_action')
|
||||||
|
self.fake_project_id = self.fake_action_0.get('project_id')
|
||||||
|
|
||||||
def test_add_and_get_action(self):
|
def test_add_and_get_action(self):
|
||||||
action_doc = copy.deepcopy(self.fake_action_0)
|
action_doc = copy.deepcopy(self.fake_action_0)
|
||||||
action_id = self.dbapi.add_action(user_id=self.fake_action_0.
|
action_id = self.dbapi.add_action(user_id=self.fake_action_0.
|
||||||
get('user_id'),
|
get('user_id'),
|
||||||
doc=action_doc,
|
doc=action_doc,
|
||||||
project_id="myproject")
|
project_id=self.fake_project_id)
|
||||||
self.assertIsNotNone(action_id)
|
self.assertIsNotNone(action_id)
|
||||||
|
|
||||||
result = self.dbapi.get_action(project_id="myproject",
|
result = self.dbapi.get_action(project_id=self.fake_project_id,
|
||||||
user_id=self.fake_action_0.
|
user_id=self.fake_action_0.
|
||||||
get('user_id'),
|
get('user_id'),
|
||||||
action_id=action_id)
|
action_id=action_id)
|
||||||
|
@ -71,10 +74,10 @@ class DbActionTestCase(base.DbTestCase):
|
||||||
action_id = self.dbapi.add_action(user_id=self.fake_action_0.
|
action_id = self.dbapi.add_action(user_id=self.fake_action_0.
|
||||||
get('user_id'),
|
get('user_id'),
|
||||||
doc=action_doc,
|
doc=action_doc,
|
||||||
project_id="myproject")
|
project_id=self.fake_project_id)
|
||||||
self.assertIsNotNone(action_id)
|
self.assertIsNotNone(action_id)
|
||||||
|
|
||||||
result = self.dbapi.delete_action(project_id="myproject",
|
result = self.dbapi.delete_action(project_id=self.fake_project_id,
|
||||||
user_id=self.fake_action_0.
|
user_id=self.fake_action_0.
|
||||||
get('user_id'),
|
get('user_id'),
|
||||||
action_id=action_id)
|
action_id=action_id)
|
||||||
|
@ -83,9 +86,45 @@ class DbActionTestCase(base.DbTestCase):
|
||||||
|
|
||||||
self.assertEqual(result, action_id)
|
self.assertEqual(result, action_id)
|
||||||
|
|
||||||
result = self.dbapi.get_action(project_id="myproject",
|
result = self.dbapi.get_action(project_id=self.fake_project_id,
|
||||||
user_id=self.fake_action_0.
|
user_id=self.fake_action_0.
|
||||||
get('user_id'),
|
get('user_id'),
|
||||||
action_id=action_id)
|
action_id=action_id)
|
||||||
|
|
||||||
self.assertEqual(len(result), 0)
|
self.assertEqual(len(result), 0)
|
||||||
|
|
||||||
|
def test_add_and_update_action(self):
|
||||||
|
action_doc = copy.deepcopy(self.fake_action_0)
|
||||||
|
action_id = self.dbapi.add_action(user_id=self.fake_action_0.
|
||||||
|
get('user_id'),
|
||||||
|
doc=action_doc,
|
||||||
|
project_id=self.fake_project_id)
|
||||||
|
self.assertIsNotNone(action_id)
|
||||||
|
|
||||||
|
patch_doc = copy.deepcopy(self.fake_action_2)
|
||||||
|
|
||||||
|
result = self.dbapi.update_action(project_id=self.fake_project_id,
|
||||||
|
user_id=self.fake_action_2.
|
||||||
|
get('user_id'),
|
||||||
|
patch_doc=patch_doc,
|
||||||
|
action_id=action_id)
|
||||||
|
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
|
self.assertEqual(result, action_id)
|
||||||
|
|
||||||
|
result = self.dbapi.get_action(project_id=self.fake_project_id,
|
||||||
|
user_id=self.fake_action_2.
|
||||||
|
get('user_id'),
|
||||||
|
action_id=action_id)
|
||||||
|
|
||||||
|
self.assertEqual(result.get('max_retries'),
|
||||||
|
self.fake_action_2.get('max_retries'))
|
||||||
|
|
||||||
|
self.assertEqual(result.get('max_retries_interval'),
|
||||||
|
self.fake_action_2.get('max_retries_interval'))
|
||||||
|
|
||||||
|
freezer_action = result.get('freezer_action')
|
||||||
|
|
||||||
|
self.assertEqual(freezer_action.get('action'),
|
||||||
|
self.freezer_action_2.get('action'))
|
||||||
|
|
Loading…
Reference in New Issue