Beispiel #1
0
 def test_should_send_request_post_to_tsuru_with_args_expected(self, put):
     self.request_post.session = {'tsuru_token': 'tokentest'}
     AppAddTeam().post(self.request_post, self.app_name)
     self.assertEqual(1, put.call_count)
     put.assert_called_with(
         '%s/apps/app-test/team-test' % settings.TSURU_HOST,
         headers={'authorization':
                  self.request_post.session['tsuru_token']})
Beispiel #2
0
 def setUp(self, get):
     self.factory = RequestFactory()
     self.request = self.factory.get('/')
     self.request.session = {}
     self.app_name = 'app-test'
     content = u'[{"name": "tsuruteam"}, {"name": "teamvieira"}]'
     m = Mock(status_code=200, content=content)
     m.json.return_value = json.loads(content)
     get.return_value = m
     self.response = AppAddTeam().get(self.request, self.app_name)
     self.request_post = self.factory.post('/', {'team': 'team-test'})
     self.request_post.session = {}
     self.response_mock = Mock()
 def test_post_invalid_form_should_return_form_with_errors(self, get, put):
     content = (u"""[{"name":"teamtsuru"},""" +
                u"""{"Name":"teamestag"},{"Name":"teambla"}]""")
     m = Mock(status_code=200, content=content)
     m.json.return_value = json.loads(content)
     get.return_value = m
     request = self.factory.post('/', {'team': ''})
     request.session = {}
     response = AppAddTeam().post(request, self.app_name)
     self.assertIn('form', response.context_data.keys())
     form = response.context_data.get('form')
     self.assertIsInstance(form, AppAddTeamForm)
     self.assertEqual(u'This field is required.', form.errors.get('team')[0])
Beispiel #4
0
 def test_invalid_post_should_not_send_request_to_tsuru(self, put):
     request = self.factory.post('/', {'team': ''})
     request.session = {}
     AppAddTeam().post(request, self.app_name)
     self.assertEqual(0, put.call_count)
Beispiel #5
0
 def test_post_with_invalid_data_should_return_context_with_form(self, put):
     put.return_value = Mock(content='Error', status_code=500)
     response = AppAddTeam().post(self.request_post, self.app_name)
     self.assertIn('form', response.context_data.keys())
     self.assertTrue(isinstance(response.context_data.get('form'),
                                AppAddTeamForm))
Beispiel #6
0
 def test_post_with_invalid_app_or_team(self, put):
     put.return_value = Mock(content='Error', status_code=500)
     response = AppAddTeam().post(self.request_post, self.app_name)
     self.assertEqual('Error', response.context_data.get('errors'))
Beispiel #7
0
 def test_post_with_valid_and_team(self, put):
     put.return_value = Mock(status_code=200)
     response = AppAddTeam().post(self.request_post, self.app_name)
     self.assertEqual("The Team was successfully added",
                      response.context_data.get('message'))
Beispiel #8
0
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()