def test_valid_twitter_feed(self): """A known-valid twitter feed will validate""" form = FeedForm(data={ 'name': "twitter", 'feed_type': Feed.TYPE_TWIITER }) self.assertTrue(form.is_valid())
def test_invalid_twitter_feed(self): """Don't allow creating an invalid twitter feed""" form = FeedForm(data={ 'name': "there's no such twitter feed", 'feed_type': Feed.TYPE_TWIITER }) self.assertFalse(form.is_valid())
def create_edit_feed(request, feed_id=None): if feed_id: feed = get_object_or_404(Feed, pk=feed_id) else: feed = Feed() if request.method == 'POST': form = FeedForm(request.POST, instance=feed) if form.is_valid(): feed = form.save() messages.info(request, "Message Feed saved successfully") return redirect('adherence-dashboard') else: form = FeedForm(instance=feed) context = { 'feed': feed, 'form': form, } return render(request, 'adherence/create_edit_feed.html', context)
def test_valid_twitter_feed(self): """A known-valid twitter feed will validate""" form = FeedForm(data={'name': "twitter", 'feed_type': Feed.TYPE_TWIITER}) self.assertTrue(form.is_valid())
def test_invalid_twitter_feed(self): """Don't allow creating an invalid twitter feed""" form = FeedForm(data={'name': "there's no such twitter feed", 'feed_type': Feed.TYPE_TWIITER}) self.assertFalse(form.is_valid())