Example #1
0
File: tests.py Project: pdc/kanbo
    def test_when_initial_tags_has_three_items_it_should_be_valid(self):
        text = """head
toes
liver"""
        subject = BagForm({'name': 'foo', 'initial_tags': text}, instance=Bag(board=self.board))

        self.assertTrue(subject.is_valid())
Example #2
0
File: views.py Project: pdc/kanbo
def new_bag(request, owner, board):
    if request.method == 'POST':
        form = BagForm(request.POST, instance=Bag(board=board))
        if form.is_valid():
            bag = form.save()
            tag_names = [x.strip() for x in form.cleaned_data['initial_tags'].split()]
            for tag_name in tag_names:
                bag.tag_set.create(name=tag_name)
            return HttpResponseRedirect(board.get_detail_url())
    else:
        form = BagForm(instance=Bag(board=board))
    return {
        'board': board,
        'form': form,
        'non_field_errors': form.errors.get(NON_FIELD_ERRORS),
    }
Example #3
0
File: tests.py Project: pdc/kanbo
    def test_forbids_spaces_in_tags(self):
        subject = BagForm({'name': 'foo', 'initial_tags': 'too many spaces\nanother spacy tag'}, instance=Bag(board=self.board))

        self.assertFalse(subject.is_valid())
Example #4
0
File: tests.py Project: pdc/kanbo
    def test_requires_lowercase(self):
        subject = BagForm({'name': 'Foo', 'initial_tags': 'tag1\ntag2'}, instance=Bag(board=self.board))

        self.assertFalse(subject.is_valid())
Example #5
0
File: tests.py Project: pdc/kanbo
    def test_has_inital_tags_field(self):
        subject = BagForm({'name': 'foo', 'initial_tags': 'tag1\ntag2'}, instance=Bag(board=self.board))

        self.assertTrue(subject.is_valid())
        self.assertEqual('tag1\ntag2', subject.cleaned_data['initial_tags'])