From 994729223d4149bdcb0edfee08581347e27602c3 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 15 2017 10:30:34 +0000 Subject: Unit test: write gitolite files when user is committer Signed-off-by: Vivek Anand --- diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index 6d16064..2fc9c84 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -369,6 +369,112 @@ repo requests/forks/pingou/test3 os.unlink(outputconf) self.assertFalse(os.path.exists(outputconf)) + def test_write_gitolite_acls_commit(self): + """ Test the write_gitolite_acls function of pagure.lib.git. + when the new uesr is just a committer """ + tests.create_projects(self.session) + + repo = pagure.lib.get_project(self.session, 'test') + # Add an user to a project + # The user will be an admin of the project + msg = pagure.lib.add_user_to_project( + session=self.session, + project=repo, + new_user='foo', + user='pingou', + access='commit' + ) + self.session.commit() + self.assertEqual(msg, 'User added') + # Add a forked project + item = pagure.lib.model.Project( + user_id=1, # pingou + name='test3', + description='test project #2', + is_fork=True, + parent_id=1, + hook_token='aaabbbvvv', + ) + self.session.add(item) + self.session.commit() + + outputconf = os.path.join(self.path, 'test_gitolite.conf') + + pagure.lib.git.write_gitolite_acls(self.session, outputconf) + + self.assertTrue(os.path.exists(outputconf)) + + with open(outputconf) as stream: + data = stream.read() + + exp = """ +repo test + R = @all + RW+ = pingou + RW+ = foo + +repo docs/test + R = @all + RW+ = pingou + RW+ = foo + +repo tickets/test + RW+ = pingou + RW+ = foo + +repo requests/test + RW+ = pingou + RW+ = foo + +repo test2 + R = @all + RW+ = pingou + +repo docs/test2 + R = @all + RW+ = pingou + +repo tickets/test2 + RW+ = pingou + +repo requests/test2 + RW+ = pingou + +repo somenamespace/test3 + R = @all + RW+ = pingou + +repo docs/somenamespace/test3 + R = @all + RW+ = pingou + +repo tickets/somenamespace/test3 + RW+ = pingou + +repo requests/somenamespace/test3 + RW+ = pingou + +repo forks/pingou/test3 + R = @all + RW+ = pingou + +repo docs/forks/pingou/test3 + R = @all + RW+ = pingou + +repo tickets/forks/pingou/test3 + RW+ = pingou + +repo requests/forks/pingou/test3 + RW+ = pingou + +""" + #print data + self.assertEqual(data, exp) + + os.unlink(outputconf) + self.assertFalse(os.path.exists(outputconf)) + def test_write_gitolite_acls_groups(self): """ Test the write_gitolite_acls function of pagure.lib.git with groups.