[bitbake-devel] [PATCH] tests/fetch.py: add simple git fetcher specific tests
Olof Johansson
olof.johansson at axis.com
Wed Jan 20 13:57:59 UTC 2016
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 <olof.johansson at axis.com>
---
bitbake/lib/bb/tests/fetch.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index b175a43..c9d9e9f 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -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 = {
--
2.1.4
More information about the bitbake-devel
mailing list