Browse Source

Add action delete unit test for sql

The patch add get and delete action unit
test for sql

Change-Id: Ia7e021b39fc25607153db7b6c0d2b5e7ea402b75
tags/7.0.0
gecong1973 6 months ago
parent
commit
320b357e4e
1 changed files with 24 additions and 0 deletions
  1. 24
    0
      freezer_api/tests/unit/sqlalchemy/test_action.py

+ 24
- 0
freezer_api/tests/unit/sqlalchemy/test_action.py View File

@@ -65,3 +65,27 @@ class DbActionTestCase(base.DbTestCase):
65 65
 
66 66
         self.assertEqual(freezer_action.get('mode'),
67 67
                          self.freezer_action_0.get('mode'))
68
+
69
+    def test_add_and_delete_action(self):
70
+        action_doc = copy.deepcopy(self.fake_action_0)
71
+        action_id = self.dbapi.add_action(user_id=self.fake_action_0.
72
+                                          get('user_id'),
73
+                                          doc=action_doc,
74
+                                          project_id="myproject")
75
+        self.assertIsNotNone(action_id)
76
+
77
+        result = self.dbapi.delete_action(project_id="myproject",
78
+                                          user_id=self.fake_action_0.
79
+                                          get('user_id'),
80
+                                          action_id=action_id)
81
+
82
+        self.assertIsNotNone(result)
83
+
84
+        self.assertEqual(result, action_id)
85
+
86
+        result = self.dbapi.get_action(project_id="myproject",
87
+                                       user_id=self.fake_action_0.
88
+                                       get('user_id'),
89
+                                       action_id=action_id)
90
+
91
+        self.assertEqual(len(result), 0)

Loading…
Cancel
Save