def test_api_change_status_issue_incomplete(self): """ Test the api_change_status_issue method of the flask api. """ headers = {'Authorization': 'token aaabbbcccddd'} # Check status before repo = pagure.get_authorized_project(self.session, 'test') issue = pagure.lib.search_issues(self.session, repo, issueid=1) self.assertEqual(issue.status, 'Open') data = { 'title': 'test issue', } # Incomplete request output = self.app.post( '/api/0/test/issue/1/status', data=data, headers=headers) self.assertEqual(output.status_code, 400) data = json.loads(output.data) self.assertDictEqual( data, { "error": "Invalid or incomplete input submitted", "error_code": "EINVALIDREQ", "errors": {"status": ["Not a valid choice"]} } ) # No change repo = pagure.get_authorized_project(self.session, 'test') issue = pagure.lib.search_issues(self.session, repo, issueid=1) self.assertEqual(issue.status, 'Open')
def test_api_comment_issue_private_un_authorized_project_less(self): """ Test the api_comment_issue method of the flask api. """ # Check before repo = pagure.get_authorized_project(self.session, 'test') issue = pagure.lib.search_issues(self.session, repo, issueid=2) self.assertEqual(len(issue.comments), 0) data = { 'comment': 'This is a very interesting question', } headers = {'Authorization': 'token pingou_foo'} # Valid request but un-authorized output = self.app.post('/api/0/test/issue/2/comment', data=data, headers=headers) self.assertEqual(output.status_code, 401) data = json.loads(output.data) self.assertEqual(pagure.api.APIERROR.EINVALIDTOK.name, data['error_code']) self.assertEqual(pagure.api.APIERROR.EINVALIDTOK.value, data['error']) # No comment added repo = pagure.get_authorized_project(self.session, 'test') issue = pagure.lib.search_issues(self.session, repo, issueid=2) self.assertEqual(len(issue.comments), 0)
def test_api_comment_issue_incomplete_request_project_less(self): """ Test the api_comment_issue method of the flask api. """ headers = {'Authorization': 'token project-less-foo'} # Check comments before repo = pagure.get_authorized_project(self.session, 'test') issue = pagure.lib.search_issues(self.session, repo, issueid=1) self.assertEqual(len(issue.comments), 0) data = { 'title': 'test issue', } # Incomplete request output = self.app.post('/api/0/test/issue/1/comment', data=data, headers=headers) self.assertEqual(output.status_code, 400) data = json.loads(output.data) self.assertDictEqual( data, { "error": "Invalid or incomplete input submitted", "error_code": "EINVALIDREQ", "errors": { "comment": ["This field is required."] } }) # No change repo = pagure.get_authorized_project(self.session, 'test') issue = pagure.lib.search_issues(self.session, repo, issueid=1) self.assertEqual(issue.status, 'Open')
def setUp(self, p_send_email, p_ugt): """ Create a couple of tickets and add tag to the project so we can play with them later. """ super(PagureLibDropIssuetests, self).setUp() p_send_email.return_value = True p_ugt.return_value = True tests.create_projects(self.session) repo = pagure.get_authorized_project(self.session, 'test') # Before issues = pagure.lib.search_issues(self.session, repo) self.assertEqual(len(issues), 0) self.assertEqual(repo.open_tickets, 0) self.assertEqual(repo.open_tickets_public, 0) # Create two issues to play with msg = pagure.lib.new_issue(session=self.session, repo=repo, title='Test issue', content='We should work on this', user='******', ticketfolder=None) self.session.commit() self.assertEqual(msg.title, 'Test issue') self.assertEqual(repo.open_tickets, 1) self.assertEqual(repo.open_tickets_public, 1) msg = pagure.lib.new_issue( session=self.session, repo=repo, title='Test issue #2', content='We should work on this for the second time', user='******', status='Open', ticketfolder=None) self.session.commit() self.assertEqual(msg.title, 'Test issue #2') self.assertEqual(repo.open_tickets, 2) self.assertEqual(repo.open_tickets_public, 2) # After issues = pagure.lib.search_issues(self.session, repo) self.assertEqual(len(issues), 2) # Add tag to the project pagure.lib.new_tag(self.session, 'red', 'red tag', '#ff0000', repo.id) self.session.commit() repo = pagure.get_authorized_project(self.session, 'test') self.assertEqual( str(repo.tags_colored), '[TagColored(id: 1, tag:red, tag_description:red tag, color:#ff0000)]' )
def setUp(self): """ Set up the environnment, ran before every tests. """ super(PagureFlaskPrNoSourcestests, self).setUp() pagure.APP.config['TESTING'] = True pagure.SESSION = self.session pagure.lib.SESSION = self.session pagure.ui.SESSION = self.session pagure.ui.app.SESSION = self.session pagure.ui.filters.SESSION = self.session pagure.ui.fork.SESSION = self.session pagure.ui.repo.SESSION = self.session pagure.ui.issues.SESSION = self.session tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True) # Create foo's fork of pingou's test project item = pagure.lib.model.Project( user_id=2, # foo name='test', description='test project #1', hook_token='aaabbb', is_fork=True, parent_id=1, ) self.session.add(item) self.session.commit() # Create the fork's git repo repo_path = os.path.join(self.path, 'repos', item.path) pygit2.init_repository(repo_path, bare=True) project = pagure.get_authorized_project(self.session, 'test') fork = pagure.get_authorized_project(self.session, 'test', user='******') self.set_up_git_repo(repo=project, fork=fork) # Ensure things got setup straight project = pagure.get_authorized_project(self.session, 'test') self.assertEqual(len(project.requests), 1) # wait for the worker to process the task path = os.path.join(self.path, 'repos', 'test.git', 'refs', 'pull', '1', 'head') cnt = 0 while not os.path.exists(path): time.sleep(0.1) cnt += 1 if cnt == 100: # We're about 10 seconds in, let's bail raise Exception('Sorry, worker took too long')
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(self.path, 'repos'), bare=True) user = tests.FakeUser() user.username = '******' with tests.user_set(pagure.APP, user): # Get the CSRF token output = self.app.get('/test/settings') csrf_token = output.data.split( 'name="csrf_token" type="hidden" value="')[1].split('">')[0] data = { 'milestones': ['v1.0', 'v2.0'], 'milestone_dates': ['', ''], 'csrf_token': csrf_token, } output = self.app.post('/test/update/milestones', data=data, follow_redirects=True) self.assertEqual(output.status_code, 200) # Check the redirect self.assertIn(u'<title>Settings - test - Pagure</title>', output.data) self.assertIn(u'<h3>Settings for test</h3>', output.data) self.assertIn(u'Milestones updated', output.data) # Check the result of the action -- Milestones recorded repo = pagure.get_authorized_project(self.session, 'test') self.assertEqual(repo.milestones, {u'v1.0': u'', u'v2.0': u''})
def test_accessing_pr_branch_deleted(self): """ Test accessing the PR if branch it originates from has been deleted. """ project = pagure.get_authorized_project(self.session, 'test', user='******') # Check the branches before gitrepo = os.path.join(self.path, 'repos', project.path) repo = pygit2.Repository(gitrepo) self.assertEqual(list(repo.listall_references()), ['refs/heads/feature']) # Delete branch of the fork user = tests.FakeUser(username='******') with tests.user_set(pagure.APP, user): output = self.app.post('/fork/foo/test/b/feature/delete', follow_redirects=True) self.assertEqual(output.status_code, 200) # Check the branches after gitrepo = os.path.join(self.path, 'repos', project.path) repo = pygit2.Repository(gitrepo) self.assertEqual(list(repo.listall_references()), []) # View the pull-request output2 = self.app.get('/test/pull-request/1') self.assertEqual(output2.status_code, 200)
def setUp(self): """ Set up the environnment, ran before every tests. """ self.maxDiff = None super(PagureFlaskApiCustomFieldIssuetests, self).setUp() pagure.APP.config['TESTING'] = True pagure.SESSION = self.session pagure.api.SESSION = self.session pagure.api.issue.SESSION = self.session pagure.lib.SESSION = self.session pagure.APP.config['TICKETS_FOLDER'] = None tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, 'tickets')) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) # Create normal issue repo = pagure.get_authorized_project(self.session, 'test') pagure.lib.new_issue( session=self.session, repo=repo, title='Test issue #1', content='We should work on this', user='******', ticketfolder=None, private=False, ) self.session.commit()
def test_delete_fork_button_fork_del_allowed(self): """ Test that the delete button is present when deletions of projects is not allowed but deletions of forks is. """ project = pagure.get_authorized_project(self.session, project_name='test', user='******') self.assertIsNotNone(project) # Ensure the project isn't read-only project.read_only = False self.session.add(project) self.session.commit() user = tests.FakeUser(username='******') with tests.user_set(pagure.APP, user): output = self.app.get('/fork/pingou/test/settings') self.assertEqual(output.status_code, 200) self.assertIn('<form action="/fork/pingou/test/delete"', output.data) self.assertIn(' Delete the forks/pingou/test project', output.data) projects = pagure.lib.search_projects(self.session) self.assertEqual(len(projects), 4)
def test_delete_fork_button_fork_del_allowed_read_only(self): """ Test that the delete button is absent when deletions of projects is not allowed but deletions of forks is but fork is still being processed. """ project = pagure.get_authorized_project(self.session, project_name='test', user='******') self.assertIsNotNone(project) # Ensure the project is read-only project.read_only = True self.session.add(project) self.session.commit() user = tests.FakeUser(username='******') with tests.user_set(pagure.APP, user): output = self.app.get('/fork/pingou/test/settings') self.assertEqual(output.status_code, 200) self.assertNotIn('<form action="/fork/pingou/test/delete"', output.data) self.assertIn( 'title="Action disabled while project\'s ACLs are being ' 'refreshed">', output.data) self.assertIn(' Delete the forks/pingou/test project', output.data)
def test_give_project(self): """ Test the give_project endpoint. """ user = tests.FakeUser() user.username = '******' with tests.user_set(pagure.APP, user): csrf_token = self.get_csrf() self._check_user() # All good data = { 'user': '******', 'csrf_token': csrf_token, } output = self.app.post('/test/give', data=data, follow_redirects=True) self.assertEqual(output.status_code, 200) self.assertIn( '</button>\n The project has been ' 'transferred to foo\n', output.data) self._check_user('foo') # Make sure that the user giving the project is still an admin project = pagure.get_authorized_project(self.session, project_name='test') self.assertEqual(len(project.users), 1) self.assertEqual(project.users[0].user, 'pingou')
def test_give_project_not_owner(self): """ Test the give_project endpoint. """ project = pagure.get_authorized_project(self.session, project_name='test') msg = pagure.lib.add_user_to_project(self.session, project=project, new_user='******', user='******', access='admin') self.session.commit() self.assertEqual(msg, 'User added') user = tests.FakeUser() user.username = '******' with tests.user_set(pagure.APP, user): csrf_token = self.get_csrf() self._check_user() # User isn't the owner data = { 'user': '******', 'csrf_token': csrf_token, } output = self.app.post('/test/give', data=data, follow_redirects=True) self.assertEqual(output.status_code, 403) self.assertIn('<p>You are not allowed to give this project</p>', output.data) self._check_user()
def setUp(self): """ Set up the environnment, ran before every tests. """ super(PagureExcludeGroupIndex, self).setUp() tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True) # Create a ``provenpackger`` group: msg = pagure.lib.add_group( self.session, group_name='provenpackager', display_name='Proven Packagers', description='Packagers having access to all the repo', group_type='user', user='******', is_admin=False, blacklist=[], ) self.session.commit() self.assertEqual(msg, 'User `pingou` added to the group `provenpackager`.') # Add the `provenpackager` group to the test2 project project = pagure.get_authorized_project(self.session, 'test2') msg = pagure.lib.add_group_to_project( session=self.session, project=project, new_group='provenpackager', user='******', ) self.session.commit() self.assertEqual(msg, 'Group added')
def test_delete_fork_when_project_off_refreshing(self): """ Test the delete_repo endpoint for a fork when only deleting main project is forbidden but the fork is being refreshed in the backend """ project = pagure.get_authorized_project(self.session, project_name='test', user='******') self.assertIsNotNone(project) # Ensure the project isn't read-only project.read_only = True self.session.add(project) self.session.commit() user = tests.FakeUser(username='******') with tests.user_set(pagure.APP, user): output = self.app.post('/fork/pingou/test/delete', follow_redirects=True) self.assertEqual(output.status_code, 200) self.assertIn( '</button>\n The ACLs of this project ' 'are being refreshed in the backend this prevents the ' 'project from being deleted. Please wait for this task to ' 'finish before trying again. Thanks!', output.data) projects = pagure.lib.search_projects(self.session) self.assertEqual(len(projects), 4)
def get_authorized_api_project(SESSION, repo, user=None, namespace=None): ''' Helper function to get an authorized_project with optional lock. ''' repo = pagure.get_authorized_project(SESSION, repo, user=user, namespace=namespace) flask.g.repo = repo return repo
def test_pullrequest__repr__(self, p_send_email, p_ugt): """ Test the PullRequest.__repr__ function of pagure.lib.model. """ p_send_email.return_value = True p_ugt.return_value = True tests.create_projects(self.session) # Create a forked repo item = pagure.lib.model.Project( user_id=1, # pingou name='test', description='test project #1', is_fork=True, parent_id=1, hook_token='aaabbbyyy', ) self.session.commit() self.session.add(item) repo = pagure.get_authorized_project(self.session, 'test') forked_repo = pagure.get_authorized_project(self.session, 'test', user='******') # Create an pull-request req = pagure.lib.new_pull_request( session=self.session, repo_from=forked_repo, branch_from='master', repo_to=repo, branch_to='master', title='test pull-request', user='******', requestfolder=None, ) self.assertEqual(req.id, 1) self.assertEqual(req.title, 'test pull-request') self.assertEqual( str(req), 'PullRequest(1, project:test, user:pingou, ' 'title:test pull-request)') request = pagure.lib.search_pull_requests(self.session, requestid=1) self.assertEqual( str(request), 'PullRequest(1, project:test, user:pingou, ' 'title:test pull-request)')
def test_request_pull_reference(self): """ Test if there is a reference created for a new PR. """ project = pagure.get_authorized_project(self.session, 'test') self.assertEqual(len(project.requests), 1) gitrepo = os.path.join(self.path, 'repos', 'test.git') repo = pygit2.Repository(gitrepo) self.assertEqual(list(repo.listall_references()), ['refs/heads/master', 'refs/pull/1/head'])
def _commit_exists(user, namespace, repo, githash): """ Utility method checking if a given commit exists. """ repo_obj = pagure.get_authorized_project( pagure.SESSION, project_name=repo, user=user, namespace=namespace) if not repo_obj: return False reponame = pagure.get_repo_path(repo_obj) git_repo = pygit2.Repository(reponame) return githash in git_repo
def test_drop_issue(self, p_send_email, p_ugt): """ Test the drop_issue of pagure.lib. We had an issue where we could not delete issue that had been tagged with this test, we create two issues, tag one of them and delete it, ensuring it all goes well. """ p_send_email.return_value = True p_ugt.return_value = True repo = pagure.get_authorized_project(self.session, 'test') # Add tag to the second issue issue = pagure.lib.search_issues(self.session, repo, issueid=2) msgs = pagure.lib.update_tags( self.session, issue, tags=['red'], username='******', gitfolder=None, ) self.session.commit() self.assertEqual(msgs, ['Issue tagged with: red']) repo = pagure.get_authorized_project(self.session, 'test') self.assertEqual(len(repo.issues), 2) issue = pagure.lib.search_issues(self.session, repo, issueid=2) self.assertEqual( str(issue.tags), '[TagColored(id: 1, tag:red, tag_description:red tag, color:#ff0000)]' ) # Drop the issue #2 issue = pagure.lib.search_issues(self.session, repo, issueid=2) pagure.lib.drop_issue(self.session, issue, user='******', ticketfolder=None) self.session.commit() repo = pagure.get_authorized_project(self.session, 'test') self.assertEqual(len(repo.issues), 1)
def test_request_pull_fork_reference(self): """ Test if there the references created on the fork. """ project = pagure.get_authorized_project(self.session, 'test', user='******') self.assertEqual(len(project.requests), 0) gitrepo = os.path.join(self.path, 'repos', project.path) repo = pygit2.Repository(gitrepo) self.assertEqual(list(repo.listall_references()), ['refs/heads/feature'])
def setUp(self): """ Set up the environnment, ran before every tests. """ super(PagureFlaskApiIssueCommenttests, self).setUp() pagure.APP.config['TESTING'] = True pagure.SESSION = self.session pagure.api.SESSION = self.session pagure.api.issue.SESSION = self.session pagure.lib.SESSION = self.session pagure.APP.config['TICKETS_FOLDER'] = None tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, 'tickets')) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) # Create normal issue repo = pagure.get_authorized_project(self.session, 'test') msg = pagure.lib.new_issue( session=self.session, repo=repo, title='Test issue #1', content='We should work on this', user='******', ticketfolder=None, private=False, ) self.session.commit() self.assertEqual(msg.title, 'Test issue #1') # Create private issue msg = pagure.lib.new_issue( session=self.session, repo=repo, title='Test issue #2', content='We should work on this', user='******', ticketfolder=None, private=True, ) self.session.commit() self.assertEqual(msg.title, 'Test issue #2') # Create project-less token for user foo item = pagure.lib.model.Token(id='project-less-foo', user_id=2, project_id=None, expiration=datetime.datetime.utcnow() + datetime.timedelta(days=30)) self.session.add(item) self.session.commit() tests.create_tokens_acl(self.session, token_id='project-less-foo')
def test_get_relation_fixes(self): """ Test the get_relation function of pagure.lib.link with fixes. """ link = pagure.lib.link.get_relation( self.session, reponame='test', namespace=None, username=None, text=COMMENTS[0], reftype='fixes', ) self.assertEqual(link, []) tests.create_projects(self.session) link = pagure.lib.link.get_relation( self.session, reponame='test', namespace=None, username=None, text=COMMENTS[2], reftype='fixes', ) self.assertEqual(link, []) # Create the issue repo = pagure.get_authorized_project(self.session, 'test') pagure.lib.new_issue(self.session, repo, title='issue 3', content='content issue 3', user='******', ticketfolder=None, issue_id=3, notify=False) self.session.commit() for idx, comment in enumerate(COMMENTS): link = pagure.lib.link.get_relation(self.session, reponame='test', namespace=None, username=None, text=comment, reftype='fixes') if idx == 2: self.assertEqual( str(link), '[Issue(3, project:test, user:pingou, title:issue 3)]') else: self.assertEqual(link, [])
def _pr_exists(user, namespace, repo, idx): """ Utility method checking if a given PR exists. """ repo_obj = pagure.get_authorized_project( pagure.SESSION, project_name=repo, user=user, namespace=namespace) if not repo_obj: return False pr_obj = pagure.lib.search_pull_requests( pagure.SESSION, project_id=repo_obj.id, requestid=idx) if not pr_obj: return False return pr_obj
def test_tagissue__repr__(self): """ Test the TagIssue.__repr__ function of pagure.lib.model. """ self.test_issue__repr__() repo = pagure.get_authorized_project(self.session, 'test') issues = pagure.lib.search_issues(self.session, repo) self.assertEqual(len(issues), 1) item = pagure.lib.model.Tag(tag='foo') self.session.add(item) self.session.commit() item = pagure.lib.model.TagIssue(issue_uid=issues[0].uid, tag='foo') self.session.add(item) self.session.commit() self.assertEqual(str(item), 'TagIssue(issue:1, tag:foo)')
def _issue_exists(user, namespace, repo, idx): """ Utility method checking if a given issue exists. """ repo_obj = pagure.get_authorized_project( pagure.SESSION, project_name=repo, user=user, namespace=namespace) if not repo_obj: return False issue_obj = pagure.lib.search_issues( pagure.SESSION, repo=repo_obj, issueid=idx) if not issue_obj: return False return issue_obj
def setUp(self): """ Set up the environnment, ran before every tests. """ super(PagureFlaskDeleteRepotests, self).setUp() pagure.APP.config['TESTING'] = True pagure.SESSION = self.session pagure.ui.SESSION = self.session pagure.ui.app.SESSION = self.session pagure.ui.filters.SESSION = self.session pagure.ui.repo.SESSION = self.session # Create some projects tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, 'repos')) self.session.commit() # Create all the git repos tests.create_projects_git(os.path.join(self.path, 'repos')) tests.create_projects_git(os.path.join(self.path, 'docs')) tests.create_projects_git(os.path.join(self.path, 'tickets'), bare=True) tests.create_projects_git(os.path.join(self.path, 'requests'), bare=True) project = pagure.get_authorized_project(self.session, project_name='test') self.assertIsNotNone(project) # Ensure the project isn't read-only project.read_only = False self.session.add(project) self.session.commit() # Create a fork task_id = pagure.lib.fork_project( session=self.session, user='******', repo=project, gitfolder=os.path.join(self.path, 'repos'), docfolder=os.path.join(self.path, 'docs'), ticketfolder=os.path.join(self.path, 'tickets'), requestfolder=os.path.join(self.path, 'requests'), ) pagure.lib.tasks.get_result(task_id).get() # Ensure everything was correctly created projects = pagure.lib.search_projects(self.session) self.assertEqual(len(projects), 4)
def test_view_docs_project_no_docs(self): """ Test the view_docs endpoint with a project that disabled the docs. """ tests.create_projects(self.session) repo = pagure.get_authorized_project(self.session, 'test') tests.create_projects_git(os.path.join(self.path, 'docs')) output = self.app.get('/test/docs') self.assertEqual(output.status_code, 404) repo.settings = {'project_documentation': False} self.session.add(repo) self.session.commit() output = self.app.get('/test/docs', follow_redirects=True) self.assertEqual(output.status_code, 404)
def get_obj_from_path(path): """ Return the Ticket or Request object based on the path provided. """ (username, namespace, reponame, objtype, objid) = _parse_path(path) repo = pagure.get_authorized_project( pagure.SESSION, reponame, user=username, namespace=namespace) if repo is None: raise PagureEvException("Project '%s' not found" % reponame) # find the appropriate object getter function from OBJECTS try: getfunc = OBJECTS[objtype] except KeyError: raise PagureEvException("Invalid object provided: '%s'" % objtype) return getfunc(repo, objid)
def run_as_post_receive_hook(): reponame = pagure.lib.git.get_repo_name(abspath) username = pagure.lib.git.get_username(abspath) namespace = pagure.lib.git.get_repo_namespace(abspath) if pagure.APP.config.get('HOOK_DEBUG', False): print('repo: ', reponame) print('user: '******'namespace:', namespace) repo = pagure.get_authorized_project(pagure.SESSION, reponame, user=username, namespace=namespace) if not repo: print('Unknown repo %s of username: %s' % (reponame, username)) sys.exit(1) pagure.lib.plugins.get_plugin('Read the Doc') # Get the list of branches branches = [ branch.strip() for branch in repo.rtd_hook.branches.split(',') if repo.rtd_hook ] # Remove empty branches branches = [branch.strip() for branch in branches if branch] url = 'http://readthedocs.org/build/%s' % ( repo.rtd_hook.project_name.strip()) for line in sys.stdin: if pagure.APP.config.get('HOOK_DEBUG', False): print(line) (oldrev, newrev, refname) = line.strip().split(' ', 2) refname = refname.replace('refs/heads/', '') if branches: if refname in branches: print('Starting RTD build for %s' % (repo.rtd_hook.project_name.strip())) requests.post(url) else: print('Starting RTD build for %s' % (repo.rtd_hook.project_name.strip())) requests.post(url)
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(self.path, 'repos'), bare=True) project = pagure.lib._get_project(self.session, 'test') # Case 1 - Empty repo with no tags exp = [] tags = pagure.lib.git.get_git_tags_objects(project) self.assertEqual(exp, get_tag_name(tags)) tests.add_readme_git_repo( os.path.join(os.path.join(self.path, 'repos'), 'test.git')) repo = pygit2.Repository( os.path.join(os.path.join(self.path, 'repos'), 'test.git')) # Case 2 - Repo with one commit and no tags exp = [] tags = pagure.lib.git.get_git_tags_objects(project) self.assertEqual(exp, get_tag_name(tags)) # 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(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.get_authorized_project(self.session, 'test2') tests.add_readme_git_repo( os.path.join(os.path.join(self.path, 'repos'), 'test2.git')) repo = pygit2.Repository( os.path.join(os.path.join(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(self.path, repo, exp, 'test2.git') tags = pagure.lib.git.get_git_tags_objects(project) self.assertEqual(exp, get_tag_name(tags))