tests/fetch.py: add simple git fetcher specific tests
PATCH 1/1 tests/fetch.py: add simple git fetcher specific tests
Currently, only Git._get_repo_url is tested to make sure that the URLs used in the git fetcher isn't mangled in a non-compatible way.
Signed-off-by Olof Johansson <[email protected]>
--- bitbake/lib/bb/tests/fetch.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
bitbake/lib/bb/tests/fetch.py +30 -0
@@ -23,8 +23,10 @@ import unittest import tempfile import subprocess import os +from urlparse import urlparse from bb.fetch2 import URI from bb.fetch2 import FetchMethod +from bb.fetch2.git import Git import bb class URITest(unittest.TestCase):
@@ -640,6 +642,34 @@ class URLHandle(unittest.TestCase): result = bb.fetch.encodeurl(v) self.assertEqual(result, k) +class GitFetchTests(unittest.TestCase): + class TestFetchData(object): + """ + Ad-Hoc mocked FetchData for the purpose of testing Git() + """ + def __init__(self, url): + urlp = urlparse(url) + if '@' in urlp.netloc: + self.user, self.host = urlp.netloc.split('@', 1) + [None,] + else: + self.user, self.host = None, urlp.netloc + self.proto = urlp.scheme + self.path = urlp.path + + tests = [ + 'http://git.example.com/repo.git', + 'https://git.example.com:1234/repo.git', + 'git://git.example.com/repo', + ] + + def setUp(self): + self.git = Git(None) + pass + + def test_get_repo_url(self): + for url in self.tests: + self.assertEqual(self.git._get_repo_url(self.TestFetchData(url)), url) + class FetchLatestVersionTest(FetcherTest): test_git_uris = {
Signature · 1 line
2.1.4