summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-13 07:56:27 +0000
committerGerrit Code Review <review@openstack.org>2018-11-13 07:56:27 +0000
commit3d4145000d56ac33f3db4aa85fbf5b546237b818 (patch)
tree15cb6111f5f8159d53c5d8032f6150bf065329b6
parentee2fc153ef6ba09eef2e2fc6f3182506a35e8be5 (diff)
parent38c4a0b74a94121415d1eb4743f63908dc74a7bb (diff)
Merge "Add unit test for session table in sqlalchemy"
-rw-r--r--freezer_api/tests/unit/sqlalchemy/test_session.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/freezer_api/tests/unit/sqlalchemy/test_session.py b/freezer_api/tests/unit/sqlalchemy/test_session.py
new file mode 100644
index 0000000..1c236fc
--- /dev/null
+++ b/freezer_api/tests/unit/sqlalchemy/test_session.py
@@ -0,0 +1,62 @@
1# -*- encoding: utf-8 -*-
2# (c) Copyright 2018 ZTE Corporation.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13# implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17
18"""Tests for manipulating job via the DB API"""
19
20import copy
21
22from freezer_api.tests.unit import common
23from freezer_api.tests.unit.sqlalchemy import base
24
25
26class DbSessionTestCase(base.DbTestCase):
27
28 def setUp(self):
29 super(DbSessionTestCase, self).setUp()
30 self.fake_session_0 = common.get_fake_session_0()
31 self.fake_session_0.pop('session_id')
32
33 def test_add_and_get_session(self):
34 session_doc = copy.deepcopy(self.fake_session_0)
35 session_id = self.dbapi.add_session(project_id=self.fake_session_0.
36 get('project_id'),
37 user_id=self.fake_session_0.
38 get('user_id'),
39 doc=session_doc)
40 self.assertIsNotNone(session_id)
41 result = self.dbapi.get_session(project_id=self.fake_session_0.
42 get('project_id'),
43 user_id=self.fake_session_0.
44 get('user_id'),
45 session_id=session_id)
46 self.assertIsNotNone(result)
47 self.assertEqual(result.get('session_tag'),
48 self.fake_session_0.get('session_tag'))
49 self.assertEqual(result.get('description'),
50 self.fake_session_0.get('description'))
51 self.assertEqual(result.get('hold_off'),
52 self.fake_session_0.get('hold_off'))
53 self.assertEqual(result.get('time_start'),
54 self.fake_session_0.get('time_start'))
55 self.assertEqual(result.get('time_end'),
56 self.fake_session_0.get('time_end'))
57 self.assertEqual(result.get('user_id'),
58 self.fake_session_0.get('user_id'))
59 self.assertEqual(result.get('project_id'),
60 self.fake_session_0.get('project_id'))
61 self.assertEqual(result.get('schedule'),
62 self.fake_session_0.get('schedule'))