blob: 4f3fa0ca6fee7b066102d911641e18392553fc6c [file] [log] [blame]
# Copyright 2014 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests of the HTTP utility functions."""
import unittest
from melange.utils import http
class SchemeRelativeURLTest(unittest.TestCase):
"""Tests for the schemeRelativeURL function."""
def testSchemeRelativeURL(self):
"""Tests constructing scheme-relative URLs from absolute URLs."""
test_data = {
'http://subdomain.example.tld': '//subdomain.example.tld',
'https://subdomain.example.tld': '//subdomain.example.tld',
'ftp://subdomain.example.tld/path/to/resource.exe':
'//subdomain.example.tld/path/to/resource.exe',
}
for absolute_url, expected_scheme_relative_url in test_data.iteritems():
self.assertEqual(
expected_scheme_relative_url, http.schemeRelativeURL(absolute_url))