All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/fetch.py: add simple git fetcher specific tests
@ 2016-01-20 13:57 Olof Johansson
  0 siblings, 0 replies; only message in thread
From: Olof Johansson @ 2016-01-20 13:57 UTC (permalink / raw)
  To: bitbake-devel

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@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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-20 13:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20 13:57 [PATCH] tests/fetch.py: add simple git fetcher specific tests Olof Johansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.