|
7 | 7 | BzrFetcher,
|
8 | 8 | BzrMergeProposalFetcher,
|
9 | 9 | GithubFetcher,
|
| 10 | + OpendevFetcher, |
10 | 11 | GitFetcher,
|
11 | 12 | BitbucketFetcher,
|
12 | 13 | LocalFetcher,
|
@@ -132,6 +133,82 @@ def test_can_fetch(self):
|
132 | 133 | self.assertEqual(test, {})
|
133 | 134 |
|
134 | 135 |
|
| 136 | +class OpendevFetcherGenericTest(unittest.TestCase): |
| 137 | + def test_can_fetch(self): |
| 138 | + f = OpendevFetcher.can_fetch |
| 139 | + |
| 140 | + good_tests = [ |
| 141 | + f('https://opendev.org/charms/foo'), |
| 142 | + f('https://www.opendev.org/charms/foo'), |
| 143 | + f('git@opendev.org:charms/foo'), |
| 144 | + ] |
| 145 | + |
| 146 | + bad_tests = [ |
| 147 | + f('http://www.opendev.org/charms/foo'), |
| 148 | + f('http://opendev.org/charms/foo'), |
| 149 | + f('https://opendev.com/charms/foo'), |
| 150 | + f('https://www.opendev.com/charms/foo'), |
| 151 | + f('git@opendev.com:charms/foo'), |
| 152 | + f('gh:charms/foo'), |
| 153 | + f('github:charms/foo'), |
| 154 | + f('http://github.com/charms/foo'), |
| 155 | + f('https://github.com/charms/foo'), |
| 156 | + f('http://www.github.com/charms/foo'), |
| 157 | + f('https://www.github.com/charms/foo'), |
| 158 | + f('git@github.com:charms/foo'), |
| 159 | + f('lp:~openstack-charmers/charms/bionic/foo'), |
| 160 | + f('lp:~openstack-charmers/charms/bionic/foo/+merge/12345'), |
| 161 | + f('bb:charms/foo'), |
| 162 | + f('local:~/src/charms/bionic/foo'), |
| 163 | + f('cs:bionic/foo'), |
| 164 | + f('bundle:openstack-base/single'), |
| 165 | + ] |
| 166 | + |
| 167 | + for test in good_tests: |
| 168 | + self.assertEqual(test['repo'], 'charms/foo') |
| 169 | + |
| 170 | + for test in bad_tests: |
| 171 | + self.assertEqual(test, {}) |
| 172 | + |
| 173 | + |
| 174 | +class OpendevFetcherSpecificTest(unittest.TestCase): |
| 175 | + def test_can_fetch(self): |
| 176 | + f = OpendevFetcher.can_fetch |
| 177 | + |
| 178 | + good_tests = [ |
| 179 | + f('https://opendev.org/x/charm-interface-barbican-hsm'), |
| 180 | + f('https://www.opendev.org/x/charm-interface-barbican-hsm'), |
| 181 | + f('git@opendev.org:x/charm-interface-barbican-hsm'), |
| 182 | + ] |
| 183 | + |
| 184 | + bad_tests = [ |
| 185 | + f('http://opendev.org/x/charm-interface-barbican-hsm'), |
| 186 | + f('http://www.opendev.org/x/charm-interface-barbican-hsm'), |
| 187 | + f('https://opendev.com/x/charm-interface-barbican-hsm'), |
| 188 | + f('https://www.opendev.com/x/charm-interface-barbican-hsm'), |
| 189 | + f('git@opendev.com:x/charm-interface-barbican-hsm'), |
| 190 | + f('gh:x/charm-interface-barbican-hsm'), |
| 191 | + f('github:x/charm-interface-barbican-hsm'), |
| 192 | + f('http://github.com/x/charm-interface-barbican-hsm'), |
| 193 | + f('https://github.com/x/charm-interface-barbican-hsm'), |
| 194 | + f('http://www.github.com/x/charm-interface-barbican-hsm'), |
| 195 | + f('https://www.github.com/x/charm-interface-barbican-hsm'), |
| 196 | + f('git@github.com:x/charm-interface-barbican-hsm'), |
| 197 | + f('lp:~openstack-charmers/x/charm-interface-barbican-hsm'), |
| 198 | + f('lp:~openstack-charmers/x/charm-interface-barbican-hsm/+merge/12345'), |
| 199 | + f('bb:x/charm-interface-barbican-hsm'), |
| 200 | + f('local:~/src/charms/bionic/x/charm-interface-barbican-hsm'), |
| 201 | + f('cs:bionic/x/charm-interface-barbican-hsm'), |
| 202 | + f('bundle:openstack-base/x/charm-interface-barbican-hsm'), |
| 203 | + ] |
| 204 | + |
| 205 | + for test in good_tests: |
| 206 | + self.assertEqual(test['repo'], 'x/charm-interface-barbican-hsm') |
| 207 | + |
| 208 | + for test in bad_tests: |
| 209 | + self.assertEqual(test, {}) |
| 210 | + |
| 211 | + |
135 | 212 | class GitFetcherTest(unittest.TestCase):
|
136 | 213 | def test_can_fetch(self):
|
137 | 214 | f = GitFetcher.can_fetch
|
|
0 commit comments