diff --git a/tests/__init__.py b/tests/__init__.py index 0d34759..383f21d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -132,7 +132,7 @@ class Modeltests(unittest.TestCase): """ Constructor. """ unittest.TestCase.__init__(self, method_name) self.session = None - self.path = tempfile.mkdtemp(prefix='pagure-tests') + self.path = None self.gitrepo = None self.gitrepos = None @@ -140,17 +140,10 @@ class Modeltests(unittest.TestCase): def setUp(self): """ Set up the environnment, ran before every tests. """ # Clean up eventual git repo left in the present folder. - for filename in os.listdir(HERE): - filename = os.path.join(HERE, filename) - if filename.endswith('.git') and os.path.isdir(filename): - shutil.rmtree(filename) - - for folder in ['tickets', 'repos', 'forks', 'docs', - 'requests' ,'releases']: - folder = os.path.join(HERE, folder) - if os.path.exists(folder): - shutil.rmtree(folder) - os.mkdir(folder) + self.path = tempfile.mkdtemp(prefix='pagure-tests') + for folder in ['tickets', 'repos', 'forks', 'docs', 'requests', + 'releases']: + os.mkdir(os.path.join(self.path, folder)) self.session = pagure.lib.model.create_tables( DB_PATH, acls=pagure.APP.config.get('ACLS', {})) diff --git a/tests/test_pagure_flask_api_issue.py b/tests/test_pagure_flask_api_issue.py index 60c20e1..201375a 100644 --- a/tests/test_pagure_flask_api_issue.py +++ b/tests/test_pagure_flask_api_issue.py @@ -47,7 +47,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): """ Test the api_new_issue method of the flask api. """ tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'tickets'), bare=True) + os.path.join(self.path, 'tickets'), bare=True) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) @@ -626,7 +626,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): def test_api_change_status_issue(self): """ Test the api_change_status_issue method of the flask api. """ tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE, 'tickets')) + tests.create_projects_git(os.path.join(self.path, 'tickets')) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index f061b04..dd3afe1 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -44,15 +44,15 @@ class PagureFlaskApiProjecttests(tests.Modeltests): pagure.api.project.SESSION = self.session pagure.lib.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = os.path.join(tests.HERE, 'repos') + pagure.APP.config['GIT_FOLDER'] = os.path.join(self.path, 'repos') pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() @@ -61,7 +61,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): tests.create_projects(self.session) # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') repo = pygit2.init_repository(gitrepo, bare=True) newpath = tempfile.mkdtemp(prefix='pagure-fork-test') @@ -239,7 +239,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): p_gga.return_value = True tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE, 'tickets')) + tests.create_projects_git(os.path.join(self.path, 'tickets')) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) @@ -325,7 +325,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): tests.create_projects(self.session) for folder in ['docs', 'tickets', 'requests', 'repos']: tests.create_projects_git( - os.path.join(tests.HERE, folder), bare=True) + os.path.join(self.path, folder), bare=True) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) diff --git a/tests/test_pagure_flask_docs.py b/tests/test_pagure_flask_docs.py index e537def..f359463 100644 --- a/tests/test_pagure_flask_docs.py +++ b/tests/test_pagure_flask_docs.py @@ -45,21 +45,21 @@ class PagureFlaskDocstests(tests.Modeltests): pagure.ui.app.SESSION = self.session pagure.ui.repo.SESSION = self.session - pagure.docs_server.APP.config['GIT_FOLDER'] = tests.HERE + pagure.docs_server.APP.config['GIT_FOLDER'] = self.path pagure.docs_server.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.docs_server.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.docs_server.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.docs_server.APP.test_client() def test_view_docs_no_project(self): @@ -96,7 +96,7 @@ class PagureFlaskDocstests(tests.Modeltests): """ tests.create_projects(self.session) repo = pagure.lib.get_project(self.session, 'test') - tests.create_projects_git(os.path.join(tests.HERE, 'docs')) + tests.create_projects_git(os.path.join(self.path, 'docs')) output = self.app.get('/test/docs') self.assertEqual(output.status_code, 404) @@ -112,13 +112,13 @@ class PagureFlaskDocstests(tests.Modeltests): """ Test the view_docs endpoint. """ tests.create_projects(self.session) repo = pygit2.init_repository( - os.path.join(tests.HERE, 'docs', 'test.git'), bare=True) + os.path.join(self.path, 'docs', 'test.git'), bare=True) output = self.app.get('/test/docs') self.assertEqual(output.status_code, 404) # forked doc repo - docrepo = os.path.join(tests.HERE, 'docs', 'test', 'test.git') + docrepo = os.path.join(self.path, 'docs', 'test', 'test.git') repo = pygit2.init_repository(docrepo) # Create files in that git repo @@ -153,7 +153,7 @@ class PagureFlaskDocstests(tests.Modeltests): # Push the changes to the bare repo remote = repo.create_remote( - 'origin', os.path.join(tests.HERE, 'docs', 'test.git')) + 'origin', os.path.join(self.path, 'docs', 'test.git')) PagureRepo.push(remote, 'refs/heads/master:refs/heads/master') diff --git a/tests/test_pagure_flask_dump_load_ticket.py b/tests/test_pagure_flask_dump_load_ticket.py index 7843c09..e2bc321 100644 --- a/tests/test_pagure_flask_dump_load_ticket.py +++ b/tests/test_pagure_flask_dump_load_ticket.py @@ -45,26 +45,26 @@ class PagureFlaskDumpLoadTicketTests(tests.Modeltests): pagure.ui.fork.SESSION = self.session pagure.ui.repo.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = os.path.join(tests.HERE, 'repos') - pagure.APP.config['FORK_FOLDER'] = os.path.join(tests.HERE, 'forks') + pagure.APP.config['GIT_FOLDER'] = os.path.join(self.path, 'repos') + pagure.APP.config['FORK_FOLDER'] = os.path.join(self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') self.app = pagure.APP.test_client() @patch('pagure.lib.notify.send_email') - def test_dumping_ticket(self, send_email): + def test_dumping_reloading_ticket(self, send_email): """ Test dumping a ticket into a JSON blob. """ send_email.return_value = True tests.create_projects(self.session) # Create repo - self.gitrepo = os.path.join(tests.HERE, 'tickets', 'test.git') - repopath = os.path.join(tests.HERE, 'tickets') + self.gitrepo = os.path.join(self.path, 'tickets', 'test.git') + repopath = os.path.join(self.path, 'tickets') os.makedirs(self.gitrepo) repo_obj = pygit2.init_repository(self.gitrepo, bare=True) @@ -183,27 +183,22 @@ class PagureFlaskDumpLoadTicketTests(tests.Modeltests): self.assertEqual(len(os.listdir(newpath)), 4) - ticket_json = os.path.join(tests.HERE, 'test_ticket.json') + ticket_json = os.path.join(self.path, 'test_ticket.json') self.assertFalse(os.path.exists(ticket_json)) shutil.copyfile(os.path.join(newpath, fileid), ticket_json) self.assertTrue(os.path.exists(ticket_json)) - - shutil.rmtree(newpath) - - @patch('pagure.lib.notify.send_email') - def test_reload_ticket(self, send_email): - """ Test reloading a ticket from a JSON blob. """ - send_email.return_value = True - ticket_json = os.path.join(tests.HERE, 'test_ticket.json') - self.assertTrue(os.path.exists(ticket_json)) - - tests.create_projects(self.session) - jsondata = None with open(ticket_json) as stream: jsondata = json.load(stream) self.assertNotEqual(jsondata, None) + shutil.rmtree(newpath) + + # Test reloading the JSON + self.tearDown() + self.setUp() + tests.create_projects(self.session) + pagure.lib.git.update_ticket_from_git( self.session, reponame='test', @@ -226,10 +221,6 @@ class PagureFlaskDumpLoadTicketTests(tests.Modeltests): self.assertEqual(issue.children, []) self.assertEqual(issue.parents, []) - self.assertTrue(os.path.exists(ticket_json)) - os.unlink(ticket_json) - self.assertFalse(os.path.exists(ticket_json)) - if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase( diff --git a/tests/test_pagure_flask_internal.py b/tests/test_pagure_flask_internal.py index 86963cc..7a6027d 100644 --- a/tests/test_pagure_flask_internal.py +++ b/tests/test_pagure_flask_internal.py @@ -42,9 +42,9 @@ class PagureFlaskInternaltests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['REQUESTS_FOLDER'] = None pagure.APP.config['TICKETS_FOLDER'] = None pagure.APP.config['DOCS_FOLDER'] = None @@ -296,7 +296,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'test.git') + gitrepo = os.path.join(self.path, 'test.git') self.assertFalse(os.path.exists(gitrepo)) os.makedirs(gitrepo) repo = pygit2.init_repository(gitrepo) @@ -418,7 +418,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'test.git') + gitrepo = os.path.join(self.path, 'test.git') self.assertFalse(os.path.exists(gitrepo)) os.makedirs(gitrepo) repo = pygit2.init_repository(gitrepo) @@ -540,7 +540,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'test.git') + gitrepo = os.path.join(self.path, 'test.git') self.assertFalse(os.path.exists(gitrepo)) os.makedirs(gitrepo) repo = pygit2.init_repository(gitrepo) @@ -681,7 +681,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'test.git') + gitrepo = os.path.join(self.path, 'test.git') self.assertFalse(os.path.exists(gitrepo)) os.makedirs(gitrepo) repo = pygit2.init_repository(gitrepo) @@ -816,7 +816,7 @@ class PagureFlaskInternaltests(tests.Modeltests): def test_get_branches_of_commit(self): ''' Test the get_branches_of_commit from the internal API. ''' tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser() user.username = 'pingou' @@ -897,7 +897,7 @@ class PagureFlaskInternaltests(tests.Modeltests): ) # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'test.git') + gitrepo = os.path.join(self.path, 'test.git') self.assertTrue(os.path.exists(gitrepo)) repo = pygit2.Repository(gitrepo) diff --git a/tests/test_pagure_flask_ui_admin.py b/tests/test_pagure_flask_ui_admin.py index 5c55c21..6063814 100644 --- a/tests/test_pagure_flask_ui_admin.py +++ b/tests/test_pagure_flask_ui_admin.py @@ -42,13 +42,13 @@ class PagureFlaskAdmintests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.admin.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_admin_index(self): diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index 3293c99..75d7423 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -41,15 +41,15 @@ class PagureFlaskApptests(tests.Modeltests): pagure.ui.filters.SESSION = self.session pagure.ui.repo.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') self.app = pagure.APP.test_client() def test_index(self): @@ -173,13 +173,13 @@ class PagureFlaskApptests(tests.Modeltests): projects = pagure.lib.search_projects(self.session) self.assertEqual(len(projects), 0) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'project-1.git'))) + os.path.join(self.path, 'project-1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'tickets', 'project-1.git'))) + os.path.join(self.path, 'tickets', 'project-1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'docs', 'project-1.git'))) + os.path.join(self.path, 'docs', 'project-1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'requests', 'project-1.git'))) + os.path.join(self.path, 'requests', 'project-1.git'))) user = tests.FakeUser() with tests.user_set(pagure.APP, user): @@ -209,13 +209,13 @@ class PagureFlaskApptests(tests.Modeltests): projects = pagure.lib.search_projects(self.session) self.assertEqual(len(projects), 0) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'project-1.git'))) + os.path.join(self.path, 'project-1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'tickets', 'project-1.git'))) + os.path.join(self.path, 'tickets', 'project-1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'docs', 'project-1.git'))) + os.path.join(self.path, 'docs', 'project-1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'requests', 'project-1.git'))) + os.path.join(self.path, 'requests', 'project-1.git'))) pagure.APP.config['ENABLE_NEW_PROJECTS'] = True @@ -225,13 +225,13 @@ class PagureFlaskApptests(tests.Modeltests): projects = pagure.lib.search_projects(self.session) self.assertEqual(len(projects), 0) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'project#1.git'))) + os.path.join(self.path, 'project#1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'tickets', 'project#1.git'))) + os.path.join(self.path, 'tickets', 'project#1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'docs', 'project#1.git'))) + os.path.join(self.path, 'docs', 'project#1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'requests', 'project#1.git'))) + os.path.join(self.path, 'requests', 'project#1.git'))) user = tests.FakeUser() with tests.user_set(pagure.APP, user): @@ -288,13 +288,13 @@ class PagureFlaskApptests(tests.Modeltests): projects = pagure.lib.search_projects(self.session) self.assertEqual(len(projects), 1) self.assertTrue(os.path.exists( - os.path.join(tests.HERE, 'project-1.git'))) + os.path.join(self.path, 'project-1.git'))) self.assertTrue(os.path.exists( - os.path.join(tests.HERE, 'tickets', 'project-1.git'))) + os.path.join(self.path, 'tickets', 'project-1.git'))) self.assertTrue(os.path.exists( - os.path.join(tests.HERE, 'docs', 'project-1.git'))) + os.path.join(self.path, 'docs', 'project-1.git'))) self.assertTrue(os.path.exists( - os.path.join(tests.HERE, 'requests', 'project-1.git'))) + os.path.join(self.path, 'requests', 'project-1.git'))) def test_non_ascii_new_project(self): """ Test the new_project endpoint with a non-ascii project. """ @@ -302,13 +302,13 @@ class PagureFlaskApptests(tests.Modeltests): projects = pagure.lib.search_projects(self.session) self.assertEqual(len(projects), 0) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'project-1.git'))) + os.path.join(self.path, 'project-1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'tickets', 'project-1.git'))) + os.path.join(self.path, 'tickets', 'project-1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'docs', 'project-1.git'))) + os.path.join(self.path, 'docs', 'project-1.git'))) self.assertFalse(os.path.exists( - os.path.join(tests.HERE, 'requests', 'project-1.git'))) + os.path.join(self.path, 'requests', 'project-1.git'))) user = tests.FakeUser() user.username = 'foo' @@ -360,13 +360,13 @@ class PagureFlaskApptests(tests.Modeltests): self.assertEqual(len(projects), 2) for project in ['project-1', 'project-2']: self.assertTrue(os.path.exists( - os.path.join(tests.HERE, '%s.git' % project))) + os.path.join(self.path, '%s.git' % project))) self.assertTrue(os.path.exists( - os.path.join(tests.HERE, 'tickets', '%s.git' % project))) + os.path.join(self.path, 'tickets', '%s.git' % project))) self.assertTrue(os.path.exists( - os.path.join(tests.HERE, 'docs', '%s.git' % project))) + os.path.join(self.path, 'docs', '%s.git' % project))) self.assertTrue(os.path.exists( - os.path.join(tests.HERE, 'requests', '%s.git' % project))) + os.path.join(self.path, 'requests', '%s.git' % project))) @patch('pagure.ui.app.admin_session_timedout') def test_user_settings(self, ast): diff --git a/tests/test_pagure_flask_ui_fork.py b/tests/test_pagure_flask_ui_fork.py index f73ec64..01ac157 100644 --- a/tests/test_pagure_flask_ui_fork.py +++ b/tests/test_pagure_flask_ui_fork.py @@ -65,13 +65,13 @@ class PagureFlaskForktests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.issues.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = os.path.join(tests.HERE, 'repos') + pagure.APP.config['GIT_FOLDER'] = os.path.join(self.path, 'repos') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') self.app = pagure.APP.test_client() def set_up_git_repo( @@ -81,7 +81,7 @@ class PagureFlaskForktests(tests.Modeltests): """ # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') repo = pygit2.init_repository(gitrepo, bare=True) newpath = tempfile.mkdtemp(prefix='pagure-fork-test') @@ -230,7 +230,7 @@ class PagureFlaskForktests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) # Non-existant project output = self.app.get('/foobar/pull-request/1') @@ -420,7 +420,7 @@ class PagureFlaskForktests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) self.set_up_git_repo( new_project=None, branch_from='feature', mtype='merge') @@ -460,7 +460,7 @@ class PagureFlaskForktests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) self.set_up_git_repo( new_project=None, branch_from='feature', mtype='conflicts') @@ -496,7 +496,7 @@ class PagureFlaskForktests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) self.set_up_git_repo( new_project=None, branch_from='master', mtype='nochanges') @@ -554,7 +554,7 @@ class PagureFlaskForktests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) self.set_up_git_repo(new_project=None, branch_from='feature') # Project w/o pull-request @@ -586,19 +586,19 @@ class PagureFlaskForktests(tests.Modeltests): self.session.commit() tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) tests.create_projects_git( - os.path.join(tests.HERE, 'repos', 'forks', 'foo'), bare=True) + os.path.join(self.path, 'repos', 'forks', 'foo'), bare=True) # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') self.assertFalse(os.path.exists(gitrepo)) os.makedirs(gitrepo) repo = pygit2.init_repository(gitrepo, bare=True) # Create a fork of this repo newpath = tempfile.mkdtemp(prefix='pagure-fork-test') - gitrepo = os.path.join(tests.HERE, 'repos', 'forks', 'foo', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'forks', 'foo', 'test.git') new_repo = pygit2.clone_repository(gitrepo, newpath) # Edit the sources file again @@ -670,12 +670,12 @@ class PagureFlaskForktests(tests.Modeltests): self.session.commit() tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) tests.create_projects_git( - os.path.join(tests.HERE, 'repos', 'forks', 'foo'), bare=True) + os.path.join(self.path, 'repos', 'forks', 'foo'), bare=True) # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') self.assertFalse(os.path.exists(gitrepo)) os.makedirs(gitrepo) repo = pygit2.init_repository(gitrepo, bare=True) @@ -683,7 +683,7 @@ class PagureFlaskForktests(tests.Modeltests): # Create a fork of this repo newpath = tempfile.mkdtemp(prefix='pagure-fork-test') gitrepo = os.path.join( - tests.HERE, 'repos', 'forks', 'foo', 'test.git') + self.path, 'repos', 'forks', 'foo', 'test.git') new_repo = pygit2.clone_repository(gitrepo, newpath) # Create a PR for these "changes" (there are none, both repos are @@ -725,7 +725,7 @@ class PagureFlaskForktests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'repos'), bare=True) + os.path.join(self.path, 'repos'), bare=True) output = self.app.get('/test/pull-requests') self.assertEqual(output.status_code, 200) @@ -802,7 +802,7 @@ class PagureFlaskForktests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) self.set_up_git_repo( new_project=None, branch_from='feature', mtype='merge') @@ -927,12 +927,12 @@ index 9f44358..2a552bb 100644 self.session.commit() tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) tests.create_projects_git( - os.path.join(tests.HERE, 'repos', 'forks', 'foo'), bare=True) + os.path.join(self.path, 'repos', 'forks', 'foo'), bare=True) # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') self.assertFalse(os.path.exists(gitrepo)) os.makedirs(gitrepo) repo = pygit2.init_repository(gitrepo, bare=True) @@ -940,7 +940,7 @@ index 9f44358..2a552bb 100644 # Create a fork of this repo newpath = tempfile.mkdtemp(prefix='pagure-fork-test') gitrepo = os.path.join( - tests.HERE, 'repos', 'forks', 'foo', 'test.git') + self.path, 'repos', 'forks', 'foo', 'test.git') new_repo = pygit2.clone_repository(gitrepo, newpath) # Edit the sources file again @@ -1042,12 +1042,12 @@ index 0000000..2a552bb self.session.commit() tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) tests.create_projects_git( - os.path.join(tests.HERE, 'repos', 'forks', 'foo'), bare=True) + os.path.join(self.path, 'repos', 'forks', 'foo'), bare=True) # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') self.assertFalse(os.path.exists(gitrepo)) os.makedirs(gitrepo) repo = pygit2.init_repository(gitrepo, bare=True) @@ -1055,7 +1055,7 @@ index 0000000..2a552bb # Create a fork of this repo newpath = tempfile.mkdtemp(prefix='pagure-fork-test') gitrepo = os.path.join( - tests.HERE, 'repos', 'forks', 'foo', 'test.git') + self.path, 'repos', 'forks', 'foo', 'test.git') new_repo = pygit2.clone_repository(gitrepo, newpath) # Create a PR for these "changes" (there are none, both repos are @@ -1093,7 +1093,7 @@ index 0000000..2a552bb tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) self.set_up_git_repo( new_project=None, branch_from='feature', mtype='merge') @@ -1174,7 +1174,7 @@ index 0000000..2a552bb tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) self.set_up_git_repo(new_project=None, branch_from='feature') user = tests.FakeUser() @@ -1309,7 +1309,7 @@ index 0000000..2a552bb tests.create_projects(self.session) for folder in ['docs', 'tickets', 'requests', 'repos']: tests.create_projects_git( - os.path.join(tests.HERE, folder), bare=True) + os.path.join(self.path, folder), bare=True) user = tests.FakeUser() user.username = 'pingou' @@ -1356,7 +1356,7 @@ index 0000000..2a552bb self.test_fork_project() tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) repo = pagure.lib.get_project(self.session, 'test') fork = pagure.lib.get_project(self.session, 'test', user='foo') @@ -1446,18 +1446,18 @@ index 0000000..2a552bb self.test_fork_project() tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) repo = pagure.lib.get_project(self.session, 'test') fork = pagure.lib.get_project(self.session, 'test', user='foo') # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') repo = pygit2.init_repository(gitrepo, bare=True) # Create a fork of this repo newpath = tempfile.mkdtemp(prefix='pagure-fork-test') - gitrepo = os.path.join(tests.HERE, 'repos', 'forks', 'foo', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'forks', 'foo', 'test.git') new_repo = pygit2.clone_repository(gitrepo, newpath) user = tests.FakeUser() @@ -1501,19 +1501,19 @@ index 0000000..2a552bb self.test_fork_project() tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) repo = pagure.lib.get_project(self.session, 'test') fork = pagure.lib.get_project(self.session, 'test', user='foo') # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') repo = pygit2.init_repository(gitrepo, bare=True) # Create a fork of this repo newpath = tempfile.mkdtemp(prefix='pagure-fork-test') gitrepo = os.path.join( - tests.HERE, 'repos', 'forks', 'foo', 'test.git') + self.path, 'repos', 'forks', 'foo', 'test.git') new_repo = pygit2.clone_repository(gitrepo, newpath) user = tests.FakeUser() @@ -1861,7 +1861,7 @@ index 0000000..2a552bb tests.create_projects(self.session) for folder in ['docs', 'tickets', 'requests', 'repos']: tests.create_projects_git( - os.path.join(tests.HERE, folder), bare=True) + os.path.join(self.path, folder), bare=True) # User not logged in output = self.app.post('fork_edit/test/edit/master/f/sources') @@ -2008,17 +2008,17 @@ index 0000000..2a552bb self.session.commit() tests.create_projects_git( - os.path.join(tests.HERE, 'repos', 'forks', 'foo'), bare=True) + os.path.join(self.path, 'repos', 'forks', 'foo'), bare=True) # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') self.assertFalse(os.path.exists(gitrepo)) os.makedirs(gitrepo) repo = pygit2.init_repository(gitrepo, bare=True) # Create a fork of this repo newpath = tempfile.mkdtemp(prefix='pagure-fork-test') - gitrepo = os.path.join(tests.HERE, 'repos', 'forks', 'foo', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'forks', 'foo', 'test.git') new_repo = pygit2.clone_repository(gitrepo, newpath) tests.add_content_git_repo(gitrepo) diff --git a/tests/test_pagure_flask_ui_groups.py b/tests/test_pagure_flask_ui_groups.py index 8f11da5..8efd9b2 100644 --- a/tests/test_pagure_flask_ui_groups.py +++ b/tests/test_pagure_flask_ui_groups.py @@ -40,15 +40,15 @@ class PagureFlaskGroupstests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') self.app = pagure.APP.test_client() def test_group_lists(self): diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index 51261d7..f5c02fc 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -51,13 +51,13 @@ class PagureFlaskIssuestests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() @patch('pagure.lib.git.update_git') @@ -78,7 +78,7 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) output = self.app.get('/test/new_issue') self.assertEqual(output.status_code, 200) @@ -167,9 +167,9 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) tests.create_projects_git( - os.path.join(tests.HERE, 'tickets'), bare=True) + os.path.join(self.path, 'tickets'), bare=True) user = tests.FakeUser() user.username = 'pingou' @@ -240,7 +240,7 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) output = self.app.get('/test/issues') self.assertEqual(output.status_code, 200) @@ -349,7 +349,7 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) output = self.app.get('/test/issue/1') self.assertEqual(output.status_code, 404) @@ -474,7 +474,7 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) output = self.app.get('/test/issue/1/update') self.assertEqual(output.status_code, 302) @@ -776,7 +776,7 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) # Create issues to play with repo = pagure.lib.get_project(self.session, 'test') @@ -886,7 +886,7 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) # Create issues to play with repo = pagure.lib.get_project(self.session, 'test') @@ -979,7 +979,7 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) # Create issues to play with repo = pagure.lib.get_project(self.session, 'test') @@ -1074,9 +1074,9 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) tests.create_projects_git( - os.path.join(tests.HERE, 'tickets'), bare=True) + os.path.join(self.path, 'tickets'), bare=True) # Create issues to play with repo = pagure.lib.get_project(self.session, 'test') @@ -1183,7 +1183,7 @@ class PagureFlaskIssuestests(tests.Modeltests): # Create the project and git repos tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE, 'tickets'), bare=True) + os.path.join(self.path, 'tickets'), bare=True) # Create issues to play with repo = pagure.lib.get_project(self.session, 'test') @@ -1271,7 +1271,7 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) output = self.app.get('/test/issue/1/edit') self.assertEqual(output.status_code, 404) @@ -1389,7 +1389,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.get('/test/tag/foo/edit') self.assertEqual(output.status_code, 403) @@ -1483,7 +1483,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.post('/test/droptag/') self.assertEqual(output.status_code, 403) @@ -1557,8 +1557,8 @@ class PagureFlaskIssuestests(tests.Modeltests): p_ugt.return_value = True tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) - tests.create_projects_git(os.path.join(tests.HERE, 'tickets')) + tests.create_projects_git(self.path) + tests.create_projects_git(os.path.join(self.path, 'tickets')) # Create issues to play with repo = pagure.lib.get_project(self.session, 'test') @@ -1640,7 +1640,7 @@ class PagureFlaskIssuestests(tests.Modeltests): tests.create_projects(self.session) tests.create_projects_git( - os.path.join(tests.HERE), bare=True) + os.path.join(self.path), bare=True) # Create issues to play with repo = pagure.lib.get_project(self.session, 'test') diff --git a/tests/test_pagure_flask_ui_no_master_branch.py b/tests/test_pagure_flask_ui_no_master_branch.py index 0996825..053cf04 100644 --- a/tests/test_pagure_flask_ui_no_master_branch.py +++ b/tests/test_pagure_flask_ui_no_master_branch.py @@ -45,21 +45,21 @@ class PagureFlaskNoMasterBranchtests(tests.Modeltests): pagure.ui.fork.SESSION = self.session pagure.ui.repo.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = os.path.join(tests.HERE, 'repos') - pagure.APP.config['FORK_FOLDER'] = os.path.join(tests.HERE, 'forks') + pagure.APP.config['GIT_FOLDER'] = os.path.join(self.path, 'repos') + pagure.APP.config['FORK_FOLDER'] = os.path.join(self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') self.app = pagure.APP.test_client() def set_up_git_repo(self): """ Set up the git repo to play with. """ # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') repo = pygit2.init_repository(gitrepo, bare=True) newpath = tempfile.mkdtemp(prefix='pagure-other-test') diff --git a/tests/test_pagure_flask_ui_plugins.py b/tests/test_pagure_flask_ui_plugins.py index 0d0a071..4c2e2aa 100644 --- a/tests/test_pagure_flask_ui_plugins.py +++ b/tests/test_pagure_flask_ui_plugins.py @@ -55,13 +55,13 @@ class PagureFlaskPluginstests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_get_plugin_names(self): @@ -94,7 +94,7 @@ class PagureFlaskPluginstests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.get('/test/settings/Mail') self.assertEqual(output.status_code, 403) diff --git a/tests/test_pagure_flask_ui_plugins_fedmsg.py b/tests/test_pagure_flask_ui_plugins_fedmsg.py index 7da5451..43120c5 100644 --- a/tests/test_pagure_flask_ui_plugins_fedmsg.py +++ b/tests/test_pagure_flask_ui_plugins_fedmsg.py @@ -42,20 +42,20 @@ class PagureFlaskPluginFedmsgtests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_fedmsg(self): """ Test the fedmsg plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): @@ -85,7 +85,7 @@ class PagureFlaskPluginFedmsgtests(tests.Modeltests): in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.fedmsg'))) + self.path, 'test.git', 'hooks', 'post-receive.fedmsg'))) data['csrf_token'] = csrf_token @@ -109,7 +109,7 @@ class PagureFlaskPluginFedmsgtests(tests.Modeltests): output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.fedmsg'))) + self.path, 'test.git', 'hooks', 'post-receive.fedmsg'))) # Activate hook data = { @@ -137,7 +137,7 @@ class PagureFlaskPluginFedmsgtests(tests.Modeltests): 'value="y">' in output.data) self.assertTrue(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.fedmsg'))) + self.path, 'test.git', 'hooks', 'post-receive.fedmsg'))) # De-Activate hook data = {'csrf_token': csrf_token} @@ -161,7 +161,7 @@ class PagureFlaskPluginFedmsgtests(tests.Modeltests): 'value="y">' in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.fedmsg'))) + self.path, 'test.git', 'hooks', 'post-receive.fedmsg'))) if __name__ == '__main__': diff --git a/tests/test_pagure_flask_ui_plugins_irc.py b/tests/test_pagure_flask_ui_plugins_irc.py index 0e74120..3da8dc6 100644 --- a/tests/test_pagure_flask_ui_plugins_irc.py +++ b/tests/test_pagure_flask_ui_plugins_irc.py @@ -42,20 +42,20 @@ class PagureFlaskPluginIRCtests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_mail(self): """ Test the irc plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): @@ -85,7 +85,7 @@ class PagureFlaskPluginIRCtests(tests.Modeltests): in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.irc'))) + self.path, 'test.git', 'hooks', 'post-receive.irc'))) data['csrf_token'] = csrf_token @@ -110,7 +110,7 @@ class PagureFlaskPluginIRCtests(tests.Modeltests): in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.irc'))) + self.path, 'test.git', 'hooks', 'post-receive.irc'))) # Activate hook data = { @@ -142,7 +142,7 @@ class PagureFlaskPluginIRCtests(tests.Modeltests): # TODO: Fix this #self.assertTrue(os.path.exists(os.path.join( - #tests.HERE, 'test.git', 'hooks', 'post-receive.irc'))) + #self.path, 'test.git', 'hooks', 'post-receive.irc'))) # De-Activate hook data = {'csrf_token': csrf_token} @@ -165,7 +165,7 @@ class PagureFlaskPluginIRCtests(tests.Modeltests): 'value="y">' in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.irc'))) + self.path, 'test.git', 'hooks', 'post-receive.irc'))) if __name__ == '__main__': diff --git a/tests/test_pagure_flask_ui_plugins_mail.py b/tests/test_pagure_flask_ui_plugins_mail.py index 55c2f88..16610bb 100644 --- a/tests/test_pagure_flask_ui_plugins_mail.py +++ b/tests/test_pagure_flask_ui_plugins_mail.py @@ -42,20 +42,20 @@ class PagureFlaskPluginMailtests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_mail(self): """ Test the mail plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): @@ -116,7 +116,7 @@ class PagureFlaskPluginMailtests(tests.Modeltests): in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.mail'))) + self.path, 'test.git', 'hooks', 'post-receive.mail'))) # Missing the required mail_to data = {'csrf_token': csrf_token, 'active': 'y'} @@ -139,7 +139,7 @@ class PagureFlaskPluginMailtests(tests.Modeltests): 'value="y">' in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.mail'))) + self.path, 'test.git', 'hooks', 'post-receive.mail'))) # Activate hook data = { @@ -170,7 +170,7 @@ class PagureFlaskPluginMailtests(tests.Modeltests): 'value="y">' in output.data) self.assertTrue(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.mail'))) + self.path, 'test.git', 'hooks', 'post-receive.mail'))) # De-Activate hook data = {'csrf_token': csrf_token} @@ -196,7 +196,7 @@ class PagureFlaskPluginMailtests(tests.Modeltests): 'value="y">' in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.mail'))) + self.path, 'test.git', 'hooks', 'post-receive.mail'))) if __name__ == '__main__': diff --git a/tests/test_pagure_flask_ui_plugins_noff.py b/tests/test_pagure_flask_ui_plugins_noff.py index c2db1f5..8590275 100644 --- a/tests/test_pagure_flask_ui_plugins_noff.py +++ b/tests/test_pagure_flask_ui_plugins_noff.py @@ -42,20 +42,20 @@ class PagureFlaskPluginNoFFtests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_noff(self): """ Test the noff plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): @@ -127,7 +127,7 @@ class PagureFlaskPluginNoFFtests(tests.Modeltests): in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.mail'))) + self.path, 'test.git', 'hooks', 'post-receive.mail'))) # Missing the required mail_to data = {'csrf_token': csrf_token, 'active': 'y'} @@ -153,7 +153,7 @@ class PagureFlaskPluginNoFFtests(tests.Modeltests): 'value="y">' in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', + self.path, 'test.git', 'hooks', 'pre-receive.pagureforcecommit'))) # Activate hook @@ -190,7 +190,7 @@ class PagureFlaskPluginNoFFtests(tests.Modeltests): 'value="y">', output.data) self.assertTrue(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', + self.path, 'test.git', 'hooks', 'pre-receive.pagureforcecommit'))) # De-Activate hook @@ -222,7 +222,7 @@ class PagureFlaskPluginNoFFtests(tests.Modeltests): 'value="y">', output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', + self.path, 'test.git', 'hooks', 'pre-receive.pagureforcecommit'))) diff --git a/tests/test_pagure_flask_ui_plugins_pagure_ci.py b/tests/test_pagure_flask_ui_plugins_pagure_ci.py index 648e0c3..8f3894f 100644 --- a/tests/test_pagure_flask_ui_plugins_pagure_ci.py +++ b/tests/test_pagure_flask_ui_plugins_pagure_ci.py @@ -34,20 +34,20 @@ class PagureFlaskPluginPagureCItests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_pagure_ci(self): """ Test the pagure ci plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): diff --git a/tests/test_pagure_flask_ui_plugins_pagure_hook.py b/tests/test_pagure_flask_ui_plugins_pagure_hook.py index 712a098..ea3fd1d 100644 --- a/tests/test_pagure_flask_ui_plugins_pagure_hook.py +++ b/tests/test_pagure_flask_ui_plugins_pagure_hook.py @@ -42,22 +42,22 @@ class PagureFlaskPluginPagureHooktests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_mail(self): """ Test the pagure hook plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): @@ -88,8 +88,8 @@ class PagureFlaskPluginPagureHooktests(tests.Modeltests): data['csrf_token'] = csrf_token - tests.create_projects_git(os.path.join(tests.HERE, 'docs')) - tests.create_projects_git(os.path.join(tests.HERE, 'requests')) + tests.create_projects_git(os.path.join(self.path, 'docs')) + tests.create_projects_git(os.path.join(self.path, 'requests')) # With the git repo output = self.app.post( @@ -113,7 +113,7 @@ class PagureFlaskPluginPagureHooktests(tests.Modeltests): in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.pagure'))) + self.path, 'test.git', 'hooks', 'post-receive.pagure'))) # Activate hook data = { @@ -142,7 +142,7 @@ class PagureFlaskPluginPagureHooktests(tests.Modeltests): 'value="y">' in output.data) self.assertTrue(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.pagure'))) + self.path, 'test.git', 'hooks', 'post-receive.pagure'))) # De-Activate hook data = {'csrf_token': csrf_token} @@ -167,7 +167,7 @@ class PagureFlaskPluginPagureHooktests(tests.Modeltests): 'value="y">' in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', 'post-receive.pagure'))) + self.path, 'test.git', 'hooks', 'post-receive.pagure'))) if __name__ == '__main__': diff --git a/tests/test_pagure_flask_ui_plugins_pagure_request_hook.py b/tests/test_pagure_flask_ui_plugins_pagure_request_hook.py index b564347..829e5ee 100644 --- a/tests/test_pagure_flask_ui_plugins_pagure_request_hook.py +++ b/tests/test_pagure_flask_ui_plugins_pagure_request_hook.py @@ -42,20 +42,20 @@ class PagureFlaskPluginPagureRequestHooktests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_pagure_request(self): """ Test the pagure_request plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): @@ -87,7 +87,7 @@ class PagureFlaskPluginPagureRequestHooktests(tests.Modeltests): data['csrf_token'] = csrf_token # Create the requests repo - tests.create_projects_git(os.path.join(tests.HERE, 'requests')) + tests.create_projects_git(os.path.join(self.path, 'requests')) output = self.app.post( '/test/settings/Pagure requests', data=data, @@ -111,7 +111,7 @@ class PagureFlaskPluginPagureRequestHooktests(tests.Modeltests): in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'requests', 'test.git', 'hooks', + self.path, 'requests', 'test.git', 'hooks', 'post-receive.pagure'))) # Activate hook @@ -142,7 +142,7 @@ class PagureFlaskPluginPagureRequestHooktests(tests.Modeltests): 'value="y">' in output.data) self.assertTrue(os.path.exists(os.path.join( - tests.HERE, 'requests', 'test.git', 'hooks', + self.path, 'requests', 'test.git', 'hooks', 'post-receive.pagure-requests'))) # De-Activate hook @@ -169,7 +169,7 @@ class PagureFlaskPluginPagureRequestHooktests(tests.Modeltests): 'value="y">' in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'requests', 'test.git', 'hooks', + self.path, 'requests', 'test.git', 'hooks', 'post-receive.pagure-requests'))) # Try re-activate hook w/o the git repo @@ -177,7 +177,7 @@ class PagureFlaskPluginPagureRequestHooktests(tests.Modeltests): 'csrf_token': csrf_token, 'active': 'y', } - shutil.rmtree(os.path.join(tests.HERE, 'requests', 'test.git')) + shutil.rmtree(os.path.join(self.path, 'requests', 'test.git')) output = self.app.post('/test/settings/Pagure requests', data=data) self.assertEqual(output.status_code, 404) diff --git a/tests/test_pagure_flask_ui_plugins_pagure_ticket_hook.py b/tests/test_pagure_flask_ui_plugins_pagure_ticket_hook.py index 4e13a84..017def4 100644 --- a/tests/test_pagure_flask_ui_plugins_pagure_ticket_hook.py +++ b/tests/test_pagure_flask_ui_plugins_pagure_ticket_hook.py @@ -42,20 +42,20 @@ class PagureFlaskPluginPagureTicketHooktests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_pagure_ticket(self): """ Test the pagure_ticket plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): @@ -87,7 +87,7 @@ class PagureFlaskPluginPagureTicketHooktests(tests.Modeltests): data['csrf_token'] = csrf_token # Create the tickets repo - tests.create_projects_git(os.path.join(tests.HERE, 'tickets')) + tests.create_projects_git(os.path.join(self.path, 'tickets')) output = self.app.post( '/test/settings/Pagure tickets', data=data, @@ -111,7 +111,7 @@ class PagureFlaskPluginPagureTicketHooktests(tests.Modeltests): in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'tickets', 'test.git', 'hooks', + self.path, 'tickets', 'test.git', 'hooks', 'post-receive.pagure'))) # Activate hook @@ -142,7 +142,7 @@ class PagureFlaskPluginPagureTicketHooktests(tests.Modeltests): 'value="y">' in output.data) self.assertTrue(os.path.exists(os.path.join( - tests.HERE, 'tickets', 'test.git', 'hooks', + self.path, 'tickets', 'test.git', 'hooks', 'post-receive.pagure-ticket'))) # De-Activate hook @@ -169,7 +169,7 @@ class PagureFlaskPluginPagureTicketHooktests(tests.Modeltests): 'value="y">' in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'tickets', 'test.git', 'hooks', + self.path, 'tickets', 'test.git', 'hooks', 'post-receive.pagure-ticket'))) # Try re-activate hook w/o the git repo @@ -177,7 +177,7 @@ class PagureFlaskPluginPagureTicketHooktests(tests.Modeltests): 'csrf_token': csrf_token, 'active': 'y', } - shutil.rmtree(os.path.join(tests.HERE, 'tickets', 'test.git')) + shutil.rmtree(os.path.join(self.path, 'tickets', 'test.git')) output = self.app.post('/test/settings/Pagure tickets', data=data) self.assertEqual(output.status_code, 404) diff --git a/tests/test_pagure_flask_ui_plugins_rtd_hook.py b/tests/test_pagure_flask_ui_plugins_rtd_hook.py index 8efefbc..759403a 100644 --- a/tests/test_pagure_flask_ui_plugins_rtd_hook.py +++ b/tests/test_pagure_flask_ui_plugins_rtd_hook.py @@ -42,20 +42,20 @@ class PagureFlaskPluginRtdHooktests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_pagure_request(self): """ Test the pagure_request plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): @@ -87,7 +87,7 @@ class PagureFlaskPluginRtdHooktests(tests.Modeltests): data['csrf_token'] = csrf_token # Create the requests repo - tests.create_projects_git(os.path.join(tests.HERE, 'requests')) + tests.create_projects_git(os.path.join(self.path, 'requests')) output = self.app.post( '/test/settings/Read the Doc', data=data, @@ -111,7 +111,7 @@ class PagureFlaskPluginRtdHooktests(tests.Modeltests): output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'requests', 'test.git', 'hooks', + self.path, 'requests', 'test.git', 'hooks', 'post-receive.pagure'))) # Activate hook @@ -143,7 +143,7 @@ class PagureFlaskPluginRtdHooktests(tests.Modeltests): 'value="y">', output.data) self.assertTrue(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', + self.path, 'test.git', 'hooks', 'post-receive.rtd'))) # De-Activate hook @@ -170,7 +170,7 @@ class PagureFlaskPluginRtdHooktests(tests.Modeltests): 'value="y">', output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', + self.path, 'test.git', 'hooks', 'post-receive.rtd'))) # Try re-activate hook w/o the git repo @@ -179,7 +179,7 @@ class PagureFlaskPluginRtdHooktests(tests.Modeltests): 'active': 'y', 'project_name': 'foo', } - shutil.rmtree(os.path.join(tests.HERE, 'test.git')) + shutil.rmtree(os.path.join(self.path, 'test.git')) output = self.app.post('/test/settings/Read the Doc', data=data) self.assertEqual(output.status_code, 404) diff --git a/tests/test_pagure_flask_ui_plugins_unsigned.py b/tests/test_pagure_flask_ui_plugins_unsigned.py index 009689a..2cda6e3 100644 --- a/tests/test_pagure_flask_ui_plugins_unsigned.py +++ b/tests/test_pagure_flask_ui_plugins_unsigned.py @@ -42,20 +42,20 @@ class PagureFlaskPluginUnsignedtests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.filters.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() def test_plugin_unsigned(self): """ Test the noff plugin on/off endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): @@ -118,7 +118,7 @@ class PagureFlaskPluginUnsignedtests(tests.Modeltests): in output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', + self.path, 'test.git', 'hooks', 'pre-receive.pagureunsignedcommit'))) # Activate the hook @@ -139,7 +139,7 @@ class PagureFlaskPluginUnsignedtests(tests.Modeltests): output.data) self.assertTrue(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', + self.path, 'test.git', 'hooks', 'pre-receive.pagureunsignedcommit'))) # De-Activate hook @@ -168,7 +168,7 @@ class PagureFlaskPluginUnsignedtests(tests.Modeltests): 'value="y">', output.data) self.assertFalse(os.path.exists(os.path.join( - tests.HERE, 'test.git', 'hooks', + self.path, 'test.git', 'hooks', 'pre-receive.pagureunsignedcommit'))) diff --git a/tests/test_pagure_flask_ui_priorities.py b/tests/test_pagure_flask_ui_priorities.py index 2e3de95..03cf122 100644 --- a/tests/test_pagure_flask_ui_priorities.py +++ b/tests/test_pagure_flask_ui_priorities.py @@ -45,13 +45,13 @@ class PagureFlaskPrioritiestests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.issues.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() @patch('pagure.lib.git.update_git') @@ -62,7 +62,7 @@ class PagureFlaskPrioritiestests(tests.Modeltests): p_ugt.return_value = True tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE), bare=True) + tests.create_projects_git(os.path.join(self.path), bare=True) user = tests.FakeUser() user.username = 'pingou' @@ -107,7 +107,7 @@ class PagureFlaskPrioritiestests(tests.Modeltests): p_ugt.return_value = True tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE), bare=True) + tests.create_projects_git(os.path.join(self.path), bare=True) # Set some priorities repo = pagure.lib.get_project(self.session, 'test') @@ -153,7 +153,7 @@ class PagureFlaskPrioritiestests(tests.Modeltests): def test_update_priorities(self): """ Test updating priorities of a repo. """ tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE), bare=True) + tests.create_projects_git(os.path.join(self.path), bare=True) # Set some priorities repo = pagure.lib.get_project(self.session, 'test') diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index a442f6c..e09eb4c 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -45,17 +45,17 @@ class PagureFlaskRepotests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.APP.config['VIRUS_SCAN_ATTACHMENTS'] = False - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['UPLOAD_FOLDER_PATH'] = os.path.join( - tests.HERE, 'releases') + self.path, 'releases') self.app = pagure.APP.test_client() @patch('pagure.ui.repo.admin_session_timedout') @@ -70,7 +70,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) # User not logged in output = self.app.get('/test/adduser') @@ -102,7 +102,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) data['user'] = 'foo' - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.post( '/test/adduser', data=data, follow_redirects=True) self.assertEqual(output.status_code, 404) @@ -120,7 +120,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) # User not logged in output = self.app.get('/test/adduser') @@ -197,7 +197,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) # User not logged in output = self.app.get('/test/addgroup') @@ -255,7 +255,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) # User not logged in output = self.app.get('/test/addgroup') @@ -346,7 +346,7 @@ class PagureFlaskRepotests(tests.Modeltests): user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.post('/test/settings') @@ -401,7 +401,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.post('/test/dropuser/1') self.assertEqual(output.status_code, 403) @@ -477,7 +477,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) # User not logged in output = self.app.post('/test/dropgroup/1') @@ -549,7 +549,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.post('/test/dropgroup/1') self.assertEqual(output.status_code, 403) @@ -646,7 +646,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) # Session timed-out output = self.app.post('/test/update') @@ -741,7 +741,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.get('/test/settings') self.assertEqual(output.status_code, 403) @@ -858,7 +858,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/forks', follow_redirects=True) self.assertEqual(output.status_code, 200) @@ -877,7 +877,7 @@ class PagureFlaskRepotests(tests.Modeltests): # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test') self.assertEqual(output.status_code, 200) @@ -894,8 +894,8 @@ class PagureFlaskRepotests(tests.Modeltests): 'test project #1 ', output.data) # Add some content to the git repo - tests.add_content_git_repo(os.path.join(tests.HERE, 'test.git')) - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_content_git_repo(os.path.join(self.path, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) output = self.app.get('/test') self.assertEqual(output.status_code, 200) @@ -918,9 +918,9 @@ class PagureFlaskRepotests(tests.Modeltests): # Add some content to the git repo tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test.git')) + os.path.join(self.path, 'forks', 'pingou', 'test.git')) tests.add_readme_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test.git')) + os.path.join(self.path, 'forks', 'pingou', 'test.git')) output = self.app.get('/fork/pingou/test') self.assertEqual(output.status_code, 200) @@ -943,11 +943,11 @@ class PagureFlaskRepotests(tests.Modeltests): self.session.commit() tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_readme_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_commit_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git'), + os.path.join(self.path, 'forks', 'pingou', 'test3.git'), ncommits=10) output = self.app.get('/fork/pingou/test3') @@ -963,7 +963,7 @@ class PagureFlaskRepotests(tests.Modeltests): tests.create_projects(self.session) # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'test.git') + gitrepo = os.path.join(self.path, 'test.git') pygit2.init_repository(gitrepo, bare=True) # Create a fork of this repo @@ -1019,14 +1019,14 @@ class PagureFlaskRepotests(tests.Modeltests): # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/branch/master') self.assertEqual(output.status_code, 404) # Add some content to the git repo - tests.add_content_git_repo(os.path.join(tests.HERE, 'test.git')) - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_content_git_repo(os.path.join(self.path, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) output = self.app.get('/test/branch/master') self.assertEqual(output.status_code, 200) @@ -1049,9 +1049,9 @@ class PagureFlaskRepotests(tests.Modeltests): # Add some content to the git repo tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test.git')) + os.path.join(self.path, 'forks', 'pingou', 'test.git')) tests.add_readme_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test.git')) + os.path.join(self.path, 'forks', 'pingou', 'test.git')) output = self.app.get('/fork/pingou/test/branch/master') self.assertEqual(output.status_code, 200) @@ -1074,11 +1074,11 @@ class PagureFlaskRepotests(tests.Modeltests): self.session.commit() tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_readme_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_commit_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git'), + os.path.join(self.path, 'forks', 'pingou', 'test3.git'), ncommits=10) output = self.app.get('/fork/pingou/test3/branch/master') @@ -1101,7 +1101,7 @@ class PagureFlaskRepotests(tests.Modeltests): # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/commits') self.assertEqual(output.status_code, 200) @@ -1111,8 +1111,8 @@ class PagureFlaskRepotests(tests.Modeltests): 'test project #1 ', output.data) # Add some content to the git repo - tests.add_content_git_repo(os.path.join(tests.HERE, 'test.git')) - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_content_git_repo(os.path.join(self.path, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) output = self.app.get('/test/commits') self.assertEqual(output.status_code, 200) @@ -1144,9 +1144,9 @@ class PagureFlaskRepotests(tests.Modeltests): # Add some content to the git repo tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test.git')) + os.path.join(self.path, 'forks', 'pingou', 'test.git')) tests.add_readme_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test.git')) + os.path.join(self.path, 'forks', 'pingou', 'test.git')) output = self.app.get('/fork/pingou/test/commits?page=abc') self.assertEqual(output.status_code, 200) @@ -1169,11 +1169,11 @@ class PagureFlaskRepotests(tests.Modeltests): self.session.commit() tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_readme_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_commit_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git'), + os.path.join(self.path, 'forks', 'pingou', 'test3.git'), ncommits=10) output = self.app.get('/fork/pingou/test3/commits/fobranch') @@ -1313,26 +1313,26 @@ class PagureFlaskRepotests(tests.Modeltests): # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/bar') self.assertEqual(output.status_code, 404) - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) # Add one commit to git repo tests.add_commit_git_repo( - os.path.join(tests.HERE, 'test.git'), ncommits=1) + os.path.join(self.path, 'test.git'), ncommits=1) c1 = repo.revparse_single('HEAD') # Add another commit to git repo tests.add_commit_git_repo( - os.path.join(tests.HERE, 'test.git'), ncommits=1) + os.path.join(self.path, 'test.git'), ncommits=1) c2 = repo.revparse_single('HEAD') # Add one more commit to git repo tests.add_commit_git_repo( - os.path.join(tests.HERE, 'test.git'), + os.path.join(self.path, 'test.git'), ncommits=1, filename='Šource') c3 = repo.revparse_single('HEAD') @@ -1357,18 +1357,18 @@ class PagureFlaskRepotests(tests.Modeltests): # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/blob/foo/f/sources') self.assertEqual(output.status_code, 404) # Add some content to the git repo - tests.add_content_git_repo(os.path.join(tests.HERE, 'test.git')) - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_content_git_repo(os.path.join(self.path, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) tests.add_binary_git_repo( - os.path.join(tests.HERE, 'test.git'), 'test.jpg') + os.path.join(self.path, 'test.git'), 'test.jpg') tests.add_binary_git_repo( - os.path.join(tests.HERE, 'test.git'), 'test_binary') + os.path.join(self.path, 'test.git'), 'test_binary') output = self.app.get('/test/blob/master/foofile') self.assertEqual(output.status_code, 404) @@ -1393,7 +1393,7 @@ class PagureFlaskRepotests(tests.Modeltests): output.data) # View by commit id - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) commit = repo.revparse_single('HEAD') output = self.app.get('/test/blob/%s/f/test.jpg' % commit.oid.hex) @@ -1435,7 +1435,7 @@ class PagureFlaskRepotests(tests.Modeltests): # View file with a non-ascii name tests.add_commit_git_repo( - os.path.join(tests.HERE, 'test.git'), + os.path.join(self.path, 'test.git'), ncommits=1, filename='Šource') output = self.app.get('/test/blob/master/f/Šource') self.assertEqual(output.status_code, 200) @@ -1464,11 +1464,11 @@ class PagureFlaskRepotests(tests.Modeltests): self.session.commit() tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_readme_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_commit_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git'), + os.path.join(self.path, 'forks', 'pingou', 'test3.git'), ncommits=10) output = self.app.get('/fork/pingou/test3/blob/master/f/sources') @@ -1492,13 +1492,13 @@ class PagureFlaskRepotests(tests.Modeltests): # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/raw/foo/sources') self.assertEqual(output.status_code, 404) # Add some content to the git repo - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) # View first commit output = self.app.get('/test/raw/master') @@ -1506,11 +1506,11 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertTrue(':Author: Pierre-Yves Chibon' in output.data) # Add some more content to the repo - tests.add_content_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_content_git_repo(os.path.join(self.path, 'test.git')) tests.add_binary_git_repo( - os.path.join(tests.HERE, 'test.git'), 'test.jpg') + os.path.join(self.path, 'test.git'), 'test.jpg') tests.add_binary_git_repo( - os.path.join(tests.HERE, 'test.git'), 'test_binary') + os.path.join(self.path, 'test.git'), 'test_binary') output = self.app.get('/test/raw/master/f/foofile') self.assertEqual(output.status_code, 404) @@ -1526,7 +1526,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertTrue(output.data.startswith('\x00\x00\x01\x00')) # View by commit id - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) commit = repo.revparse_single('HEAD') output = self.app.get('/test/raw/%s/f/test.jpg' % commit.oid.hex) @@ -1579,11 +1579,11 @@ class PagureFlaskRepotests(tests.Modeltests): self.session.commit() tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_readme_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_commit_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git'), + os.path.join(self.path, 'forks', 'pingou', 'test3.git'), ncommits=10) output = self.app.get('/fork/pingou/test3/raw/master/f/sources') @@ -1602,14 +1602,14 @@ class PagureFlaskRepotests(tests.Modeltests): # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/c/bar') self.assertEqual(output.status_code, 404) # Add a README to the git repo - First commit - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) commit = repo.revparse_single('HEAD') # View first commit @@ -1632,9 +1632,9 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertIn('

Project not found

', output.data) # Add some content to the git repo - tests.add_content_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_content_git_repo(os.path.join(self.path, 'test.git')) - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) commit = repo.revparse_single('HEAD') # View another commit @@ -1685,7 +1685,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.session.add(item) self.session.commit() forkedgit = os.path.join( - tests.HERE, 'forks', 'pingou', 'test3.git') + self.path, 'forks', 'pingou', 'test3.git') tests.add_content_git_repo(forkedgit) tests.add_readme_git_repo(forkedgit) @@ -1746,14 +1746,14 @@ class PagureFlaskRepotests(tests.Modeltests): # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/c/bar.patch') self.assertEqual(output.status_code, 404) # Add a README to the git repo - First commit - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) commit = repo.revparse_single('HEAD') # View first commit @@ -1785,9 +1785,9 @@ index 0000000..fb7093d self.assertTrue('Subject: Add a README file' in output.data) # Add some content to the git repo - tests.add_content_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_content_git_repo(os.path.join(self.path, 'test.git')) - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) commit = repo.revparse_single('HEAD') # View another commit @@ -1819,7 +1819,7 @@ index 0000000..11980b1 ) self.session.add(item) self.session.commit() - forkedgit = os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git') + forkedgit = os.path.join(self.path, 'forks', 'pingou', 'test3.git') tests.add_content_git_repo(forkedgit) tests.add_readme_git_repo(forkedgit) @@ -1871,7 +1871,7 @@ index 0000000..fb7093d # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/tree/') self.assertEqual(output.status_code, 200) @@ -1889,8 +1889,8 @@ index 0000000..fb7093d 'No content found in this repository' in output.data) # Add a README to the git repo - First commit - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) commit = repo.revparse_single('HEAD') # View first commit @@ -1926,7 +1926,7 @@ index 0000000..fb7093d ) self.session.add(item) self.session.commit() - forkedgit = os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git') + forkedgit = os.path.join(self.path, 'forks', 'pingou', 'test3.git') tests.add_content_git_repo(forkedgit) @@ -1969,7 +1969,7 @@ index 0000000..fb7093d user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.post('/test/delete', follow_redirects=True) self.assertEqual(output.status_code, 404) @@ -2000,8 +2000,8 @@ index 0000000..fb7093d ) self.session.add(item) self.session.commit() - tests.create_projects_git(tests.HERE) - tests.create_projects_git(os.path.join(tests.HERE, 'docs')) + tests.create_projects_git(self.path) + tests.create_projects_git(os.path.join(self.path, 'docs')) output = self.app.post('/test/delete', follow_redirects=True) self.assertEqual(output.status_code, 404) @@ -2016,12 +2016,12 @@ index 0000000..fb7093d self.session.commit() # Create all the git repos - tests.create_projects_git(tests.HERE) - tests.create_projects_git(os.path.join(tests.HERE, 'docs')) + tests.create_projects_git(self.path) + tests.create_projects_git(os.path.join(self.path, 'docs')) tests.create_projects_git( - os.path.join(tests.HERE, 'tickets'), bare=True) + os.path.join(self.path, 'tickets'), bare=True) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) # Check repo was created output = self.app.get('/') @@ -2041,7 +2041,7 @@ index 0000000..fb7093d title='Test issue', content='We should work on this', user='pingou', - ticketfolder=os.path.join(tests.HERE, 'tickets') + ticketfolder=os.path.join(self.path, 'tickets') ) self.session.commit() self.assertEqual(msg.title, 'Test issue') @@ -2052,7 +2052,7 @@ index 0000000..fb7093d title='Test issue #2', content='We should work on this, really', user='pingou', - ticketfolder=os.path.join(tests.HERE, 'tickets') + ticketfolder=os.path.join(self.path, 'tickets') ) self.session.commit() self.assertEqual(msg.title, 'Test issue #2') @@ -2078,7 +2078,7 @@ index 0000000..fb7093d branch_to='master', title='test pull-request', user='pingou', - requestfolder=os.path.join(tests.HERE, 'requests'), + requestfolder=os.path.join(self.path, 'requests'), ) self.session.commit() self.assertEqual(req.id, 3) @@ -2092,7 +2092,7 @@ index 0000000..fb7093d branch_to='master', title='test pull-request', user='pingou', - requestfolder=os.path.join(tests.HERE, 'requests'), + requestfolder=os.path.join(self.path, 'requests'), ) self.session.commit() self.assertEqual(req.id, 4) @@ -2145,11 +2145,11 @@ index 0000000..fb7093d self.session.add(item) self.session.commit() tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_content_git_repo( - os.path.join(tests.HERE, 'docs', 'pingou', 'test3.git')) + os.path.join(self.path, 'docs', 'pingou', 'test3.git')) tests.add_content_git_repo( - os.path.join(tests.HERE, 'tickets', 'pingou', 'test3.git')) + os.path.join(self.path, 'tickets', 'pingou', 'test3.git')) # Check before deleting the fork output = self.app.get('/') @@ -2182,7 +2182,7 @@ index 0000000..fb7093d user = tests.FakeUser() with tests.user_set(pagure.APP, user): tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) # No project registered in the DB (no git repo) output = self.app.post('/foo/delete') @@ -2198,7 +2198,7 @@ index 0000000..fb7093d user = tests.FakeUser(username='pingou') with tests.user_set(pagure.APP, user): - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) ast.return_value = True output = self.app.post('/test/delete') @@ -2226,7 +2226,7 @@ index 0000000..fb7093d ) self.session.add(item) self.session.commit() - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) output = self.app.post('/test/delete', follow_redirects=True) self.assertEqual(output.status_code, 200) @@ -2249,8 +2249,8 @@ index 0000000..fb7093d ) self.session.add(item) self.session.commit() - tests.create_projects_git(tests.HERE) - tests.create_projects_git(os.path.join(tests.HERE, 'docs')) + tests.create_projects_git(self.path) + tests.create_projects_git(os.path.join(self.path, 'docs')) output = self.app.post('/test/delete', follow_redirects=True) self.assertEqual(output.status_code, 200) self.assertTrue( @@ -2268,12 +2268,12 @@ index 0000000..fb7093d self.session.commit() # Create all the git repos - tests.create_projects_git(tests.HERE) - tests.create_projects_git(os.path.join(tests.HERE, 'docs')) + tests.create_projects_git(self.path) + tests.create_projects_git(os.path.join(self.path, 'docs')) tests.create_projects_git( - os.path.join(tests.HERE, 'tickets'), bare=True) + os.path.join(self.path, 'tickets'), bare=True) tests.create_projects_git( - os.path.join(tests.HERE, 'requests'), bare=True) + os.path.join(self.path, 'requests'), bare=True) # Check repo was created output = self.app.get('/') @@ -2293,7 +2293,7 @@ index 0000000..fb7093d title='Test issue', content='We should work on this', user='pingou', - ticketfolder=os.path.join(tests.HERE, 'tickets') + ticketfolder=os.path.join(self.path, 'tickets') ) self.session.commit() self.assertEqual(msg.title, 'Test issue') @@ -2304,7 +2304,7 @@ index 0000000..fb7093d title='Test issue #2', content='We should work on this, really', user='pingou', - ticketfolder=os.path.join(tests.HERE, 'tickets') + ticketfolder=os.path.join(self.path, 'tickets') ) self.session.commit() self.assertEqual(msg.title, 'Test issue #2') @@ -2330,7 +2330,7 @@ index 0000000..fb7093d branch_to='master', title='test pull-request', user='pingou', - requestfolder=os.path.join(tests.HERE, 'requests'), + requestfolder=os.path.join(self.path, 'requests'), ) self.session.commit() self.assertEqual(req.id, 3) @@ -2344,7 +2344,7 @@ index 0000000..fb7093d branch_to='master', title='test pull-request', user='pingou', - requestfolder=os.path.join(tests.HERE, 'requests'), + requestfolder=os.path.join(self.path, 'requests'), ) self.session.commit() self.assertEqual(req.id, 4) @@ -2403,11 +2403,11 @@ index 0000000..fb7093d self.session.add(item) self.session.commit() tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_content_git_repo( - os.path.join(tests.HERE, 'docs', 'pingou', 'test3.git')) + os.path.join(self.path, 'docs', 'pingou', 'test3.git')) tests.add_content_git_repo( - os.path.join(tests.HERE, 'tickets', 'pingou', 'test3.git')) + os.path.join(self.path, 'tickets', 'pingou', 'test3.git')) # Check before deleting the fork output = self.app.get('/') @@ -2434,7 +2434,7 @@ index 0000000..fb7093d """ Test the new_repo_hook_token endpoint. """ ast.return_value = False tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) repo = pagure.lib.get_project(self.session, 'test') self.assertEqual(repo.hook_token, 'aaabbbccc') @@ -2496,7 +2496,7 @@ index 0000000..fb7093d upgit.return_value = True sendmail.return_value = True tests.create_projects(self.session) - tests.create_projects_git(tests.HERE) + tests.create_projects_git(self.path) user = tests.FakeUser() with tests.user_set(pagure.APP, user): @@ -2588,15 +2588,15 @@ index 0000000..fb7093d # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/releases') self.assertEqual(output.status_code, 200) self.assertIn('This project has not been tagged.', output.data) # Add a README to the git repo - First commit - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) first_commit = repo.revparse_single('HEAD') tagger = pygit2.Signature('Alice Doe', 'adoe@example.com', 12347, 0) repo.create_tag( @@ -2623,7 +2623,7 @@ index 0000000..fb7093d self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) # No a repo admin output = self.app.get('/test/edit/foo/f/sources') @@ -2641,12 +2641,12 @@ index 0000000..fb7093d self.assertEqual(output.status_code, 404) # Add some content to the git repo - tests.add_content_git_repo(os.path.join(tests.HERE, 'test.git')) - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_content_git_repo(os.path.join(self.path, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) tests.add_binary_git_repo( - os.path.join(tests.HERE, 'test.git'), 'test.jpg') + os.path.join(self.path, 'test.git'), 'test.jpg') tests.add_binary_git_repo( - os.path.join(tests.HERE, 'test.git'), 'test_binary') + os.path.join(self.path, 'test.git'), 'test_binary') output = self.app.get('/test/edit/master/foofile') self.assertEqual(output.status_code, 404) @@ -2737,11 +2737,11 @@ index 0000000..fb7093d self.session.commit() tests.add_content_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_readme_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git')) + os.path.join(self.path, 'forks', 'pingou', 'test3.git')) tests.add_commit_git_repo( - os.path.join(tests.HERE, 'forks', 'pingou', 'test3.git'), + os.path.join(self.path, 'forks', 'pingou', 'test3.git'), ncommits=10) output = self.app.get('/fork/pingou/test3/edit/master/f/sources') @@ -2776,7 +2776,7 @@ index 0000000..fb7093d self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - repos = tests.create_projects_git(tests.HERE) + repos = tests.create_projects_git(self.path) output = self.app.post('/test/default/branch/') self.assertEqual(output.status_code, 403) @@ -2872,7 +2872,7 @@ index 0000000..fb7093d self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - repo = tests.create_projects_git(tests.HERE) + repo = tests.create_projects_git(self.path) output = self.app.post('/test/upload/') self.assertEqual(output.status_code, 403) @@ -2883,7 +2883,8 @@ index 0000000..fb7093d user.username = 'pingou' with tests.user_set(pagure.APP, user): - img = os.path.join(tests.HERE, 'placebo.png') + img = os.path.join(os.path.abspath(os.path.dirname(__file__)), + 'placebo.png') # Missing CSRF Token with open(img, mode='rb') as stream: @@ -2922,7 +2923,7 @@ index 0000000..fb7093d self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/test/token/new/') self.assertEqual(output.status_code, 403) @@ -2988,7 +2989,7 @@ index 0000000..fb7093d self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.post('/test/token/revoke/123') self.assertEqual(output.status_code, 403) @@ -3064,7 +3065,7 @@ index 0000000..fb7093d self.assertEqual(output.status_code, 404) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) # User not logged in output = self.app.post('/test/b/master/delete') @@ -3092,7 +3093,7 @@ index 0000000..fb7093d self.assertIn('

Branch no found

', output.data) # Add a branch that we can delete - path = os.path.join(tests.HERE, 'test.git') + path = os.path.join(self.path, 'test.git') tests.add_content_git_repo(path) repo = pygit2.Repository(path) repo.create_branch('foo', repo.head.get_object()) @@ -3121,7 +3122,7 @@ index 0000000..fb7093d output.data) # Add a branch with a '/' in its name that we can delete - path = os.path.join(tests.HERE, 'test.git') + path = os.path.join(self.path, 'test.git') tests.add_content_git_repo(path) repo = pygit2.Repository(path) repo.create_branch('feature/foo', repo.head.get_object()) @@ -3162,7 +3163,7 @@ index 0000000..fb7093d # No git repo associated self.assertEqual(output.status_code, 404) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) output = self.app.get('/docs/test/') self.assertEqual(output.status_code, 404) @@ -3170,7 +3171,7 @@ index 0000000..fb7093d def test_view_project_activity(self): """ Test the view_project_activity endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) # Project Exists, but No DATAGREPPER_URL set output = self.app.get('/test/activity/') @@ -3196,7 +3197,7 @@ index 0000000..fb7093d self.assertEqual(output.status_code, 405) tests.create_projects(self.session) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) user = tests.FakeUser() user.username = 'pingou' @@ -3246,7 +3247,7 @@ index 0000000..fb7093d ) self.session.add(item) self.session.commit() - gitrepo = os.path.join(tests.HERE, 'forks', 'foo', 'test.git') + gitrepo = os.path.join(self.path, 'forks', 'foo', 'test.git') pygit2.init_repository(gitrepo, bare=True) output = self.app.post( diff --git a/tests/test_pagure_flask_ui_repo_slash_name.py b/tests/test_pagure_flask_ui_repo_slash_name.py index 5ca66c3..8a07ce4 100644 --- a/tests/test_pagure_flask_ui_repo_slash_name.py +++ b/tests/test_pagure_flask_ui_repo_slash_name.py @@ -46,21 +46,21 @@ class PagureFlaskSlashInNametests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.issues.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = os.path.join(tests.HERE, 'repos') - pagure.APP.config['FORK_FOLDER'] = os.path.join(tests.HERE, 'forks') + pagure.APP.config['GIT_FOLDER'] = os.path.join(self.path, 'repos') + pagure.APP.config['FORK_FOLDER'] = os.path.join(self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') self.app = pagure.APP.test_client() def set_up_git_repo(self, name='test'): """ Set up the git repo to play with. """ # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', '%s.git' % name) + gitrepo = os.path.join(self.path, 'repos', '%s.git' % name) repo = pygit2.init_repository(gitrepo, bare=True) newpath = tempfile.mkdtemp(prefix='pagure-other-test') @@ -106,7 +106,7 @@ class PagureFlaskSlashInNametests(tests.Modeltests): self.assertEqual(output.status_code, 404) # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') repo = pygit2.init_repository(gitrepo, bare=True) # With git repo @@ -150,7 +150,7 @@ class PagureFlaskSlashInNametests(tests.Modeltests): self.session.commit() # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'forks/test.git') + gitrepo = os.path.join(self.path, 'repos', 'forks/test.git') repo = pygit2.init_repository(gitrepo, bare=True) output = self.app.get('/forks/test') @@ -243,7 +243,7 @@ class PagureFlaskSlashInNametests(tests.Modeltests): output.data) # Try accessing the commit - gitrepo = os.path.join(tests.HERE, 'repos', 'forks/test.git') + gitrepo = os.path.join(self.path, 'repos', 'forks/test.git') repo = pygit2.Repository(gitrepo) master_branch = repo.lookup_branch('master') first_commit = master_branch.get_object().hex diff --git a/tests/test_pagure_flask_ui_roadmap.py b/tests/test_pagure_flask_ui_roadmap.py index 0cca6ec..06bdd16 100644 --- a/tests/test_pagure_flask_ui_roadmap.py +++ b/tests/test_pagure_flask_ui_roadmap.py @@ -45,13 +45,13 @@ class PagureFlaskRoadmaptests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.ui.issues.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') self.app = pagure.APP.test_client() @patch('pagure.lib.git.update_git') @@ -62,7 +62,7 @@ class PagureFlaskRoadmaptests(tests.Modeltests): p_ugt.return_value = True tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE), bare=True) + tests.create_projects_git(os.path.join(self.path), bare=True) user = tests.FakeUser() user.username = 'pingou' @@ -105,7 +105,7 @@ class PagureFlaskRoadmaptests(tests.Modeltests): p_ugt.return_value = True tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE), bare=True) + tests.create_projects_git(os.path.join(self.path), bare=True) # Set some milestone repo = pagure.lib.get_project(self.session, 'test') @@ -166,7 +166,7 @@ class PagureFlaskRoadmaptests(tests.Modeltests): def test_update_milestones(self): """ Test updating milestones of a repo. """ tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE), bare=True) + tests.create_projects_git(os.path.join(self.path), bare=True) # Set some milestones repo = pagure.lib.get_project(self.session, 'test') @@ -340,7 +340,7 @@ class PagureFlaskRoadmaptests(tests.Modeltests): def test_milestones_without_dates(self, p_send_email, p_ugt): """ Test creating two milestones with no dates. """ tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE), bare=True) + tests.create_projects_git(os.path.join(self.path), bare=True) user = tests.FakeUser() user.username = 'pingou' diff --git a/tests/test_pagure_flask_ui_slash_branch_name.py b/tests/test_pagure_flask_ui_slash_branch_name.py index b1971a4..2d20ece 100644 --- a/tests/test_pagure_flask_ui_slash_branch_name.py +++ b/tests/test_pagure_flask_ui_slash_branch_name.py @@ -45,21 +45,21 @@ class PagureFlaskSlashInBranchtests(tests.Modeltests): pagure.ui.fork.SESSION = self.session pagure.ui.repo.SESSION = self.session - pagure.APP.config['GIT_FOLDER'] = os.path.join(tests.HERE, 'repos') - pagure.APP.config['FORK_FOLDER'] = os.path.join(tests.HERE, 'forks') + pagure.APP.config['GIT_FOLDER'] = os.path.join(self.path, 'repos') + pagure.APP.config['FORK_FOLDER'] = os.path.join(self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') self.app = pagure.APP.test_client() def set_up_git_repo(self): """ Set up the git repo to play with. """ # Create a git repo to play with - gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + gitrepo = os.path.join(self.path, 'repos', 'test.git') repo = pygit2.init_repository(gitrepo, bare=True) newpath = tempfile.mkdtemp(prefix='pagure-other-test') diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py index 09fb942..cb2d7ba 100644 --- a/tests/test_pagure_lib.py +++ b/tests/test_pagure_lib.py @@ -727,11 +727,6 @@ class PagureLibtests(tests.Modeltests): ticketfolder = os.path.join(self.path, 'tickets') requestfolder = os.path.join(self.path, 'requests') - os.mkdir(gitfolder) - os.mkdir(docfolder) - os.mkdir(ticketfolder) - os.mkdir(requestfolder) - # Try creating a blacklisted project self.assertRaises( pagure.exceptions.PagureException, @@ -1146,10 +1141,6 @@ class PagureLibtests(tests.Modeltests): ticketfolder = os.path.join(self.path, 'tickets') requestfolder = os.path.join(self.path, 'requests') - os.mkdir(gitfolder) - os.mkdir(docfolder) - os.mkdir(ticketfolder) - projects = pagure.lib.search_projects(self.session) self.assertEqual(len(projects), 0) diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index b3fc048..c37fd29 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -38,15 +38,15 @@ class PagureLibGittests(tests.Modeltests): pagure.lib.git.SESSION = self.session pagure.APP.config['GIT_FOLDER'] = os.path.join( - tests.HERE, 'repos') + self.path, 'repos') pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') def test_write_gitolite_acls(self): """ Test the write_gitolite_acls function of pagure.lib.git. """ @@ -74,7 +74,7 @@ class PagureLibGittests(tests.Modeltests): self.session.add(item) self.session.commit() - outputconf = os.path.join(tests.HERE, 'test_gitolite.conf') + outputconf = os.path.join(self.path, 'test_gitolite.conf') pagure.lib.git.write_gitolite_acls(self.session, outputconf) @@ -210,7 +210,7 @@ repo requests/forks/pingou/test3 self.session.add(item) self.session.commit() - outputconf = os.path.join(tests.HERE, 'test_gitolite.conf') + outputconf = os.path.join(self.path, 'test_gitolite.conf') pagure.lib.git.write_gitolite_acls(self.session, outputconf) @@ -282,7 +282,7 @@ repo requests/forks/pingou/test2 def test_commit_to_patch(self): """ Test the commit_to_patch function of pagure.lib.git. """ # Create a git repo to play with - self.gitrepo = os.path.join(tests.HERE, 'test_repo.git') + self.gitrepo = os.path.join(self.path, 'test_repo.git') os.makedirs(self.gitrepo) repo = pygit2.init_repository(self.gitrepo) @@ -441,7 +441,7 @@ index 9f44358..2a552bb 100644 self.session.commit() # Create repo - self.gitrepo = os.path.join(tests.HERE, 'test_ticket_repo.git') + self.gitrepo = os.path.join(self.path, 'test_ticket_repo.git') os.makedirs(self.gitrepo) repo_obj = pygit2.init_repository(self.gitrepo, bare=True) @@ -453,11 +453,11 @@ index 9f44358..2a552bb 100644 title='Test issue', content='We should work on this', user='pingou', - ticketfolder=tests.HERE + ticketfolder=self.path ) self.assertEqual(msg.title, 'Test issue') issue = pagure.lib.search_issues(self.session, repo, issueid=1) - pagure.lib.git.update_git(issue, repo, tests.HERE) + pagure.lib.git.update_git(issue, repo, self.path) repo = pygit2.Repository(self.gitrepo) commit = repo.revparse_single('HEAD') @@ -541,7 +541,7 @@ index 0000000..60f7480 issue=issue, comment='Hey look a comment!', user='foo', - ticketfolder=tests.HERE + ticketfolder=self.path ) self.session.commit() self.assertEqual(msg, 'Comment added') @@ -628,7 +628,7 @@ index 458821a..77674a8 self.test_update_git() - gitpath = os.path.join(tests.HERE, 'test_ticket_repo.git') + gitpath = os.path.join(self.path, 'test_ticket_repo.git') gitrepo = pygit2.init_repository(gitpath, bare=True) # Get the uid of the ticket created @@ -646,7 +646,7 @@ index 458821a..77674a8 repo = pagure.lib.get_project(self.session, 'test_ticket_repo') issue = pagure.lib.search_issues(self.session, repo, issueid=1) - pagure.lib.git.clean_git(issue, repo, tests.HERE) + pagure.lib.git.clean_git(issue, repo, self.path) # No more files in the git repo commit = gitrepo.revparse_single('HEAD') @@ -669,7 +669,7 @@ index 458821a..77674a8 self.session.commit() # Create repo - self.gitrepo = os.path.join(tests.HERE, 'test_ticket_repo.git') + self.gitrepo = os.path.join(self.path, 'test_ticket_repo.git') os.makedirs(self.gitrepo) repo_obj = pygit2.init_repository(self.gitrepo, bare=True) @@ -683,7 +683,7 @@ index 458821a..77674a8 branch_to='master', title='test PR', user='pingou', - requestfolder=tests.HERE, + requestfolder=self.path, requestuid='foobar', requestid=None, status='Open', @@ -694,7 +694,7 @@ index 458821a..77674a8 request = repo.requests[0] self.assertEqual(request.title, 'test PR') - pagure.lib.git.update_git(request, request.project, tests.HERE) + pagure.lib.git.update_git(request, request.project, self.path) repo = pygit2.Repository(self.gitrepo) commit = repo.revparse_single('HEAD') @@ -962,7 +962,7 @@ index 0000000..60f7480 def test_update_request_from_git(self): """ Test the update_request_from_git method from pagure.lib.git. """ tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE, 'repos')) + tests.create_projects_git(os.path.join(self.path, 'repos')) repo = pagure.lib.get_project(self.session, 'test') @@ -1110,10 +1110,10 @@ index 0000000..60f7480 username=None, request_uid='d4182a2ac2d541d884742d3037c26e56', json_data=data, - gitfolder=tests.HERE, - docfolder=os.path.join(tests.HERE, 'docs'), - ticketfolder=os.path.join(tests.HERE, 'tickets'), - requestfolder=os.path.join(tests.HERE, 'requests') + gitfolder=self.path, + docfolder=os.path.join(self.path, 'docs'), + ticketfolder=os.path.join(self.path, 'tickets'), + requestfolder=os.path.join(self.path, 'requests') ) pagure.lib.git.update_request_from_git( @@ -1123,10 +1123,10 @@ index 0000000..60f7480 username=None, request_uid='d4182a2ac2d541d884742d3037c26e56', json_data=data, - gitfolder=tests.HERE, - docfolder=os.path.join(tests.HERE, 'docs'), - ticketfolder=os.path.join(tests.HERE, 'tickets'), - requestfolder=os.path.join(tests.HERE, 'requests') + gitfolder=self.path, + docfolder=os.path.join(self.path, 'docs'), + ticketfolder=os.path.join(self.path, 'tickets'), + requestfolder=os.path.join(self.path, 'requests') ) self.session.commit() @@ -1227,10 +1227,10 @@ index 0000000..60f7480 username=None, request_uid='d4182a2ac2d541d884742d3037c26e57', json_data=data, - gitfolder=tests.HERE, - docfolder=os.path.join(tests.HERE, 'docs'), - ticketfolder=os.path.join(tests.HERE, 'tickets'), - requestfolder=os.path.join(tests.HERE, 'requests') + gitfolder=self.path, + docfolder=os.path.join(self.path, 'docs'), + ticketfolder=os.path.join(self.path, 'tickets'), + requestfolder=os.path.join(self.path, 'requests') ) self.session.commit() @@ -1252,7 +1252,7 @@ index 0000000..60f7480 """ Test the read_git_lines method of pagure.lib.git. """ self.test_update_git() - gitrepo = os.path.join(tests.HERE, 'test_ticket_repo.git') + gitrepo = os.path.join(self.path, 'test_ticket_repo.git') output = pagure.lib.git.read_git_lines( ['log', '-1', "--pretty='%s'"], gitrepo) self.assertEqual(len(output), 1) @@ -1276,7 +1276,7 @@ index 0000000..60f7480 self.test_update_git() - gitrepo = os.path.join(tests.HERE, 'test_ticket_repo.git') + gitrepo = os.path.join(self.path, 'test_ticket_repo.git') output = pagure.lib.git.read_git_lines( ['log', '-3', "--pretty='%H'"], gitrepo) self.assertEqual(len(output), 2) @@ -1343,7 +1343,7 @@ index 0000000..60f7480 self.test_update_git() - gitrepo = os.path.join(tests.HERE, 'test_ticket_repo.git') + gitrepo = os.path.join(self.path, 'test_ticket_repo.git') output = pagure.lib.git.read_git_lines( ['log', '-3', "--pretty='%H'"], gitrepo) self.assertEqual(len(output), 2) @@ -1357,7 +1357,7 @@ index 0000000..60f7480 self.test_update_git() - gitrepo = os.path.join(tests.HERE, 'test_ticket_repo.git') + gitrepo = os.path.join(self.path, 'test_ticket_repo.git') output = pagure.lib.git.read_git_lines( ['log', '-3', "--pretty='%H'"], gitrepo) self.assertEqual(len(output), 2) @@ -1368,7 +1368,7 @@ index 0000000..60f7480 def test_get_repo_name(self): """ Test the get_repo_name method of pagure.lib.git. """ - gitrepo = os.path.join(tests.HERE, 'test_ticket_repo.git') + gitrepo = os.path.join(self.path, 'test_ticket_repo.git') repo_name = pagure.lib.git.get_repo_name(gitrepo) self.assertEqual(repo_name, 'test_ticket_repo') @@ -1380,7 +1380,7 @@ index 0000000..60f7480 def test_get_username(self): """ Test the get_username method of pagure.lib.git. """ - gitrepo = os.path.join(tests.HERE, 'test_ticket_repo.git') + gitrepo = os.path.join(self.path, 'test_ticket_repo.git') repo_name = pagure.lib.git.get_username(gitrepo) self.assertEqual(repo_name, None) @@ -1391,45 +1391,45 @@ index 0000000..60f7480 self.assertEqual(repo_name, None) repo_name = pagure.lib.git.get_username( - os.path.join(tests.HERE, 'forks', 'pingou', 'foo.test.git')) + os.path.join(self.path, 'forks', 'pingou', 'foo.test.git')) self.assertEqual(repo_name, 'pingou') repo_name = pagure.lib.git.get_username( - os.path.join(tests.HERE, 'forks', 'pingou', 'bar/foo.test.git')) + os.path.join(self.path, 'forks', 'pingou', 'bar/foo.test.git')) self.assertEqual(repo_name, 'pingou') repo_name = pagure.lib.git.get_username(os.path.join( - tests.HERE, 'forks', 'pingou', 'fooo/bar/foo.test.git')) + self.path, 'forks', 'pingou', 'fooo/bar/foo.test.git')) self.assertEqual(repo_name, 'pingou') def test_get_repo_namespace(self): """ Test the get_repo_namespace method of pagure.lib.git. """ repo_name = pagure.lib.git.get_repo_namespace( - os.path.join(tests.HERE, 'repos', 'test_ticket_repo.git')) + os.path.join(self.path, 'repos', 'test_ticket_repo.git')) self.assertEqual(repo_name, None) repo_name = pagure.lib.git.get_repo_namespace( - os.path.join(tests.HERE, 'repos', 'foo/bar/baz/test.git')) + os.path.join(self.path, 'repos', 'foo/bar/baz/test.git')) self.assertEqual(repo_name, 'foo/bar/baz') repo_name = pagure.lib.git.get_repo_namespace( - os.path.join(tests.HERE, 'repos', 'foo.test.git')) + os.path.join(self.path, 'repos', 'foo.test.git')) self.assertEqual(repo_name, None) repo_name = pagure.lib.git.get_repo_namespace(os.path.join( - tests.HERE, 'repos', 'forks', 'user', 'foo.test.git')) + self.path, 'repos', 'forks', 'user', 'foo.test.git')) self.assertEqual(repo_name, None) repo_name = pagure.lib.git.get_repo_namespace(os.path.join( - tests.HERE, 'repos', 'forks', 'user', 'bar/foo.test.git')) + self.path, 'repos', 'forks', 'user', 'bar/foo.test.git')) self.assertEqual(repo_name, 'bar') repo_name = pagure.lib.git.get_repo_namespace(os.path.join( - tests.HERE, 'repos', 'forks', 'user', 'ns/bar/foo.test.git')) + self.path, 'repos', 'forks', 'user', 'ns/bar/foo.test.git')) self.assertEqual(repo_name, 'ns/bar') repo_name = pagure.lib.git.get_repo_namespace(os.path.join( - tests.HERE, 'repos', 'forks', 'user', '/bar/foo.test.git')) + self.path, 'repos', 'forks', 'user', '/bar/foo.test.git')) self.assertEqual(repo_name, 'bar') diff --git a/tests/test_pagure_lib_git_get_tags_objects.py b/tests/test_pagure_lib_git_get_tags_objects.py index 0532273..9c05d0e 100644 --- a/tests/test_pagure_lib_git_get_tags_objects.py +++ b/tests/test_pagure_lib_git_get_tags_objects.py @@ -30,12 +30,12 @@ def get_tag_name(tags): return output -def add_repo_tag(repo, tags, repo_name): +def add_repo_tag(git_dir, repo, tags, repo_name): """ Use a list to create multiple tags on a git repo """ for tag in reversed(tags): time.sleep(1) tests.add_commit_git_repo( - os.path.join(tests.HERE, 'repos', repo_name), + os.path.join(git_dir, 'repos', repo_name), ncommits=1) first_commit = repo.revparse_single('HEAD') tagger = pygit2.Signature('Alice Doe', 'adoe@example.com', 12347, 0) @@ -52,20 +52,20 @@ class PagureLibGitGetTagstests(tests.Modeltests): pagure.lib.git.SESSION = self.session pagure.APP.config['GIT_FOLDER'] = os.path.join( - tests.HERE, 'repos') + self.path, 'repos') pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') def test_get_git_tags_objects(self): """ Test the get_git_tags_objects method of pagure.lib.git. """ tests.create_projects(self.session) - tests.create_projects_git(os.path.join(tests.HERE, 'repos'), bare=True) + tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True) project = pagure.lib.get_project(self.session, 'test') # Case 1 - Empty repo with no tags @@ -74,9 +74,9 @@ class PagureLibGitGetTagstests(tests.Modeltests): self.assertEqual(exp, get_tag_name(tags)) tests.add_readme_git_repo(os.path.join(os.path.join( - tests.HERE, 'repos'), 'test.git')) + self.path, 'repos'), 'test.git')) repo = pygit2.Repository(os.path.join(os.path.join( - tests.HERE, 'repos'), 'test.git')) + self.path, 'repos'), 'test.git')) # Case 2 - Repo with one commit and no tags exp = [] @@ -86,20 +86,20 @@ class PagureLibGitGetTagstests(tests.Modeltests): # Case 3 - Simple sort exp = ['0.1.0', 'test-0.0.21', '0.0.12-beta', '0.0.12-alpha', '0.0.12', '0.0.11', '0.0.3', 'foo-0.0.2', '0.0.1'] - add_repo_tag(repo, exp, 'test.git') + add_repo_tag(self.path, repo, exp, 'test.git') tags = pagure.lib.git.get_git_tags_objects(project) self.assertEqual(exp, get_tag_name(tags)) # Case 4 - Sorting with different splitting characters project = pagure.lib.get_project(self.session, 'test2') tests.add_readme_git_repo(os.path.join(os.path.join( - tests.HERE, 'repos'), 'test2.git')) + self.path, 'repos'), 'test2.git')) repo = pygit2.Repository(os.path.join(os.path.join( - tests.HERE, 'repos'), 'test2.git')) + self.path, 'repos'), 'test2.git')) exp = ['1.0-0_2', '1.0-0_1', '0.1-1_0', '0.1-0_0', '0.0-2_0', '0.0-1_34', '0.0-1_11', '0.0-1_3', '0.0-1_2', '0.0-1_1'] - add_repo_tag(repo, exp, 'test2.git') + add_repo_tag(self.path, repo, exp, 'test2.git') tags = pagure.lib.git.get_git_tags_objects(project) self.assertEqual(exp, get_tag_name(tags)) diff --git a/tests/test_zzz_pagure_flask_ui_old_commit.py b/tests/test_zzz_pagure_flask_ui_old_commit.py index 87e7309..43b1ade 100644 --- a/tests/test_zzz_pagure_flask_ui_old_commit.py +++ b/tests/test_zzz_pagure_flask_ui_old_commit.py @@ -53,17 +53,17 @@ class PagureFlaskRepoOldUrltests(tests.Modeltests): pagure.APP.config['OLD_VIEW_COMMIT_ENABLED'] = True pagure.APP.config['EMAIL_SEND'] = False - pagure.APP.config['GIT_FOLDER'] = tests.HERE + pagure.APP.config['GIT_FOLDER'] = self.path pagure.APP.config['FORK_FOLDER'] = os.path.join( - tests.HERE, 'forks') + self.path, 'forks') pagure.APP.config['REQUESTS_FOLDER'] = os.path.join( - tests.HERE, 'requests') + self.path, 'requests') pagure.APP.config['TICKETS_FOLDER'] = os.path.join( - tests.HERE, 'tickets') + self.path, 'tickets') pagure.APP.config['DOCS_FOLDER'] = os.path.join( - tests.HERE, 'docs') + self.path, 'docs') pagure.APP.config['UPLOAD_FOLDER_PATH'] = os.path.join( - tests.HERE, 'releases') + self.path, 'releases') self.app = pagure.APP.test_client() def tearDown(self): @@ -79,11 +79,11 @@ class PagureFlaskRepoOldUrltests(tests.Modeltests): """ Test the view_commit_old endpoint. """ tests.create_projects(self.session) - tests.create_projects_git(tests.HERE, bare=True) + tests.create_projects_git(self.path, bare=True) # Add a README to the git repo - First commit - tests.add_readme_git_repo(os.path.join(tests.HERE, 'test.git')) - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + tests.add_readme_git_repo(os.path.join(self.path, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) commit = repo.revparse_single('HEAD') # View first commit @@ -119,9 +119,9 @@ class PagureFlaskRepoOldUrltests(tests.Modeltests): '+ ======' in output.data) # Add some content to the git repo - tests.add_content_git_repo(os.path.join(tests.HERE, 'test.git')) + tests.add_content_git_repo(os.path.join(self.path, 'test.git')) - repo = pygit2.Repository(os.path.join(tests.HERE, 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'test.git')) commit = repo.revparse_single('HEAD') # View another commit @@ -159,7 +159,7 @@ class PagureFlaskRepoOldUrltests(tests.Modeltests): self.session.add(item) self.session.commit() forkedgit = os.path.join( - tests.HERE, 'forks', 'pingou', 'test3.git') + self.path, 'forks', 'pingou', 'test3.git') tests.add_content_git_repo(forkedgit) tests.add_readme_git_repo(forkedgit)