1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
13 from toscaparser.tests.base import TestCase
14 import toscaparser.utils.urlutils
15 import toscaparser.utils.yamlparser
17 YAML_LOADER = toscaparser.utils.yamlparser.load_yaml
20 class UrlUtilsTest(TestCase):
22 url_utils = toscaparser.utils.urlutils.UrlUtils
24 def test_urlutils_validate_url(self):
25 self.assertTrue(self.url_utils.validate_url("http://www.github.com/"))
27 self.url_utils.validate_url("https://github.com:81/a/2/a.b"))
28 self.assertTrue(self.url_utils.validate_url("ftp://github.com"))
29 self.assertFalse(self.url_utils.validate_url("github.com"))
30 self.assertFalse(self.url_utils.validate_url("123"))
31 self.assertFalse(self.url_utils.validate_url("a/b/c"))
33 def test_urlutils_join_url(self):
35 self.url_utils.join_url("http://github.com/proj1", "proj2"),
36 "http://github.com/proj2")
38 self.url_utils.join_url("http://github.com/proj1/scripts/a.js",
40 "http://github.com/proj1/scripts/b.js")
42 self.url_utils.join_url("http://github.com/proj1/scripts", "b.js"),
43 "http://github.com/proj1/b.js")
45 self.url_utils.join_url("http://github.com/proj1/scripts",
47 "http://github.com/proj1/scripts/b.js")