allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject allura git commit: [#7999] ticket:864 Handle subprojects
Date Wed, 25 Nov 2015 15:20:38 GMT
Repository: allura
Updated Branches:
  refs/heads/ib/7999a 788503bb4 -> 5320d7549


[#7999] ticket:864 Handle subprojects


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

Branch: refs/heads/ib/7999a
Commit: 5320d754913039f2cc1ed64f22402455911d0825
Parents: 788503b
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Nov 25 15:55:46 2015 +0200
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Nov 25 16:38:31 2015 +0200

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py                     |  5 +++++
 .../allura/tests/functional/test_site_admin.py  |  6 +++++
 Allura/allura/tests/test_delete_projects.py     | 23 ++++++++++++++++++++
 Allura/allura/tests/test_plugin.py              | 11 ++++++++++
 4 files changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5320d754/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index f100ad2..e061323 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -1073,6 +1073,11 @@ class ProjectRegistrationProvider(object):
         if not n:
             return None, u'Neighborhood not found'
         p = Project.query.get(neighborhood_id=n._id, shortname=url[1])
+        if len(url) > 2:
+            # Maybe subproject
+            subp = Project.query.get(neighborhood_id=n._id, shortname='{}/{}'.format(*url[1:3]))
+            if subp:
+                return (subp, None)
         return (p, u'Project not found' if p is None else None)
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/5320d754/Allura/allura/tests/functional/test_site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index 7f440c3..fd81965 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -646,6 +646,12 @@ class TestDeleteProjects(TestController):
         self.app.post('/nf/admin/delete_projects/really_delete', data)
         dp.post.assert_called_once_with('--disable-users p/test p/test2')
 
+    @patch('allura.controllers.site_admin.DeleteProjects', autospec=True)
+    def test_subproject_delete(self, dp):
+        data = {'projects': '/p/test/sub1/something\np/test2'}
+        self.app.post('/nf/admin/delete_projects/really_delete', data)
+        dp.post.assert_called_once_with('p/test/sub1 p/test2')
+
 
 @task
 def test_task(*args, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/5320d754/Allura/allura/tests/test_delete_projects.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_delete_projects.py b/Allura/allura/tests/test_delete_projects.py
index 6eab1fe..77915cf 100644
--- a/Allura/allura/tests/test_delete_projects.py
+++ b/Allura/allura/tests/test_delete_projects.py
@@ -18,6 +18,7 @@
 from ming.odm import session, Mapper, ThreadLocalODMSession
 from mock import patch
 from pylons import app_globals as g
+from nose.tools import assert_equal
 
 from alluratest.controller import TestController
 from allura.tests.decorators import audits, out_audits
@@ -70,6 +71,28 @@ class TestDeleteProjects(TestController):
         things = self.things_related_to_project(pid)
         assert len(things) == 0, 'Not all things are deleted: %s' % things
 
+    def test_subproject_is_deleted(self):
+        p = M.Project.query.get(shortname='test/sub1')
+        assert p is not None, 'Can not find subproject to delete'
+        self.run_script(['p/test/sub1'])
+        session(p).expunge(p)
+        p = M.Project.query.get(shortname='test/sub1')
+        assert p is None, 'Project is not deleted'
+        p = M.Project.query.get(shortname='test')
+        assert p is not None, 'Parent project should not be deleted'
+
+    def test_subproject_artifacts_are_deleted(self):
+        parent_pid = M.Project.query.get(shortname='test')._id
+        pid = M.Project.query.get(shortname='test/sub1')._id
+        things = self.things_related_to_project(pid)
+        assert len(things) > 0, 'No things related to subproject to begin with'
+        parent_things_before = self.things_related_to_project(parent_pid)
+        self.run_script(['p/test/sub1'])
+        things = self.things_related_to_project(pid)
+        assert len(things) == 0, 'Not all things are deleted: %s' % things
+        parent_things_after = self.things_related_to_project(parent_pid)
+        assert_equal(len(parent_things_before), len(parent_things_after))
+
     @patch('allura.lib.plugin.solr_del_project_artifacts', autospec=True)
     def test_solr_index_is_deleted(self, del_solr):
         pid = M.Project.query.get(shortname=self.p_shortname)._id

http://git-wip-us.apache.org/repos/asf/allura/blob/5320d754/Allura/allura/tests/test_plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
index b9ee17c..272ee35 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -132,6 +132,17 @@ class TestProjectRegistrationProviderParseProjectFromUrl(object):
         assert_equal((p, None), self.parse('test'))
         assert_equal((adobe, None), self.parse('adobe-1'))
 
+    def test_subproject(self):
+        p = M.Project.query.get(shortname='test/sub1')
+        assert_equal((p, None), self.parse('p/test/sub1'))
+        assert_equal((p, None), self.parse('p/test/sub1/something'))
+        assert_equal((p, None), self.parse('http://localhost:8080/p/test/sub1'))
+        assert_equal((p, None), self.parse('http://localhost:8080/p/test/sub1/something'))
+
+    def test_subproject_not_found(self):
+        p = M.Project.query.get(shortname='test')
+        assert_equal((p, None), self.parse('http://localhost:8080/p/test/not-a-sub'))
+
 
 class UserMock(object):
     def __init__(self):


Mime
View raw message