Ejemplo n.º 1
0
 def test_post_sends_request_to_tsuru(self, post):
     self.request_post.session = {'tsuru_token': 'tokentest'}
     Add.as_view()(self.request_post)
     self.assertEqual(1, post.call_count)
     post.assert_called_with(
         '%s/teams' % settings.TSURU_HOST,
         data='{"name": "test-team"}',
         headers={'authorization':
                  self.request_post.session['tsuru_token']})
Ejemplo n.º 2
0
 def test_post_sends_request_to_tsuru(self, post):
     self.request_post.session = {'tsuru_token': 'tokentest'}
     Add.as_view()(self.request_post)
     self.assertEqual(1, post.call_count)
     post.assert_called_with('%s/teams' % settings.TSURU_HOST,
                             data='{"name": "test-team"}',
                             headers={
                                 'authorization':
                                 self.request_post.session['tsuru_token']
                             })
Ejemplo n.º 3
0
 def test_post_without_name_should_return_form_with_errors(self):
     request = self.factory.post('/team/', {'name': ''})
     request.session = {"tsuru_token": "admin"}
     response = Add.as_view()(request)
     form = response.context_data.get('form')
     self.assertIn('name', form.errors)
     self.assertIn(u'This field is required.', form.errors.get('name'))
Ejemplo n.º 4
0
 def setUp(self):
     self.factory = RequestFactory()
     self.request = self.factory.get('/')
     self.request.session = {"tsuru_token": "admin"}
     self.response = Add.as_view()(self.request)
     self.request_post = self.factory.post('/team/', {'name': 'test-team'})
     self.request_post.session = {"tsuru_token": "admin"}
Ejemplo n.º 5
0
 def test_post_without_name_should_return_form_with_errors(self):
     request = self.factory.post('/team/', {'name': ''})
     request.session = {"tsuru_token": "admin"}
     response = Add.as_view()(request)
     form = response.context_data.get('form')
     self.assertIn('name', form.errors)
     self.assertIn(u'This field is required.', form.errors.get('name'))
Ejemplo n.º 6
0
 def setUp(self):
     self.factory = RequestFactory()
     self.request = self.factory.get('/')
     self.request.session = {"tsuru_token": "admin"}
     self.response = Add.as_view()(self.request)
     self.request_post = self.factory.post('/team/', {'name': 'test-team'})
     self.request_post.session = {"tsuru_token": "admin"}
Ejemplo n.º 7
0
 def setUp(self, get):
     get.return_value = Mock(status_code=200)
     self.factory = RequestFactory()
     self.request = self.factory.get('/')
     self.request.session = {"tsuru_token": "admin"}
     self.response = Add.as_view()(self.request)
     self.request_post = self.factory.post('/team/', {'name': 'test-team'})
     self.request_post.session = {"tsuru_token": "admin"}
Ejemplo n.º 8
0
 def setUp(self, get):
     get.return_value = Mock(status_code=200)
     self.factory = RequestFactory()
     self.request = self.factory.get('/')
     self.request.session = {"tsuru_token": "admin"}
     self.response = Add.as_view()(self.request)
     self.request_post = self.factory.post('/team/', {'name': 'test-team'})
     self.request_post.session = {"tsuru_token": "admin"}
Ejemplo n.º 9
0
 def test_post_with_invalid_name_should_return_500(self, post):
     post.return_value = Mock(status_code=500, content='Error')
     response = Add.as_view()(self.request_post)
     self.assertEqual('Error', response.context_data.get('errors'))
Ejemplo n.º 10
0
 def test_valid_post_redirect_to_team_list(self, post):
     post.return_value = Mock(status_code=200)
     response = Add.as_view()(self.request_post)
     self.assertEqual(302, response.status_code)
     self.assertEqual(reverse('team-list'), response.items()[1][1])
Ejemplo n.º 11
0
 def test_post_with_invalid_name_should_return_500(self, get, post):
     get.return_value = Mock(status_code=200)
     post.return_value = Mock(status_code=500, content='Error')
     response = Add.as_view()(self.request_post)
     self.assertEqual('Error', response.context_data.get('errors'))
Ejemplo n.º 12
0
 def test_valid_post_redirect_to_team_list(self, get, post):
     get.return_value = Mock(status_code=200)
     post.return_value = Mock(status_code=200)
     response = Add.as_view()(self.request_post)
     self.assertEqual(302, response.status_code)
     self.assertEqual(reverse('team-list'), response.items()[1][1])