I have a model:
class Order(models.Model):
STATUS_CHOICES = (
(100, 'First'),
(200, 'Second'),
)
status = models.IntegerField('Status', choices=STATUS_CHOICES)
def accept(self):
self.status = 200
self.save()
return self.status, self.get_status_display()
And I have a Unit-Test for it:
class CustomTestCase(TestCase):
@classmethod
def setUp(self):
pass
@classmethod
def save(self):
pass
class OrderTest(CustomTestCase):
def test_accept(self):
result = Order.accept(self)
expected = (200, 'Second')
self.assertEqual(expected, result)
As you can see, i added 'save' function that do nothing, the reason for that is because without that custom 'save' function I keep getting this error:
[OrderTest] object has no attribute [save]
If there is a better solution to that custom 'save' function please tell me. But this kind of solution will not work with django-built-in 'get_status_display()' function. And without solution I keep getting this trouble:
[OrderTest] object has no attribute [get_status_display]
What can I do to make this work as I need ?