Beispiel #1
0
 def test_app_is_exported_successfully(self, mock_get, mock_render):
     mock_render.return_value = 'OK'
     app_mock = Mock(spec=Application)()
     app_mock.name = 'Gigabit'
     app_mock.has_member.return_value = True
     mock_get.return_value = app_mock
     request = self.factory.get('/app/blue/export')
     request.user = utils.get_user_mock()
     response = views.app_export(request, 'blue')
     mock_get.assert_called_once_with(Application.active, slug__exact='blue')
     mock_render.assert_called_once()
     eq_(response['Content-Type'], 'text/plain')
     ok_('attachment; filename=' in response['Content-Disposition'])
     ok_(response.content, 'OK')
Beispiel #2
0
 def test_non_active_app_raises_404(self, mock_get):
     mock_get.side_effect = Http404
     request = self.factory.get('/app/blue/export')
     request.user = utils.get_user_mock()
     views.app_export(request, 'blue')
Beispiel #3
0
 def test_export_requires_login(self):
     request = self.factory.get('/app/blue/export/')
     request.user = utils.get_anon_mock()
     response = views.app_export(request, 'blue')
     expected_url = utils.get_login_url('/app/blue/export/')
     eq_(response['Location'], expected_url)