Skip to content

Commit 596b75c

Browse files
kseeverRoss Mechanic
authored andcommitted
small tweaks to test names for history change reason (#406)
1 parent 11b8038 commit 596b75c

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Authors
6060
- Nathan Villagaray-Carski
6161
- Mike Spainhower
6262
- Alexander Anikeev
63+
- Kyle Seever
6364

6465
Background
6566
==========

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ To run tox and generate an HTML code coverage report (available in the
6060

6161
make test
6262

63-
To quickly run the tests against a single version of Python and Django::
63+
To quickly run the tests against a single version of Python and Django (note: you must ``pip install django`` beforehand)::
6464

6565
python setup.py test

simple_history/tests/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ class UUIDDefaultModel(models.Model):
439439
setattr(settings, 'SIMPLE_HISTORY_HISTORY_CHANGE_REASON_USE_TEXT_FIELD', True)
440440

441441

442-
class TextFieldChangeReasonModel1(models.Model):
442+
class DefaultTextFieldChangeReasonModel(models.Model):
443443
greeting = models.CharField(max_length=100)
444444
history = HistoricalRecords()
445445

@@ -448,7 +448,7 @@ class TextFieldChangeReasonModel1(models.Model):
448448
delattr(settings, 'SIMPLE_HISTORY_HISTORY_CHANGE_REASON_USE_TEXT_FIELD')
449449

450450

451-
class TextFieldChangeReasonModel2(models.Model):
451+
class UserTextFieldChangeReasonModel(models.Model):
452452
greeting = models.CharField(max_length=100)
453453
history = HistoricalRecords(
454454
history_change_reason_field=models.TextField(null=True)

simple_history/tests/tests/test_models.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
UUIDModel,
5555
UUIDDefaultModel,
5656
WaterLevel,
57-
TextFieldChangeReasonModel1,
58-
TextFieldChangeReasonModel2,
57+
DefaultTextFieldChangeReasonModel,
58+
UserTextFieldChangeReasonModel,
5959
CharFieldChangeReasonModel,
6060
)
6161

@@ -408,33 +408,39 @@ def test_charfield_history_change_reason(self):
408408
self.assertTrue(isinstance(field, models.CharField))
409409
self.assertTrue(field.max_length, 100)
410410

411-
def test_textfield_history_change_reason1(self):
411+
def test_default_textfield_history_change_reason(self):
412412
# TextField usage is determined by settings
413-
entry = TextFieldChangeReasonModel1.objects.create(
413+
entry = DefaultTextFieldChangeReasonModel.objects.create(
414414
greeting="what's up?"
415415
)
416416
entry.greeting = "what is happening?"
417417
entry.save()
418-
update_change_reason(entry, 'Change greeting.')
418+
419+
reason = 'Change greeting'
420+
update_change_reason(entry, reason)
419421

420422
history = entry.history.all()[0]
421423
field = history._meta.get_field('history_change_reason')
422424

423425
self.assertTrue(isinstance(field, models.TextField))
426+
self.assertEquals(history.history_change_reason, reason)
424427

425-
def test_textfield_history_change_reason2(self):
428+
def test_user_textfield_history_change_reason(self):
426429
# TextField instance is passed in init
427-
entry = TextFieldChangeReasonModel2.objects.create(
430+
entry = UserTextFieldChangeReasonModel.objects.create(
428431
greeting="what's up?"
429432
)
430433
entry.greeting = "what is happening?"
431434
entry.save()
432-
update_change_reason(entry, 'Change greeting.')
435+
436+
reason = 'Change greeting'
437+
update_change_reason(entry, reason)
433438

434439
history = entry.history.all()[0]
435440
field = history._meta.get_field('history_change_reason')
436441

437442
self.assertTrue(isinstance(field, models.TextField))
443+
self.assertEqual(history.history_change_reason, reason)
438444

439445
def test_get_prev_record(self):
440446
poll = Poll(question="what's up?", pub_date=today)

0 commit comments

Comments
 (0)