コード例 #1
0
 def test_idea_add_submit_schema_succeed(self):
     from flow.shootout.views import idea_add
     from flow.shootout.models import Idea
     self.config.testing_securitypolicy(u'username')
     _register_routes(self.config)
     request = testing.DummyRequest(
         post={
             'form.submitted': u'Shoot',
             'tags': u'abc def, bar',
             'text': u'My idea is cool',
             'title': u'My idea',
         })
     user = self._addUser(u'username')
     result = idea_add(request)
     self.assertEqual(result.location, 'http://example.com/ideas/1')
     ideas = self.session.query(Idea).all()
     self.assertEqual(len(ideas), 1)
     idea = ideas[0]
     self.assertEqual(idea.idea_id, 1)
     self.assertEqual(idea.text, u'My idea is cool')
     self.assertEqual(idea.title, u'My idea')
     self.assertEqual(idea.author, user)
     self.assertEqual(len(idea.tags), 3)
     self.assertEqual(idea.tags[0].name, u'abc')
     self.assertEqual(idea.tags[1].name, u'bar')
     self.assertEqual(idea.tags[2].name, u'def')
コード例 #2
0
 def test_idea_add_not_existing_target(self):
     from flow.shootout.views import idea_add
     self.config.testing_securitypolicy(u'username')
     _register_routes(self.config)
     _register_common_templates(self.config)
     request = testing.DummyRequest(params={'target': 100})
     result = idea_add(request)
     self.assertEqual(result.code, 404)
コード例 #3
0
 def test_idea_add_nosubmit_idea(self):
     from flow.shootout.views import idea_add
     self.config.testing_securitypolicy(u'username')
     _register_routes(self.config)
     _register_common_templates(self.config)
     request = testing.DummyRequest()
     result = idea_add(request)
     self.assertEqual(result['target'], None)
     self.assertEqual(result['kind'], 'idea')
コード例 #4
0
 def test_idea_add_nosubmit_comment(self):
     from flow.shootout.views import idea_add
     self.config.testing_securitypolicy(u'username')
     _register_routes(self.config)
     _register_common_templates(self.config)
     idea = self._addIdea()
     request = testing.DummyRequest(params={'target': idea.idea_id})
     result = idea_add(request)
     self.assertEqual(result['target'], idea)
     self.assertEqual(result['kind'], 'comment')
コード例 #5
0
 def test_idea_add_submit_schema_fail_empty_params(self):
     from flow.shootout.views import idea_add
     self.config.testing_securitypolicy(u'username')
     _register_routes(self.config)
     _register_common_templates(self.config)
     request = testing.DummyRequest(post={'form.submitted': 'Shoot'})
     result = idea_add(request)
     self.assertEqual(
         result['form'].form.errors, {
             'text': u'Missing value',
             'tags': u'Missing value',
             'title': u'Missing value'
         })