incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [4/6] git commit: [#6541] Added audit log on project import
Date Fri, 06 Sep 2013 15:11:44 GMT
[#6541] Added audit log on project import

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/caddc076
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/caddc076
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/caddc076

Branch: refs/heads/db/6541
Commit: caddc0766ea7923e22cfc642e7cf2ecd8214ba66
Parents: 230c205
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed Aug 28 20:19:13 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Sep 6 15:11:06 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/base.py           |  2 ++
 .../forgeimporters/tests/test_base.py           | 24 ++++++++++++++++++++
 2 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/caddc076/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index e0e9d6f..ffb1650 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -37,6 +37,7 @@ from allura.lib import helpers as h
 from allura.lib import exceptions
 from allura.lib import validators as v
 from allura.app import SitemapEntry
+from allura import model as M
 
 from paste.deploy.converters import aslist
 
@@ -245,6 +246,7 @@ class ProjectImporter(BaseController):
         self.after_project_create(c.project, **kw)
         for importer_name in kw['tools']:
             import_tool.post(importer_name, **kw)
+        M.AuditLog.log('import project from %s' % self.source)
 
         flash('Welcome to the %s Project System! '
               'Your project data will be imported and should show up here shortly.' % config['site_name'])

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/caddc076/ForgeImporters/forgeimporters/tests/test_base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/test_base.py b/ForgeImporters/forgeimporters/tests/test_base.py
index 7de0625..4aefc35 100644
--- a/ForgeImporters/forgeimporters/tests/test_base.py
+++ b/ForgeImporters/forgeimporters/tests/test_base.py
@@ -99,6 +99,30 @@ class TestProjectImporter(TestCase):
         self.assertEqual(pi.tool_importers, {'ep1': eps[0].lv, 'ep3': eps[2].lv})
         iep.assert_called_once_with('allura.importers')
 
+    @mock.patch.object(base, 'redirect')
+    @mock.patch.object(base, 'flash')
+    @mock.patch.object(base, 'import_tool')
+    @mock.patch.object(base, 'M')
+    @mock.patch.object(base, 'c')
+    def test_process(self, c, M, import_tool, flash, redirect):
+        pi = base.ProjectImporter(mock.Mock())
+        pi.source = 'Source'
+        pi.after_project_create = mock.Mock()
+        pi.neighborhood.register_project.return_value.script_name = 'script_name/'
+        kw = {
+                'project_name': 'project_name',
+                'project_shortname': 'shortname',
+                'tools': ['tool'],
+            }
+        with mock.patch.dict(base.config, {'site_name': 'foo'}):
+            pi.process(**kw)
+        pi.neighborhood.register_project.assert_called_once_with('shortname', project_name='project_name')
+        pi.after_project_create.assert_called_once_with(c.project, **kw)
+        import_tool.post.assert_called_once_with('tool', **kw)
+        M.AuditLog.log.assert_called_once_with('import project from Source')
+        self.assertEqual(flash.call_count, 1)
+        redirect.assert_called_once_with('script_name/admin/overview')
+
 
 
 TA1 = mock.Mock(tool_label='foo', tool_description='foo_desc')


Mime
View raw message