Beispiel #1
0
    def test_get_context_data(self):
        user = Mock()
        user.domain = None
        app_id = None
        request = Mock()
        request.GET = {}
        request.openrosa_headers = {}
        timing_context = Mock()
        timing_context.to_list.return_value = []
        with patch('corehq.apps.hqadmin.views.get_restore_response',
                   return_value=(HttpResponse('bad response', status=500), timing_context)):

            view = AdminRestoreView(user=user, app_id=app_id, request=request)
            context = view.get_context_data(foo='bar', view='AdminRestoreView')
            self.assertEqual(context, {
                'foo': 'bar',
                'view': 'AdminRestoreView',
                'payload': '<error>Unexpected restore response 500: bad response. If you believe this is a bug '
                           'please report an issue.</error>\n',
                'restore_id': None,
                'status_code': 500,
                'timing_data': [],
                'num_cases': 0,
                'num_locations': 0,
            })
Beispiel #2
0
    def test_get_context_data(self):
        user = Mock()
        user.domain = None
        app_id = None
        request = Mock()
        request.GET = {}
        request.openrosa_headers = {}
        timing_context = Mock()
        timing_context.to_list.return_value = []
        with patch('corehq.apps.ota.views.has_privilege', return_value=False), \
                patch('corehq.apps.hqadmin.views.get_restore_response',
                      return_value=(HttpResponse('bad response', status=500), timing_context)):

            view = AdminRestoreView(user=user, app_id=app_id, request=request)
            context = view.get_context_data(foo='bar', view='AdminRestoreView')
            self.assertEqual(context, {
                'foo': 'bar',
                'view': 'AdminRestoreView',
                'payload': '<error>Unexpected restore response 500: bad response. If you believe this is a bug '
                           'please report an issue.</error>\n',
                'restore_id': None,
                'status_code': 500,
                'timing_data': [],
                'num_cases': 0,
            })
Beispiel #3
0
 url(r'^system/check_services$', check_services, name="check_services"),
 url(r'^system/autostaging/$',
     branches_on_staging,
     name="branches_on_staging"),
 url(r'^auth_as/$', AuthenticateAs.as_view(), name=AuthenticateAs.urlname),
 url(r'^auth_as/(?P<username>[^/]*)/$',
     AuthenticateAs.as_view(),
     name=AuthenticateAs.urlname),
 url(r'^auth_as/(?P<username>[^/]*)/(?P<domain>{})/$'.format(new_domain_re),
     AuthenticateAs.as_view(),
     name=AuthenticateAs.urlname),
 url(r'^superuser_management/$',
     SuperuserManagement.as_view(),
     name=SuperuserManagement.urlname),
 url(r'^run_command/$', run_command, name="run_management_command"),
 url(r'^phone/restore/$', AdminRestoreView.as_view(), name="admin_restore"),
 url(r'^phone/restore/(?P<app_id>[\w-]+)/$',
     AdminRestoreView.as_view(),
     name='app_aware_admin_restore'),
 url(r'^flag_broken_builds/$',
     FlagBrokenBuilds.as_view(),
     name="flag_broken_builds"),
 url(r'^stats_data/$', stats_data, name="admin_stats_data"),
 url(r'^admin_reports_stats_data/$',
     admin_reports_stats_data,
     name="admin_reports_stats_data"),
 url(r'^do_pillow_op/$', pillow_operation_api, name="pillow_operation_api"),
 url(r'^web_user_lookup/$', web_user_lookup, name='web_user_lookup'),
 url(r'^doc_in_es/$', doc_in_es, name='doc_in_es'),
 url(r'^raw_couch/$', raw_couch, name='raw_couch'),
 url(r'^raw_doc/$', raw_doc, name='raw_doc'),
Beispiel #4
0
 url(r'^system/recent_changes/$', RecentCouchChangesView.as_view(),
     name=RecentCouchChangesView.urlname),
 url(r'^system/recent_changes/download/$', download_recent_changes, name="download_recent_changes"),
 url(r'^system/system_ajax$', system_ajax, name="system_ajax"),
 url(r'^system/check_services$', check_services, name="check_services"),
 url(r'^system/autostaging/$', branches_on_staging, name="branches_on_staging"),
 url(r'^auth_as/$', AuthenticateAs.as_view(), name=AuthenticateAs.urlname),
 url(r'^auth_as/(?P<username>[^/]*)/$', AuthenticateAs.as_view(), name=AuthenticateAs.urlname),
 url(r'^auth_as/(?P<username>[^/]*)/(?P<domain>{})/$'.format(new_domain_re),
     AuthenticateAs.as_view(), name=AuthenticateAs.urlname),
 url(r'^management_commands/$', ManagementCommandsView.as_view(),
     name=ManagementCommandsView.urlname),
 url(r'^superuser_management/$', SuperuserManagement.as_view(), name=SuperuserManagement.urlname),
 url(r'^run_command/$', run_command, name="run_management_command"),
 url(r'^vcm_migration/$', VCMMigrationView.as_view(), name=VCMMigrationView.urlname),
 url(r'^phone/restore/$', AdminRestoreView.as_view(), name="admin_restore"),
 url(r'^phone/restore/(?P<app_id>[\w-]+)/$', AdminRestoreView.as_view(), name='app_aware_admin_restore'),
 url(r'^flag_broken_builds/$', FlagBrokenBuilds.as_view(), name="flag_broken_builds"),
 url(r'^stats_data/$', stats_data, name="admin_stats_data"),
 url(r'^admin_reports_stats_data/$', admin_reports_stats_data, name="admin_reports_stats_data"),
 url(r'^do_pillow_op/$', pillow_operation_api, name="pillow_operation_api"),
 url(r'^web_user_lookup/$', web_user_lookup, name='web_user_lookup'),
 url(r'^doc_in_es/$', doc_in_es, name='doc_in_es'),
 url(r'^raw_couch/$', raw_couch, name='raw_couch'),
 url(r'^raw_doc/$', raw_doc, name='raw_doc'),
 url(r'^callcenter_test/$', callcenter_test, name='callcenter_test'),
 (r'^api/', include(admin_api_urlpatterns)),
 url(r'^callcenter_ucr_check/$', CallcenterUCRCheck.as_view(), name=CallcenterUCRCheck.urlname),
 (r'^api/', include(admin_api_urlpatterns)),
 url(r'^download_malt/$',
     DownloadMALTView.as_view(), name=DownloadMALTView.urlname),
Beispiel #5
0
 url(r'^system/$', SystemInfoView.as_view(), name=SystemInfoView.urlname),
 url(r'^system/recent_changes/$', RecentCouchChangesView.as_view(),
     name=RecentCouchChangesView.urlname),
 url(r'^system/recent_changes/download/$', download_recent_changes, name="download_recent_changes"),
 url(r'^system/system_ajax$', system_ajax, name="system_ajax"),
 url(r'^system/check_services$', check_services, name="check_services"),
 url(r'^system/autostaging/$', branches_on_staging, name="branches_on_staging"),
 url(r'^auth_as/$', AuthenticateAs.as_view(), name=AuthenticateAs.urlname),
 url(r'^auth_as/(?P<username>[^/]*)/$', AuthenticateAs.as_view(), name=AuthenticateAs.urlname),
 url(r'^auth_as/(?P<username>[^/]*)/(?P<domain>{})/$'.format(new_domain_re),
     AuthenticateAs.as_view(), name=AuthenticateAs.urlname),
 url(r'^management_commands/$', ManagementCommandsView.as_view(),
     name=ManagementCommandsView.urlname),
 url(r'^superuser_management/$', SuperuserManagement.as_view(), name=SuperuserManagement.urlname),
 url(r'^run_command/$', run_command, name="run_management_command"),
 url(r'^phone/restore/$', AdminRestoreView.as_view(), name="admin_restore"),
 url(r'^phone/restore/(?P<app_id>[\w-]+)/$', AdminRestoreView.as_view(), name='app_aware_admin_restore'),
 url(r'^flag_broken_builds/$', FlagBrokenBuilds.as_view(), name="flag_broken_builds"),
 url(r'^stats_data/$', stats_data, name="admin_stats_data"),
 url(r'^admin_reports_stats_data/$', admin_reports_stats_data, name="admin_reports_stats_data"),
 url(r'^do_pillow_op/$', pillow_operation_api, name="pillow_operation_api"),
 url(r'^web_user_lookup/$', web_user_lookup, name='web_user_lookup'),
 url(r'^doc_in_es/$', doc_in_es, name='doc_in_es'),
 url(r'^raw_couch/$', raw_couch, name='raw_couch'),
 url(r'^raw_doc/$', raw_doc, name='raw_doc'),
 url(r'^callcenter_test/$', callcenter_test, name='callcenter_test'),
 url(r'^api/', include(admin_api_urlpatterns)),
 url(r'^callcenter_ucr_check/$', CallcenterUCRCheck.as_view(), name=CallcenterUCRCheck.urlname),
 url(r'^api/', include(admin_api_urlpatterns)),
 url(r'^download_malt/$',
     DownloadMALTView.as_view(), name=DownloadMALTView.urlname),