-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_srcflib_scripts.py
More file actions
53 lines (34 loc) · 1.4 KB
/
test_srcflib_scripts.py
File metadata and controls
53 lines (34 loc) · 1.4 KB
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
44
45
46
47
48
49
50
51
52
53
from inspect import cleandoc
import unittest
from srcf.database import Session, queries
from srcflib.scripts.utils import ENTRYPOINTS
from .scripts import no_args, with_member_society, with_owner
from .utils import create_test_session, destroy_test_session
sess: Session
def setUpModule():
global sess
sess = create_test_session()
def tearDownModule():
destroy_test_session(sess)
class TestScripts(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.mem = queries.get_member("spqr2", sess)
cls.soc = queries.get_society("unittest", sess)
def test_entrypoints(self):
self.assertIn("srcflib-scripts-no-args=tests.scripts:no_args", ENTRYPOINTS)
def test_doc(self):
self.assertEqual(cleandoc(no_args.__doc__), "Usage: srcflib-scripts-no-args")
def test_args_member_society(self):
member, society = with_member_society({"MEMBER": self.mem.crsid,
"SOCIETY": self.soc.society})
self.assertEqual(member, self.mem)
self.assertEqual(society, self.soc)
def test_args_owner_member(self):
member = with_owner({"OWNER": self.mem.crsid})
self.assertEqual(member, self.mem)
def test_args_owner_society(self):
society = with_owner({"OWNER": self.soc.society})
self.assertEqual(society, self.soc)
if __name__ == "__main__":
unittest.main()