Coverage for tests/test_panda_auth_utils.py: 44%

17 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-08-10 07:57 +0000

1"""Unit tests for PanDA authentication utilities. 

2""" 

3import os 

4import unittest 

5from unittest import mock 

6 

7from lsst.ctrl.bps.panda import __version__ as version 

8from lsst.ctrl.bps.panda.panda_auth_utils import panda_auth_status 

9 

10 

11class VersionTestCase(unittest.TestCase): 

12 """Test versioning.""" 

13 

14 def test_version(self): 

15 # Check that version is defined. 

16 self.assertIsNotNone(version) 

17 

18 

19class TestPandaAuthUtils(unittest.TestCase): 

20 """Simple test of auth utilities.""" 

21 

22 def testPandaAuthStatusWrongEnviron(self): 

23 unwanted = { 

24 "PANDA_AUTH", 

25 "PANDA_VERIFY_HOST", 

26 "PANDA_AUTH_VO", 

27 "PANDA_URL_SSL", 

28 "PANDA_URL", 

29 } 

30 test_environ = {key: val for key, val in os.environ.items() if key not in unwanted} 

31 with mock.patch.dict(os.environ, test_environ, clear=True): 

32 with self.assertRaises(OSError): 

33 panda_auth_status() 

34 

35 

36if __name__ == "__main__": 36 ↛ 37line 36 didn't jump to line 37, because the condition on line 36 was never true

37 unittest.main()