incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [1/6] git commit: [#6533] ticket:422 Tests for github code importer
Date Mon, 09 Sep 2013 14:02:36 GMT
Updated Branches:
  refs/heads/master 56043b14b -> 781e22bd5


[#6533] ticket:422 Tests for github code importer


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/3eb02637
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3eb02637
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3eb02637

Branch: refs/heads/master
Commit: 3eb02637a444c4886e307373642af36d78602ed6
Parents: 49174c6
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Sep 6 13:18:39 2013 +0300
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Mon Sep 9 14:02:08 2013 +0000

----------------------------------------------------------------------
 .../forgeimporters/github/tests/test_code.py    | 36 ++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3eb02637/ForgeImporters/forgeimporters/github/tests/test_code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_code.py b/ForgeImporters/forgeimporters/github/tests/test_code.py
index 341e110..09afa87 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_code.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_code.py
@@ -18,9 +18,16 @@
 from unittest import TestCase
 from mock import Mock, patch
 
+from allura.tests import TestController
+from allura.tests.decorators import with_tool
 from forgeimporters.github.code import GitHubRepoImporter
 
 
+# important to be distinct from 'test' which ForgeGit uses, so that the tests can run in
parallel and not clobber each other
+test_project_with_repo = 'test2'
+with_git = with_tool(test_project_with_repo, 'git', 'src', 'git')
+
+
 class TestGitHubRepoImporter(TestCase):
 
     def _make_project(self, gh_proj_name=None):
@@ -40,3 +47,32 @@ class TestGitHubRepoImporter(TestCase):
             mount_label='Code',
             init_from_url='http://remote/clone/url/')
         g.post_event.assert_called_once_with('project_updated')
+
+
+class TestGitHubImportController(TestController, TestCase):
+
+    @with_git
+    def test_index(self):
+        r = self.app.get('/p/{}/admin/ext/import/github-repo/'.format(test_project_with_repo))
+        self.assertIsNotNone(r.html.find(attrs=dict(name="gh_user_name")))
+        self.assertIsNotNone(r.html.find(attrs=dict(name="gh_project_name")))
+        self.assertIsNotNone(r.html.find(attrs=dict(name="mount_label")))
+        self.assertIsNotNone(r.html.find(attrs=dict(name="mount_point")))
+
+    @with_git
+    @patch('forgeimporters.github.code.import_tool')
+    def test_create(self, import_tool):
+        params = dict(
+                gh_user_name='spooky',
+                gh_project_name='poop',
+                mount_label='mylabel',
+                mount_point='mymount',
+                )
+        r = self.app.post('/p/{}/admin/ext/import/github-repo/create'.format(test_project_with_repo),
+                params,
+                status=302)
+        self.assertEqual(r.location, 'http://localhost/p/{}/admin/'.format(test_project_with_repo))
+        self.assertEqual(u'mymount', import_tool.post.call_args[1]['mount_point'])
+        self.assertEqual(u'mylabel', import_tool.post.call_args[1]['mount_label'])
+        self.assertEqual(u'poop', import_tool.post.call_args[1]['project_name'])
+        self.assertEqual(u'spooky', import_tool.post.call_args[1]['user_name'])


Mime
View raw message