def test_form_instantiation(self): value_string = "Valid Text" data = {} for category in self.categories: category = category.replace(" ", "_").lower() data[category] = value_string data['name'] = 'Jeff' form = NodeForm(data) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data['business_units'], value_string)
def test_tag_save(self): form = NodeForm(self.form_values) self.assertTrue(form.is_valid()) form.save() tags = Tag.objects.all().exclude(category__id=1) for tag in tags: expected_values = self.form_values[normalize_string( tag.category.name)] expected_values = [normalize_string( x) for x in expected_values.split(",")] self.assertTrue(tag.metadata.name in expected_values) tag = Tag.objects.get(category__id=1) self.assertTrue(tag)