|
| 1 | +# |
| 2 | +# Copyright (c) 2017 nexB Inc. and others. All rights reserved. |
| 3 | +# http://nexb.com and https://github.com/nexB/scancode-toolkit/ |
| 4 | +# The ScanCode software is licensed under the Apache License version 2.0. |
| 5 | +# Data generated with ScanCode require an acknowledgment. |
| 6 | +# ScanCode is a trademark of nexB Inc. |
| 7 | +# |
| 8 | +# You may not use this software except in compliance with the License. |
| 9 | +# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 |
| 10 | +# Unless required by applicable law or agreed to in writing, software distributed |
| 11 | +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 12 | +# CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 13 | +# specific language governing permissions and limitations under the License. |
| 14 | +# |
| 15 | +# When you publish or redistribute any data created with ScanCode or any ScanCode |
| 16 | +# derivative work, you must accompany this data with the following acknowledgment: |
| 17 | +# |
| 18 | +# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES |
| 19 | +# OR CONDITIONS OF ANY KIND, either express or implied. No content created from |
| 20 | +# ScanCode should be considered or used as legal advice. Consult an Attorney |
| 21 | +# for any legal advice. |
| 22 | +# ScanCode is a free software code scanning tool from nexB Inc. and others. |
| 23 | +# Visit https://github.com/nexB/scancode-toolkit/ for support and download. |
| 24 | + |
| 25 | +from __future__ import absolute_import |
| 26 | +from __future__ import print_function |
| 27 | + |
| 28 | +import os.path |
| 29 | + |
| 30 | +from commoncode.testcase import FileBasedTesting |
| 31 | +from packagedcode.utils import parse_repo_url |
| 32 | + |
| 33 | + |
| 34 | +class TestUtilsPi(FileBasedTesting): |
| 35 | + test_data_dir = os.path.join(os.path.dirname(__file__), 'data') |
| 36 | + |
| 37 | + def test_parse_url(self): |
| 38 | + inputs = ['npm/npm', |
| 39 | + 'gist:11081aaa281', |
| 40 | + 'bitbucket:example/repo', |
| 41 | + 'gitlab:another/repo', |
| 42 | + 'expressjs/serve-static', |
| 43 | + 'git://github.com/angular/di.js.git', |
| 44 | + 'git://github.com/hapijs/boom', |
| 45 | + '[email protected]:balderdashy/waterline-criteria.git', |
| 46 | + 'http://github.com/ariya/esprima.git', |
| 47 | + 'http://github.com/isaacs/nopt', |
| 48 | + 'https://github.com/chaijs/chai', |
| 49 | + 'https://github.com/christkv/kerberos.git', |
| 50 | + 'https://gitlab.com/foo/private.git', |
| 51 | + '[email protected]:foo/private.git' |
| 52 | + ] |
| 53 | + results = [] |
| 54 | + for input in inputs: |
| 55 | + results.append(parse_repo_url(input)) |
| 56 | + expected = ['https://github.com/npm/npm', |
| 57 | + 'https://gist.github.com/11081aaa281', |
| 58 | + 'https://bitbucket.org/example/repo', |
| 59 | + 'https://gitlab.com/another/repo', |
| 60 | + 'https://github.com/expressjs/serve-static', |
| 61 | + 'git://github.com/angular/di.js.git', |
| 62 | + 'git://github.com/hapijs/boom', |
| 63 | + 'https://github.com/balderdashy/waterline-criteria.git', |
| 64 | + 'http://github.com/ariya/esprima.git', |
| 65 | + 'http://github.com/isaacs/nopt', |
| 66 | + 'https://github.com/chaijs/chai', |
| 67 | + 'https://github.com/christkv/kerberos.git', |
| 68 | + 'https://gitlab.com/foo/private.git', |
| 69 | + 'https://gitlab.com/foo/private.git' |
| 70 | + ] |
| 71 | + self.assertEquals(expected, results) |
| 72 | + |
0 commit comments