aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_trapd_http_session.py
blob: a423be6dba6d325dd8b0a3ae2e21f8826e3f9376 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pytest
import unittest
import trapd_http_session
 
class test_init_session_obj(unittest.TestCase):
    """
    Test the init_session_obj mod
    """
 
    def init_session(self):
        """
        test creation of http session
        """
        result = trapd_http_session.init_session_obj()
        compare = str(result).startswith("<requests.sessions.Session object at")
        self.assertEqual(compare, True)
 
    def test_reset(self):
        """
        test reset of existing http session
        """
        sess = trapd_http_session.init_session_obj()
        result = trapd_http_session.reset_session_obj(sess)
        compare = str(result).startswith("<requests.sessions.Session object at")
        self.assertEqual(compare, True)
 
    def close_existing_session(self):
        """
        test close of existing http session
        """
        sess = trapd_http_session.init_session_obj()
        result = trapd_http_session.close_session_obj(sess)
        self.assertEqual(result, True)
 
    def close_nonexistent_session(self):
        """
        test close of non-existent http session
        """
        result = trapd_http_session.close_session_obj(None)
        self.assertEqual(result, True)
 
if __name__ == '__main__':
    unittest.main()