Coverage for tests/test_lsstsw.py: 43%
21 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-10-18 09:47 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-10-18 09:47 +0000
1# This file is part of verify.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22import os
23import unittest
24try:
25 import unittest.mock as mock
26except ImportError:
27 mock = None
29import lsst.verify.metadata.lsstsw as lsstsw
32class LsstswReposTestCase(unittest.TestCase):
33 """Tests for lsst.verify.provsrc.lsstsw.LsstswRepos.
35 These tests are tied to data in tests/data/lsstsw/
36 """
38 def setUp(self):
39 self.lsstsw_dirname = os.path.join(
40 os.path.dirname(__file__),
41 'data', 'lsstsw')
43 def test_lsstsw_repos(self):
44 lsstsw_repos = lsstsw.LsstswRepos(self.lsstsw_dirname)
46 self.assertEqual(
47 lsstsw_repos.manifest_path,
48 os.path.join(self.lsstsw_dirname, 'build', 'manifest.txt')
49 )
51 self.assertEqual(
52 lsstsw_repos.get_package_repo_path('afw'),
53 os.path.join(self.lsstsw_dirname, 'build', 'afw')
54 )
56 self.assertIn('afw', lsstsw_repos)
57 self.assertNotIn('ruby', lsstsw_repos)
59 self.assertEqual(len(lsstsw_repos), 196)
61 self.assertEqual(
62 lsstsw_repos.get_package_repo_url('afw'),
63 'https://github.com/lsst/afw.git'
64 )
66 self.assertEqual(
67 lsstsw_repos.get_package_repo_url('xrootd'),
68 'https://github.com/lsst/xrootd.git'
69 )
71 # FIXME not sure how to mock GitPython here. Actually complainst can't
72 # lsstsw module.
73 # @mock.patch('lsstsw.git.Repo')
74 # @unittest.skipIf(mock is None, 'unittest.mock is required.')
75 # def test_get_package_branch(self, MockRepo):
76 # # mock git.Repo in lsst.verify.provsrc.lsstsw so that a repo's active
77 # # branch is main and doesn't attempt to actually query the repo in
78 # # the filesystem.
79 # # mock.mocker.patch('lsstsw.verify.provsrc.lsstsw.git.Repo')
80 # MockRepo.return_value.active_branch.name = 'main'
82 # lsstsw_repos = lsstsw.LsstswRepos(self.lsstsw_dirname)
83 # self.assertEqual(
84 # lsstsw_repos.get_package_branch('afw'),
85 # 'main')
88if __name__ == "__main__": 88 ↛ 89line 88 didn't jump to line 89, because the condition on line 88 was never true
89 unittest.main()