예제 #1
0
 def test_post_with_name_should_send_request_post_to_tsuru(self, post, er):
     self.request_post.session = {'tsuru_token': 'tokentest'}
     Key.as_view()(self.request_post)
     self.assertEqual(1, post.call_count)
     post.assert_called_with(
         '%s/users/keys' % settings.TSURU_HOST,
         data='{"key": "test-key-qq"}',
         headers={'authorization':
                  self.request_post.session['tsuru_token']})
예제 #2
0
 def test_post_with_name_should_send_request_post_to_tsuru(self, post, er):
     self.request_post.session = {'tsuru_token': 'tokentest'}
     Key.as_view()(self.request_post)
     self.assertEqual(1, post.call_count)
     post.assert_called_with('%s/users/keys' % settings.TSURU_HOST,
                             data='{"key": "test-key-qq"}',
                             headers={
                                 'authorization':
                                 self.request_post.session['tsuru_token']
                             })
예제 #3
0
 def setUp(self):
     self.factory = RequestFactory()
     self.request = self.factory.get('/')
     self.request.session = {"tsuru_token": "admin"}
     self.response = Key.as_view()(self.request)
     self.request_post = self.factory.post('/team/', {'key': 'test-key-qq'})
     self.request_post.session = {"tsuru_token": "admin"}
예제 #4
0
 def setUp(self):
     self.factory = RequestFactory()
     self.request = self.factory.get('/')
     self.request.session = {"tsuru_token": "admin"}
     self.response = Key.as_view()(self.request)
     self.request_post = self.factory.post('/team/', {'key': 'test-key-qq'})
     self.request_post.session = {"tsuru_token": "admin"}
예제 #5
0
 def test_post_without_key_should_return_form_with_errors(self, post):
     request = self.factory.post('/team/', {'key': ''})
     request.session = {"tsuru_token": "admin"}
     response = Key.as_view()(request)
     self.assertIn('form', response.context_data.keys())
     form = response.context_data.get('form')
     self.assertTrue(isinstance(form, KeyForm))
     self.assertEqual(u'This field is required.', form.errors.get('key')[0])
예제 #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 = Key.as_view()(self.request)
     self.request_post = self.factory.post('/team/', {'key': 'test-key-qq'})
     self.request_post.session = {"tsuru_token": "admin"}
예제 #7
0
 def test_post_without_key_should_return_form_with_errors(self, post):
     request = self.factory.post('/team/', {'key': ''})
     request.session = {"tsuru_token": "admin"}
     response = Key.as_view()(request)
     self.assertIn('form', response.context_data.keys())
     form = response.context_data.get('form')
     self.assertTrue(isinstance(form, KeyForm))
     self.assertEqual(u'This field is required.',
                      form.errors.get('key')[0])
예제 #8
0
파일: urls.py 프로젝트: hfeeki/abyss
from django.views.generic.base import TemplateView, RedirectView

class TextPlainView(TemplateView):
    def render_to_response(self, context, **kwargs):
        return super(TextPlainView, self).render_to_response(
            context, content_type='text/plain', **kwargs)

urlpatterns = patterns('',
    url(r'^robots\.txt$', TextPlainView.as_view(template_name='robots.txt')),
    url(r'^favicon\.ico$', RedirectView.as_view(url='/static/img/favicon.ico')),
    url(r'^$', Login.as_view(), name='login'),

    url(r'^login$', Login.as_view(), name='login'),
    url(r'^logout$', Logout.as_view(), name='logout'),
    url(r'^team/$', Team.as_view(), name='team'),
    url(r'^key/$', Key.as_view(), name='token'),
    url(r'^signup$', Signup.as_view(), name='signup'),

    url(r'^apps/$', ListApp.as_view(), name='list-app'),
    url(r'^apps/create/$', CreateApp.as_view(), name='create-app'),
    url(r'^app/run/$', Run.as_view(), name='run'),
    url(r'^app/(?P<app_name>[\w-]+)/$', AppDetail.as_view(), name='detail-app'),
    url(r'^app/(?P<name>[\w-]+)/remove/$', RemoveApp.as_view(), name='remove_app'),
    url(r'^app/(?P<app_name>[\w-]+)/log/$', AppLog.as_view(), name='app_log'),
    url(r'^app/(?P<app_name>[\w-]+)/env/$', AppEnv.as_view(), name='get-env'),
    url(r'^app/(?P<app_name>[\w-]+)/teams/$', AppTeams.as_view(), name='app-teams'),
    url(r'^app/(?P<app_name>[\w-]+)/team/add/$', AppAddTeam.as_view(), name='app-add-team'),
    url(r'^envs/$', "auth.views.env_vars", name='envs'),
)

urlpatterns += staticfiles_urlpatterns()
예제 #9
0
 def test_post_with_error_should_redirects(self, post, er):
     post.return_value = Mock(status_code=500, content='Error')
     response = Key.as_view()(self.request_post)
     self.assertEqual(302, response.status_code)
     self.assertEqual(reverse('key'), response.items()[1][1])
예제 #10
0
 def test_post_without_key_should_not_send_request_to_tsuru(self, post):
     request = self.factory.post('/team/', {'key': ''})
     request.session = {}
     Key.as_view()(request)
     self.assertEqual(0, post.call_count)
예제 #11
0
 def test_invalid_post_should_return_error_message(self, post, error):
     post.return_value = Mock(status_code=500, text='Error')
     Key.as_view()(self.request_post)
     error.assert_called_with(self.request_post, 'Error', fail_silently=True)
예제 #12
0
 def test_successfully_post_should_redirects(self, post, m):
     post.return_value = Mock(status_code=200)
     response = Key.as_view()(self.request_post)
     self.assertEqual(302, response.status_code)
     self.assertEqual(reverse('key'), response.items()[1][1])
예제 #13
0
 def test_valid_postshould_return_message_expected(self, post, success):
     post.return_value = Mock(status_code=200)
     Key.as_view()(self.request_post)
     success.assert_called_with(self.request_post,
                                "The key was successfully added",
                                fail_silently=True)
예제 #14
0
 def test_valid_postshould_return_message_expected(self, post, success):
     post.return_value = Mock(status_code=200)
     Key.as_view()(self.request_post)
     success.assert_called_with(self.request_post, "The key was successfully added", fail_silently=True)
예제 #15
0
 def test_invalid_post_should_return_error_message(self, post, error):
     post.return_value = Mock(status_code=500, text='Error')
     Key.as_view()(self.request_post)
     error.assert_called_with(self.request_post,
                              'Error',
                              fail_silently=True)
예제 #16
0
 def test_post_without_key_should_not_send_request_to_tsuru(self, get, post):
     get.return_value = Mock(status_code=200)
     request = self.factory.post('/team/', {'key': ''})
     request.session = {}
     Key.as_view()(request)
     self.assertEqual(0, post.call_count)
예제 #17
0
 def test_successfully_post_should_redirects(self, post, m):
     post.return_value = Mock(status_code=200)
     response = Key.as_view()(self.request_post)
     self.assertEqual(302, response.status_code)
     self.assertEqual(reverse('key'), response.items()[1][1])
예제 #18
0
 def test_post_with_error_should_redirects(self, post, er):
     post.return_value = Mock(status_code=500, content='Error')
     response = Key.as_view()(self.request_post)
     self.assertEqual(302, response.status_code)
     self.assertEqual(reverse('key'), response.items()[1][1])
예제 #19
0
 def test_post_without_key_should_not_send_request_to_tsuru(self, post):
     request = self.factory.post('/team/', {'key': ''})
     request.session = {}
     Key.as_view()(request)
     self.assertEqual(0, post.call_count)