| 57 | |
| 58 | def test_no_whitespace_in_domain(self): |
| 59 | # Test that all whitespace is removed from domain before being saved |
| 60 | incorrect = ' example . com ' |
| 61 | correct = 'example.com' |
| 62 | |
| 63 | new_site = Site.objects.create(domain=incorrect, name="An example site with whitespace in the domain") |
| 64 | site_from_db = Site.objects.get(pk=new_site.pk) |
| 65 | |
| 66 | # Test that domain whitespace has been removed on create() insert |
| 67 | self.assertEqual(site_from_db.domain, correct) |
| 68 | |
| 69 | site_from_db.domain = incorrect |
| 70 | site_from_db.save() |
| 71 | another_site_from_db = Site.objects.get(pk=site_from_db.pk) |
| 72 | |
| 73 | # Test that domain whitespace has been removed on save() update |
| 74 | self.assertEqual(another_site_from_db.domain, correct) |