-
Notifications
You must be signed in to change notification settings - Fork 105
One to one field custom related name fix #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/usr/bin/env python | ||
| # coding: utf-8 | ||
|
|
||
| """ | ||
| django-reversion-compare unittests | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| I used the setup from reversion_compare_test_project ! | ||
|
|
||
| TODO: | ||
| * models.IntegerField() | ||
|
|
||
| :copyleft: 2012-2015 by the django-reversion-compare team, see AUTHORS for more details. | ||
| :license: GNU GPL v3 or above, see LICENSE for more details. | ||
| """ | ||
|
|
||
| from __future__ import absolute_import, division, print_function | ||
|
|
||
|
|
||
| try: | ||
| import django_tools | ||
| except ImportError as err: | ||
| msg = ( | ||
| "Please install django-tools for unittests" | ||
| " - https://github.com/jedie/django-tools/" | ||
| " - Original error: %s" | ||
| ) % err | ||
| raise ImportError(msg) | ||
|
|
||
| from reversion import get_for_object | ||
|
|
||
| from .test_utils.test_cases import BaseTestCase | ||
| from .test_utils.test_data import TestData | ||
|
|
||
|
|
||
| class OneToOneFieldTest(BaseTestCase): | ||
| "Test a model which uses a custom reversion manager." | ||
|
|
||
| def setUp(self): | ||
| super(OneToOneFieldTest, self).setUp() | ||
| test_data = TestData(verbose=False) | ||
| self.person, self.item = test_data.create_PersonIdentity_data() | ||
|
|
||
| queryset = get_for_object(self.person) | ||
| self.version_ids = queryset.values_list("pk", flat=True) | ||
|
|
||
| def test_select_compare(self): | ||
| response = self.client.get("/admin/tests/person/%s/history/" % self.person.pk) | ||
|
|
||
| self.assertContainsHtml(response, | ||
| '<input type="submit" value="compare">', | ||
| '<input type="radio" name="version_id1" value="%i" style="visibility:hidden" />' % self.version_ids[0], | ||
| '<input type="radio" name="version_id2" value="%i" checked="checked" />' % self.version_ids[0], | ||
| '<input type="radio" name="version_id1" value="%i" checked="checked" />' % self.version_ids[1], | ||
| '<input type="radio" name="version_id2" value="%i" />' % self.version_ids[1], | ||
| ) | ||
|
|
||
| def test_compare(self): | ||
| response = self.client.get( | ||
| "/admin/tests/person/%s/history/compare/" % self.person.pk, | ||
| data={"version_id2":self.version_ids[0], "version_id1":self.version_ids[1]} | ||
| ) | ||
|
|
||
| self.assertContainsHtml(response, | ||
| """ | ||
| <pre class="highlight"> | ||
| <del>- Dave</del> | ||
| <ins>+ John</ins> | ||
| </pre> | ||
| """, | ||
| "<blockquote>version 2: change person name.</blockquote>", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this line is not needed anymore, it should be deleted.