incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [15/39] git commit: [#6541] Added import_id and AuditLog to GC repo importer
Date Tue, 10 Sep 2013 15:55:11 GMT
[#6541] Added import_id and AuditLog to GC repo importer

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


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

Branch: refs/heads/db/6545
Commit: 59a395dfcccf6829162fb2c9ff2f4c02737c97ff
Parents: 4a4ee8f
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed Aug 28 20:42:33 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Sep 9 20:27:30 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/google/code.py      | 12 +++++++++++-
 .../forgeimporters/google/tests/test_code.py      | 18 ++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/59a395df/ForgeImporters/forgeimporters/google/code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/code.py b/ForgeImporters/forgeimporters/google/code.py
index 4cf752d..c5f34cd 100644
--- a/ForgeImporters/forgeimporters/google/code.py
+++ b/ForgeImporters/forgeimporters/google/code.py
@@ -36,6 +36,7 @@ from tg.decorators import (
 from allura.controllers import BaseController
 from allura.lib import validators as v
 from allura.lib.decorators import require_post, task
+from allura import model as M
 
 from forgeimporters.base import (
         ToolImporter,
@@ -168,6 +169,15 @@ class GoogleRepoImporter(ToolImporter):
                 mount_point=mount_point or 'code',
                 mount_label=mount_label or 'Code',
                 init_from_url=repo_url,
-                )
+                import_id={
+                        'source': self.source,
+                        'project_name': project_name,
+                    }
+            )
+        M.AuditLog.log(
+                'import tool %s from %s on %s' % (
+                    app.config.options.mount_point,
+                    project_name, self.source,
+                ), project=project, user=user)
         g.post_event('project_updated')
         return app

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/59a395df/ForgeImporters/forgeimporters/google/tests/test_code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/tests/test_code.py b/ForgeImporters/forgeimporters/google/tests/test_code.py
index c6874ad..4028076 100644
--- a/ForgeImporters/forgeimporters/google/tests/test_code.py
+++ b/ForgeImporters/forgeimporters/google/tests/test_code.py
@@ -57,20 +57,30 @@ class TestGoogleRepoImporter(TestCase):
         return project
 
     @patch('forgeimporters.google.code.g')
+    @patch('forgeimporters.google.code.M')
     @patch('forgeimporters.google.code.GoogleCodeProjectExtractor')
     @patch('forgeimporters.google.code.get_repo_url')
-    def test_import_tool_happy_path(self, get_repo_url, gcpe, g):
+    def test_import_tool_happy_path(self, get_repo_url, gcpe, M, g):
         gcpe.return_value.get_repo_type.return_value = 'git'
         get_repo_url.return_value = 'http://remote/clone/url/'
         p = self._make_project(gc_proj_name='myproject')
-        GoogleRepoImporter().import_tool(p, Mock(name='c.user'),
-                project_name='project_name')
+        u = Mock(name='c.user')
+        app = p.install_app.return_value
+        app.config.options.mount_point = 'code'
+        GoogleRepoImporter().import_tool(p, u, project_name='project_name')
         get_repo_url.assert_called_once_with('project_name', 'git')
         p.install_app.assert_called_once_with('Git',
                 mount_point='code',
                 mount_label='Code',
                 init_from_url='http://remote/clone/url/',
-                )
+                import_id={
+                        'source': 'Google Code',
+                        'project_name': 'project_name',
+                    },
+            )
+        M.AuditLog.log.assert_called_once_with(
+                'import tool code from project_name on Google Code',
+                project=p, user=u)
         g.post_event.assert_called_once_with('project_updated')
 
 


Mime
View raw message