def test_proxy_please_wait(self): title_text = 'test-title' body_html = '<p>test-body</p>' proxy = Proxy(please_wait_title='<' + title_text + '>', please_wait_body_html=body_html, logs_path='docker-logs') urlpatterns = proxy.url_patterns() self.assertEqual(len(urlpatterns), 2) response = urlpatterns[-1].callback( request=RequestFactory().get('/fake-url'), container_name='fake-container', url='fake-url') self.assertEqual(response.status_code, 503) self.assertIn('Container not yet available', response.reason_phrase) self.assertIn( '404 Client Error: Not Found ("No such container: fake-container")', response.reason_phrase) self.assertIn('<title><' + title_text + '></title>', str(response.content)) # Title escaped self.assertIn(body_html, str(response.content)) # Body not escaped self.assertIn('http-equiv="refresh"', str(response.content)) # The doctests handle the case where a container has been started. logs_response = urlpatterns[0].callback( request=RequestFactory().get('/fake-url'), container_name='fake-container') self.assertIn('Traceback (most recent call last)', str(logs_response.content)) self.assertIn('No such container: fake-container', str(logs_response.content))
from django_docker_engine.proxy import Proxy urlpatterns = Proxy().url_patterns()
def _check_proxy_csrf(self, csrf_exempt=True): with mock.patch("django_docker_engine.proxy.csrf_exempt_decorator") \ as csrf_exempt_mock: Proxy(csrf_exempt=csrf_exempt).url_patterns() assert csrf_exempt_mock.called == csrf_exempt
from django_docker_engine.proxy import Proxy urlpatterns = Proxy(logs_path='docker-logs').url_patterns()
from os.path import dirname, join from django.conf import settings from django.conf.urls import include, url from django_docker_engine.proxy import FileLogger, Proxy from rest_framework.routers import DefaultRouter from .views import ToolDefinitionsViewSet, ToolsViewSet # DRF url routing tool_manager_router = DefaultRouter() tool_manager_router.register(r'tools', ToolsViewSet) tool_manager_router.register(r'tool_definitions', ToolDefinitionsViewSet) please_wait_path = join(dirname(__file__), 'please-wait.html') with open(please_wait_path, 'r') as f: please_wait_content = f.read() url_patterns = Proxy( settings.DJANGO_DOCKER_ENGINE_DATA_DIR, logger=FileLogger(settings.PROXY_LOG), please_wait_content=please_wait_content ).url_patterns() django_docker_engine_url = url( r'^{}/'.format(settings.DJANGO_DOCKER_ENGINE_BASE_URL), include(url_patterns) )
from django.conf import settings from django.conf.urls import include, url from django_docker_engine.proxy import FileLogger, Proxy from rest_framework.routers import DefaultRouter from .views import ToolDefinitionsViewSet, ToolsViewSet # DRF url routing tool_manager_router = DefaultRouter() tool_manager_router.register(r'tools', ToolsViewSet) tool_manager_router.register(r'tool_definitions', ToolDefinitionsViewSet) url_patterns = Proxy(FileLogger(settings.PROXY_LOG)).url_patterns() django_docker_engine_url = url( r'^{}/'.format(settings.DJANGO_DOCKER_ENGINE_BASE_URL), include(url_patterns))
from django.conf import settings from django.conf.urls import include, url from django_docker_engine.proxy import Proxy from rest_framework.routers import DefaultRouter from .views import ToolDefinitionsViewSet, ToolsViewSet # DRF url routing tool_manager_router = DefaultRouter() tool_manager_router.register(r'tools', ToolsViewSet) tool_manager_router.register(r'tool_definitions', ToolDefinitionsViewSet, base_name="tooldefinition") url_patterns = Proxy( settings.DJANGO_DOCKER_ENGINE_DATA_DIR # please_wait_title='optional title' # please_wait_body='optional html body' ).url_patterns() django_docker_engine_url = url( r'^{}/'.format(settings.DJANGO_DOCKER_ENGINE_BASE_URL), include(url_patterns))