Пример #1
0
 def test_post_sends_request_to_tsuru(self, get, post):
     get.return_value = Mock(status_code=200)
     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']})
Пример #2
0
 def test_post_sends_request_to_tsuru(self, get, post):
     get.return_value = Mock(status_code=200)
     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']
                             })
Пример #3
0
 def test_post_without_name_should_return_form_with_errors(self, get):
     get.return_value = Mock(status_code=200)
     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'))
Пример #4
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"}
Пример #5
0
 def test_post_without_name_should_return_form_with_errors(self, get):
     get.return_value = Mock(status_code=200)
     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'))
Пример #6
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"}
Пример #7
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'))
Пример #8
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])
Пример #9
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'))
Пример #10
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()[2][1])