def test_slug_unique_global(self): Simple.slug_globally_unique = True simple_en = Simple() simple_en.set_current_language('en') simple_en.name = 'SimpleOne' simple_en.save() simple_fr = Simple() simple_fr.set_current_language('fr') simple_fr.name = 'SimpleOne' simple_fr.save() self.assertNotEquals(simple_en.slug, simple_fr.slug) Simple.slug_globally_unique = None # default is False simple_en = Simple() simple_en.set_current_language('en') simple_en.name = 'SimpleTwo' simple_en.save() simple_fr = Simple() simple_fr.set_current_language('fr') simple_fr.name = 'SimpleTwo' simple_fr.save() self.assertEquals(simple_en.slug, simple_fr.slug)
def test_slug_unique_for_language(self): simple_en_1 = Simple() simple_en_1.set_current_language('en') simple_en_1.name = 'SimpleOne' simple_en_1.save() # make another instance with same name simple_en_2 = Simple() simple_en_2.set_current_language('en') simple_en_2.name = 'SimpleOne' simple_en_2.save() # slugs should not be same. self.assertNotEquals(simple_en_1.slug, simple_en_2.slug)
def test_existing_object(self): simple = Simple() simple.set_current_language('en') simple.save() # slug is now the default simple.name = 'A new name' simple.slug = None simple.save() self.assertEquals('a-new-name', simple.slug)
def test_limited_length(self): Simple.slug_max_length = 6 try: for r in range(0, 101): simple = Simple() simple.set_current_language('en') simple.name = 'Simple' simple.save() except Exception: self.fail() Simple.slug_max_length = None
def test_limited_length(self): Simple.slug_max_length = 6 try: for r in range(0, 101): simple = Simple() simple.set_current_language('en') simple.name = 'Simple' simple.save() except: self.fail() Simple.slug_max_length = None
def test_simple_slug(self): simple = Simple() simple.set_current_language('en') simple.name = 'Simple' simple.save() self.assertEquals(simple.slug, 'simple')