diff options
author | 2018-09-21 23:09:35 +0200 | |
---|---|---|
committer | 2018-09-21 23:09:35 +0200 | |
commit | adc8dc83dead1afcc9ff83ae7a0f57747a886a4b (patch) | |
tree | ba5335aaed73785d852c6218b942ca7397ffc7ca /api/tests | |
parent | Add `__repr__` to all models. (diff) |
Add `__str__` to all API models.
Diffstat (limited to 'api/tests')
-rw-r--r-- | api/tests/test_models.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/api/tests/test_models.py b/api/tests/test_models.py index 7ed49a78..ff4bb226 100644 --- a/api/tests/test_models.py +++ b/api/tests/test_models.py @@ -1,6 +1,9 @@ from django.test import SimpleTestCase -from ..models import ModelReprMixin +from ..models import ( + DocumentationLink, Member, ModelReprMixin, + OffTopicChannelName, Role, SnakeName +) class SimpleClass(ModelReprMixin): @@ -15,3 +18,26 @@ class ReprMixinTests(SimpleTestCase): def test_shows_attributes(self): expected = "<SimpleClass(the_cake='is a lie')>" self.assertEqual(repr(self.klass), expected) + + +class StringDunderMethodTests(SimpleTestCase): + def setUp(self): + self.objects = ( + DocumentationLink( + 'test', 'http://example.com', 'http://example.com' + ), + OffTopicChannelName(name='bob-the-builders-playground'), + SnakeName(name='python', scientific='3'), + Role( + id=5, name='test role', + colour=0x5, permissions=0 + ), + Member( + id=5, name='bob', + discriminator=1, avatar_hash=None + ) + ) + + def test_returns_string(self): + for instance in self.objects: + self.assertIsInstance(str(instance), str) |