def test_parse_key_value_tags_missing_equals_sign(self): data = self.__get_valid_data({"keyvaluetags": "foo"}) form = ImageEditBasicForm(instance=self.image, data=data, files=self.__get_files()) self.assertFalse(form.is_valid())
def test_parse_key_value_tags_valid_data_multiple_lines(self): data = self.__get_valid_data({"keyvaluetags": "foo=bar\r\ngoo=tar"}) form = ImageEditBasicForm(instance=self.image, data=data, files=self.__get_files()) self.assertTrue(form.is_valid())
def test_parse_key_value_tags_empty(self): data = self.__get_valid_data({"keyvaluetags": ""}) form = ImageEditBasicForm(instance=self.image, data=data, files=self.__get_files()) self.assertTrue(form.is_valid())
def test_parse_key_value_tags_valid_data(self): data = self.__get_valid_data({"keyvaluetags": "foo=bar"}) form = ImageEditBasicForm(instance=self.image, data=data, files=self.__get_files()) self.assertTrue(form.is_valid()) image = form.save(commit=False) self.assertEquals(1, image.keyvaluetags.count()) self.assertEquals("bar", image.keyvaluetags.get(key="foo").value)