From a8f6829009449a0a93490f4eb04fb31330dfb02a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 05 2017 15:24:18 +0000 Subject: Adjust unit-tests for the changes made to the colored tags feature --- diff --git a/tests/test_pagure_flask_api.py b/tests/test_pagure_flask_api.py index cc2269b..c912d38 100644 --- a/tests/test_pagure_flask_api.py +++ b/tests/test_pagure_flask_api.py @@ -76,15 +76,14 @@ class PagureFlaskApitests(tests.Modeltests): ) self.session.add(item) self.session.commit() - item = pagure.lib.model.Tag( + item = pagure.lib.model.TagColored( tag='tag1', tag_color='DeepBlueSky', project_id=1, ) self.session.add(item) self.session.commit() - item = pagure.lib.model.TagIssue( - tag='tag1', + item = pagure.lib.model.TagIssueColored( issue_uid='foobar', - tag_id=tag.tag_id + tag_id=item.id ) self.session.add(item) self.session.commit() diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index ea8b874..6e79890 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -1531,7 +1531,8 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'Settings - test - Pagure', output.data) self.assertIn( - '\n Edited tag: tag1(DeepSkyBlue) to tag2(DeepSkyBlue)', + '\n ' + 'Edited tag: tag1(DeepSkyBlue) to tag2(DeepSkyBlue)', output.data) # After edit, list tags diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py index 7677028..3ea6706 100644 --- a/tests/test_pagure_lib.py +++ b/tests/test_pagure_lib.py @@ -420,7 +420,18 @@ class PagureLibtests(tests.Modeltests): session=self.session, project=repo, old_tag='foo', - old_tag_color='DeepSkyBlue', + new_tag='bar', + new_tag_color='black', + user='pingou', + ticketfolder=None, + ) + + self.assertRaises( + pagure.exceptions.PagureException, + pagure.lib.edit_issue_tags, + session=self.session, + project=repo, + old_tag=None, new_tag='bar', new_tag_color='black', user='pingou', @@ -431,14 +442,16 @@ class PagureLibtests(tests.Modeltests): session=self.session, project=repo, old_tag='tag1', - old_tag_color='DeepSkyBlue', new_tag='tag2', new_tag_color='black', user='pingou', ticketfolder=None, ) self.session.commit() - self.assertEqual(msgs, ['Edited tag: tag1(DeepSkyBlue) to tag2(black)']) + self.assertEqual( + msgs, + ['Edited tag: tag1(DeepSkyBlue) to tag2(black)'] + ) # Add a new tag msg = pagure.lib.add_tag_obj( @@ -458,7 +471,6 @@ class PagureLibtests(tests.Modeltests): session=self.session, project=repo, old_tag='tag2', - old_tag_color='black', new_tag='tag3', new_tag_color='red', user='pingou', @@ -470,7 +482,6 @@ class PagureLibtests(tests.Modeltests): session=self.session, project=repo, old_tag='tag2', - old_tag_color='black', new_tag='tag4', new_tag_color='purple', user='pingou', diff --git a/tests/test_pagure_lib_model.py b/tests/test_pagure_lib_model.py index 9708b4a..696ea42 100644 --- a/tests/test_pagure_lib_model.py +++ b/tests/test_pagure_lib_model.py @@ -132,21 +132,43 @@ class PagureLibModeltests(tests.Modeltests): issues = pagure.lib.search_issues(self.session, repo) self.assertEqual(len(issues), 1) - item = pagure.lib.model.Tag(tag='foo', tag_color='DeepSkyBlue', - project_id=repo.id) + item = pagure.lib.model.Tag(tag='foo') self.session.add(item) self.session.commit() item = pagure.lib.model.TagIssue( - issue=issues[0], issue_uid=issues[0].uid, - tag='foo', - tag_id=item.tag_id + tag='foo' ) self.session.add(item) self.session.commit() self.assertEqual(str(item), 'TagIssue(issue:1, tag:foo)') + def test_tagissuecolor__repr__(self): + """ Test the TagIssue.__repr__ function of pagure.lib.model. """ + self.test_issue__repr__() + repo = pagure.lib.get_project(self.session, 'test') + issues = pagure.lib.search_issues(self.session, repo) + self.assertEqual(len(issues), 1) + + item = pagure.lib.model.TagColored( + tag='foo', + tag_color='DeepSkyBlue', + project_id=repo.id) + self.session.add(item) + self.session.commit() + + item = pagure.lib.model.TagIssueColored( + issue_uid=issues[0].uid, + tag_id=item.id + ) + self.session.add(item) + self.session.commit() + self.assertEqual( + str(item), + 'TagIssueColored(issue:1, tag:foo, project:test)' + ) + if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase(PagureLibModeltests)