diff --git a/tests/test_resources_standard.py b/tests/test_resources_standard.py index d77b248..83b3a87 100644 --- a/tests/test_resources_standard.py +++ b/tests/test_resources_standard.py @@ -5,6 +5,12 @@ class StandardResourcesTestCase(BaseRedmineTestCase): + def _test_eq_helper(self, f): + r1 = f() + r2 = f() + self.assertNotEqual(id(r1), id(r2)) + self.assertEqual(r1, r2) + def test_supports_dictionary_like_attribute_retrieval(self): self.response.json.return_value = responses['project']['get'] project = self.redmine.project.get(1) @@ -271,6 +277,9 @@ def test_project_get(self): self.assertEqual(project.id, 1) self.assertEqual(project.name, 'Foo') + def test_project_eq(self): + return self._test_eq_helper(lambda: self.redmine.project.get(1)) + def test_project_all(self): self.response.json.return_value = responses['project']['all'] projects = self.redmine.project.all() @@ -409,6 +418,9 @@ def test_issue_get(self): self.assertEqual(issue.id, 1) self.assertEqual(issue.subject, 'Foo') + def test_issue_eq(self): + return self._test_eq_helper(lambda: self.redmine.issue.get(1)) + def test_issue_all(self): self.response.json.return_value = responses['issue']['all'] issues = self.redmine.issue.all() @@ -681,6 +693,9 @@ def test_time_entry_get(self): self.assertEqual(time_entry.id, 1) self.assertEqual(time_entry.hours, 2) + def test_time_entry_eq(self): + return self._test_eq_helper(lambda: self.redmine.time_entry.get(1)) + def test_time_entry_all(self): self.response.json.return_value = responses['time_entry']['all'] time_entries = self.redmine.time_entry.all() @@ -785,6 +800,9 @@ def test_enumeration_get(self): self.assertEqual(enumeration.id, 1) self.assertEqual(enumeration.name, 'Foo') + def test_enumeration_eq(self): + return self._test_eq_helper(lambda: self.redmine.enumeration.get(1, resource='time_entry_activities')) + def test_enumeration_filter(self): self.response.json.return_value = responses['enumeration']['filter'] enumerations = self.redmine.enumeration.filter(resource='time_entry_activities') @@ -809,6 +827,9 @@ def test_attachment_get(self): self.assertEqual(attachment.id, 1) self.assertEqual(attachment.filename, 'foo.jpg') + def test_attachment_entry_eq(self): + return self._test_eq_helper(lambda: self.redmine.attachment.get(1)) + def test_attachment_update(self): self.response.json.return_value = responses['attachment']['get'] attachment = self.redmine.attachment.get(1) @@ -870,6 +891,9 @@ def test_file_get(self): self.assertEqual(f.id, 1) self.assertEqual(f.filename, 'foo.jpg') + def test_file_eq(self): + return self._test_eq_helper(lambda: self.redmine.file.get(1)) + def test_file_filter(self): self.response.json.return_value = responses['file']['filter'] files = self.redmine.file.filter(project_id=1) @@ -953,6 +977,9 @@ def test_wiki_page_get(self): wiki_page = self.redmine.wiki_page.get('Foo', project_id=1) self.assertEqual(wiki_page.title, 'Foo') + def test_wiki_eq(self): + return self._test_eq_helper(lambda: self.redmine.wiki_page.get('Foo', project_id=1)) + def test_wiki_page_get_special(self): """Test getting a wiki page with special char in title.""" self.response.json.return_value = responses['wiki_page']['get_special'] @@ -1077,6 +1104,9 @@ def test_project_membership_get(self): membership = self.redmine.project_membership.get(1) self.assertEqual(membership.id, 1) + def test_project_membership_eq(self): + return self._test_eq_helper(lambda: self.redmine.project_membership.get(1)) + def test_project_membership_filter(self): self.response.json.return_value = responses['project_membership']['filter'] memberships = self.redmine.project_membership.filter(project_id=1) @@ -1158,6 +1188,9 @@ def test_issue_category_get(self): self.assertEqual(issue_category.id, 1) self.assertEqual(issue_category.name, 'Foo') + def test_issue_category_eq(self): + return self._test_eq_helper(lambda: self.redmine.issue_category.get(1)) + def test_issue_category_filter(self): self.response.json.return_value = responses['issue_category']['filter'] categories = self.redmine.issue_category.filter(project_id=1) @@ -1221,6 +1254,9 @@ def test_issue_relation_get(self): relation = self.redmine.issue_relation.get(1) self.assertEqual(relation.id, 1) + def test_issue_relation_eq(self): + return self._test_eq_helper(lambda: self.redmine.issue_relation.get(1)) + def test_issue_relation_filter(self): self.response.json.return_value = responses['issue_relation']['filter'] relations = self.redmine.issue_relation.filter(issue_id=1) @@ -1273,6 +1309,9 @@ def test_version_get(self): self.assertEqual(version.id, 1) self.assertEqual(version.name, 'Foo') + def test_version_eq(self): + return self._test_eq_helper(lambda: self.redmine.version.get(1)) + def test_version_filter(self): self.response.json.return_value = responses['version']['filter'] versions = self.redmine.version.filter(project_id=1) @@ -1337,6 +1376,9 @@ def test_user_get(self): self.assertEqual(user.id, 1) self.assertEqual(user.firstname, 'John') + def test_user_eq(self): + return self._test_eq_helper(lambda: self.redmine.user.get(1)) + def test_user_get_account(self): self.response.json.return_value = responses['user']['get'] user = self.redmine.user.get('me') @@ -1463,6 +1505,9 @@ def test_group_get(self): self.assertEqual(group.id, 1) self.assertEqual(group.name, 'Foo') + def test_group_eq(self): + return self._test_eq_helper(lambda: self.redmine.group.get(1)) + def test_group_all(self): self.response.json.return_value = responses['group']['all'] groups = self.redmine.group.all() @@ -1538,6 +1583,9 @@ def test_role_get(self): self.assertEqual(role.id, 1) self.assertEqual(role.name, 'Foo') + def test_role_eq(self): + return self._test_eq_helper(lambda: self.redmine.role.get(1)) + def test_role_all(self): self.response.json.return_value = responses['role']['all'] roles = self.redmine.role.all() @@ -1559,6 +1607,9 @@ def test_news_get(self): self.assertEqual(news.id, 1) self.assertEqual(news.title, 'Foo') + def test_news_eq(self): + return self._test_eq_helper(lambda: self.redmine.news.get(1)) + def test_news_all(self): self.response.json.return_value = responses['news']['all'] news = self.redmine.news.all() @@ -1656,6 +1707,9 @@ def test_issue_status_get(self): self.assertEqual(status.id, 1) self.assertEqual(status.name, 'Foo') + def test_issue_status_eq(self): + return self._test_eq_helper(lambda: self.redmine.issue_status.get(1)) + def test_issue_status_all(self): self.response.json.return_value = responses['issue_status']['all'] statuses = self.redmine.issue_status.all() @@ -1677,6 +1731,9 @@ def test_tracker_get(self): self.assertEqual(tracker.id, 1) self.assertEqual(tracker.name, 'Foo') + def test_tracker_eq(self): + return self._test_eq_helper(lambda: self.redmine.tracker.get(1)) + def test_tracker_all(self): self.response.json.return_value = responses['tracker']['all'] trackers = self.redmine.tracker.all() @@ -1698,6 +1755,9 @@ def test_query_get(self): self.assertEqual(query.id, 1) self.assertEqual(query.name, 'Foo') + def test_query_eq(self): + return self._test_eq_helper(lambda: self.redmine.query.get(1)) + def test_query_all(self): self.response.json.return_value = responses['query']['all'] queries = self.redmine.query.all() @@ -1719,6 +1779,9 @@ def test_custom_field_get(self): self.assertEqual(field.id, 1) self.assertEqual(field.name, 'Foo') + def test_custom_field_eq(self): + return self._test_eq_helper(lambda: self.redmine.custom_field.get(1)) + def test_custom_field_all(self): self.response.json.return_value = responses['custom_field']['all'] fields = self.redmine.custom_field.all()