def test_with_invalid_input(self): try: get_tag_list(29) except ValueError, ve: self.assertEquals(str(ve), 'The tag input given was invalid.')
def test_with_tag_filter(self): ret = get_tag_list(Tag.objects.filter(name__in=['cheese', 'toast'])) self.assertEquals(len(ret), 2) self.failUnless(self.cheese in ret) self.failUnless(self.toast in ret)
def test_with_invalid_input_mix_of_string_and_instance(self): try: get_tag_list(['cheese', self.toast]) except ValueError, ve: self.assertEquals(str(ve), 'If a list or tuple of tags is provided, they must all be tag names, Tag objects or Tag ids.')
def test_list_of_strings_with_strange_nontag_string(self): ret = get_tag_list(['cheese', 'toast', 'ŠĐĆŽćžšđ']) self.assertEquals(len(ret), 2) self.failUnless(self.cheese in ret) self.failUnless(self.toast in ret)
def test_tuple_of_instances(self): ret = get_tag_list((self.cheese, self.toast)) self.assertEquals(len(ret), 2) self.failUnless(self.cheese in ret) self.failUnless(self.toast in ret)
def test_list_of_tag_primary_keys(self): ret = get_tag_list([self.cheese.id, self.toast.id]) self.assertEquals(len(ret), 2) self.failUnless(self.cheese in ret) self.failUnless(self.toast in ret)
def test_list_of_two_strings(self): ret = get_tag_list(['cheese', 'toast']) self.assertEquals(len(ret), 2) self.failUnless(self.cheese in ret) self.failUnless(self.toast in ret)
def test_with_empty_list(self): self.assertEquals(get_tag_list([]), [])
def test_comma_delimeted_string_as_input(self): ret = get_tag_list('cheese,toast') self.assertEquals(len(ret), 2) self.failUnless(self.cheese in ret) self.failUnless(self.toast in ret)
def test_single_tag_object_as_input(self): self.assertEquals(get_tag_list(self.cheese), [self.cheese])