# HG changeset patch # User Thomas De Schampheleire # Date 2021-09-01 20:44:49 # Node ID 2ef4f7c0031e7470cc20e83cd4589bba2aa5e6c6 # Parent 7da398c076a073b15ba761f082405791d5903cf7 tests: merge test_repo_groups.py into test_admin_repo_groups.py Two files testing the same underlying code. As this code is really in the 'admin' section, merge into test_admin_repo_groups.py. diff --git a/kallithea/tests/functional/test_admin_repo_groups.py b/kallithea/tests/functional/test_admin_repo_groups.py --- a/kallithea/tests/functional/test_admin_repo_groups.py +++ b/kallithea/tests/functional/test_admin_repo_groups.py @@ -9,6 +9,79 @@ fixture = Fixture() class TestRepoGroupsController(base.TestController): + def test_index(self): + self.log_user() + response = self.app.get(base.url('repos_groups')) + response.mustcontain('"records": []') + + def test_new(self): + self.log_user() + response = self.app.get(base.url('new_repos_group')) + + def test_create(self): + self.log_user() + + group_name = 'foo' + + # creation with form error + response = self.app.post(base.url('repos_groups'), + {'group_name': group_name, + '_session_csrf_secret_token': self.session_csrf_secret_token()}) + response.mustcontain('name="group_name" type="text" value="%s"' % group_name) + response.mustcontain('') + + # creation + response = self.app.post(base.url('repos_groups'), + {'group_name': group_name, + 'group_description': 'lala', + 'parent_group_id': '-1', + 'group_copy_permissions': 'True', + '_session_csrf_secret_token': self.session_csrf_secret_token()}) + self.checkSessionFlash(response, 'Created repository group %s' % group_name) + + # edit form + response = self.app.get(base.url('edit_repo_group', group_name=group_name)) + response.mustcontain('>lala<') + + # edit with form error + response = self.app.post(base.url('update_repos_group', group_name=group_name), + {'group_name': group_name, + '_session_csrf_secret_token': self.session_csrf_secret_token()}) + response.mustcontain('name="group_name" type="text" value="%s"' % group_name) + response.mustcontain('') + + # edit + response = self.app.post(base.url('update_repos_group', group_name=group_name), + {'group_name': group_name, + 'group_description': 'lolo', + '_session_csrf_secret_token': self.session_csrf_secret_token()}) + self.checkSessionFlash(response, 'Updated repository group %s' % group_name) + response = response.follow() + response.mustcontain('name="group_name" type="text" value="%s"' % group_name) + response.mustcontain(no='') + response.mustcontain('>lolo<') + + # listing + response = self.app.get(base.url('repos_groups')) + response.mustcontain('raw_name": "%s"' % group_name) + + # show + response = self.app.get(base.url('repos_group', group_name=group_name)) + response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) + + # show ignores extra trailing slashes in the URL + response = self.app.get(base.url('repos_group', group_name='%s//' % group_name)) + response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) + + # delete + response = self.app.post(base.url('delete_repo_group', group_name=group_name), + {'_session_csrf_secret_token': self.session_csrf_secret_token()}) + self.checkSessionFlash(response, 'Removed repository group %s' % group_name) + + def test_new_by_regular_user(self): + self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) + response = self.app.get(base.url('new_repos_group'), status=403) + def test_case_insensitivity(self): self.log_user() group_name = 'newgroup' diff --git a/kallithea/tests/functional/test_repo_groups.py b/kallithea/tests/functional/test_repo_groups.py deleted file mode 100644 --- a/kallithea/tests/functional/test_repo_groups.py +++ /dev/null @@ -1,77 +0,0 @@ -from kallithea.tests import base - - -class TestRepoGroupsController(base.TestController): - - def test_index(self): - self.log_user() - response = self.app.get(base.url('repos_groups')) - response.mustcontain('"records": []') - - def test_new(self): - self.log_user() - response = self.app.get(base.url('new_repos_group')) - - def test_create(self): - self.log_user() - - group_name = 'foo' - - # creation with form error - response = self.app.post(base.url('repos_groups'), - {'group_name': group_name, - '_session_csrf_secret_token': self.session_csrf_secret_token()}) - response.mustcontain('name="group_name" type="text" value="%s"' % group_name) - response.mustcontain('') - - # creation - response = self.app.post(base.url('repos_groups'), - {'group_name': group_name, - 'group_description': 'lala', - 'parent_group_id': '-1', - 'group_copy_permissions': 'True', - '_session_csrf_secret_token': self.session_csrf_secret_token()}) - self.checkSessionFlash(response, 'Created repository group %s' % group_name) - - # edit form - response = self.app.get(base.url('edit_repo_group', group_name=group_name)) - response.mustcontain('>lala<') - - # edit with form error - response = self.app.post(base.url('update_repos_group', group_name=group_name), - {'group_name': group_name, - '_session_csrf_secret_token': self.session_csrf_secret_token()}) - response.mustcontain('name="group_name" type="text" value="%s"' % group_name) - response.mustcontain('') - - # edit - response = self.app.post(base.url('update_repos_group', group_name=group_name), - {'group_name': group_name, - 'group_description': 'lolo', - '_session_csrf_secret_token': self.session_csrf_secret_token()}) - self.checkSessionFlash(response, 'Updated repository group %s' % group_name) - response = response.follow() - response.mustcontain('name="group_name" type="text" value="%s"' % group_name) - response.mustcontain(no='') - response.mustcontain('>lolo<') - - # listing - response = self.app.get(base.url('repos_groups')) - response.mustcontain('raw_name": "%s"' % group_name) - - # show - response = self.app.get(base.url('repos_group', group_name=group_name)) - response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) - - # show ignores extra trailing slashes in the URL - response = self.app.get(base.url('repos_group', group_name='%s//' % group_name)) - response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) - - # delete - response = self.app.post(base.url('delete_repo_group', group_name=group_name), - {'_session_csrf_secret_token': self.session_csrf_secret_token()}) - self.checkSessionFlash(response, 'Removed repository group %s' % group_name) - - def test_new_by_regular_user(self): - self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) - response = self.app.get(base.url('new_repos_group'), status=403)