コード例 #1
0
ファイル: server.py プロジェクト: merlian/django-slumber
 def test_slumber_local_url_with_services_but_no_service_specified(self):
     with patch(
         "slumber.server.get_slumber_directory",
         lambda: {"pizzas": "http://localhost:8000:/slumber/pizzas/", "takeaway": "http://localhost:8002:/slumber/"},
     ):
         with self.assertRaises(NoServiceSpecified):
             self.assertEqual(get_slumber_local_url_prefix(), "http://localhost:8000:/")
コード例 #2
0
 def test_slumber_local_url_with_services(self):
     with patch('slumber.server.get_slumber_directory', lambda: {
             'pizzas': 'http://localhost:8000:/slumber/pizzas/',
             'takeaway': 'http://localhost:8002:/slumber/'}):
         with patch('slumber.server.get_slumber_service', lambda: 'pizzas'):
             self.assertEqual(get_slumber_local_url_prefix(),
             'http://localhost:8000:/')
コード例 #3
0
ファイル: server.py プロジェクト: merlian/django-slumber
 def test_slumber_local_url_with_services(self):
     with patch(
         "slumber.server.get_slumber_directory",
         lambda: {"pizzas": "http://localhost:8000:/slumber/pizzas/", "takeaway": "http://localhost:8002:/slumber/"},
     ):
         with patch("slumber.server.get_slumber_service", lambda: "pizzas"):
             self.assertEqual(get_slumber_local_url_prefix(), "http://localhost:8000:/")
コード例 #4
0
 def test_slumber_local_url_with_services_but_no_service_specified(self):
     with patch('slumber.server.get_slumber_directory', lambda: {
             'pizzas': 'http://localhost:8000:/slumber/pizzas/',
             'takeaway': 'http://localhost:8002:/slumber/'}):
         with self.assertRaises(NoServiceSpecified):
             self.assertEqual(get_slumber_local_url_prefix(),
             'http://localhost:8000:/')
コード例 #5
0
ファイル: server.py プロジェクト: DjNero/django-slumber
 def test_slumber_local_url_with_services_but_no_service_specified(self):
     with patch('slumber.server.get_slumber_directory', lambda: {
             'pizzas': 'http://localhost:8000:/slumber/pizzas/',
             'takeaway': 'http://localhost:8002:/slumber/'}):
         with self.assertRaises(NoServiceSpecified):
             self.assertEqual(get_slumber_local_url_prefix(),
             'http://localhost:8000:/')
コード例 #6
0
ファイル: server.py プロジェクト: DjNero/django-slumber
 def test_slumber_local_url_with_services(self):
     with patch('slumber.server.get_slumber_directory', lambda: {
             'pizzas': 'http://localhost:8000:/slumber/pizzas/',
             'takeaway': 'http://localhost:8002:/slumber/'}):
         with patch('slumber.server.get_slumber_service', lambda: 'pizzas'):
             self.assertEqual(get_slumber_local_url_prefix(),
             'http://localhost:8000:/')
コード例 #7
0
ファイル: server.py プロジェクト: merlian/django-slumber
 def test_slumber_local_url_with_services_but_relative_self_service_url(self):
     with patch(
         "slumber.server.get_slumber_directory",
         lambda: {"pizzas": "/slumber/pizzas/", "takeaway": "http://localhost:8002:/slumber/"},
     ):
         with patch("slumber.server.get_slumber_service", lambda: "pizzas"):
             with self.assertRaises(AbsoluteURIRequired):
                 self.assertEqual(get_slumber_local_url_prefix(), "http://localhost:8000:/")
コード例 #8
0
 def test_slumber_local_url_with_services_but_relative_self_service_url(self):
     with patch('slumber.server.get_slumber_directory', lambda: {
             'pizzas': '/slumber/pizzas/',
             'takeaway': 'http://localhost:8002:/slumber/'}):
         with patch('slumber.server.get_slumber_service', lambda: 'pizzas'):
             with self.assertRaises(AbsoluteURIRequired):
                 self.assertEqual(get_slumber_local_url_prefix(),
                 'http://localhost:8000:/')
コード例 #9
0
ファイル: server.py プロジェクト: DjNero/django-slumber
 def test_slumber_local_url_with_services_but_relative_self_service_url(self):
     with patch('slumber.server.get_slumber_directory', lambda: {
             'pizzas': '/slumber/pizzas/',
             'takeaway': 'http://localhost:8002:/slumber/'}):
         with patch('slumber.server.get_slumber_service', lambda: 'pizzas'):
             with self.assertRaises(AbsoluteURIRequired):
                 self.assertEqual(get_slumber_local_url_prefix(),
                 'http://localhost:8000:/')
コード例 #10
0
ファイル: ua.py プロジェクト: vernomcrp/django-slumber
def _use_fake(url):
    """Return the local URL fragment if the request should use the Fake
    HTTP client as it is local, otherwise return None
    """
    slumber_local = get_slumber_local_url_prefix()
    if url.startswith(slumber_local):
        logging.debug("Using local fake HTTP due to %s starting with %s", url, slumber_local)
        return url[len(slumber_local) - 1 :]
    elif url.startswith("/"):
        logging.debug("Using local fake HTTP due to %s starting with /", url)
        return url
    logging.debug("Using real HTTP for %s", url)
コード例 #11
0
ファイル: ua.py プロジェクト: miraculixx/django-slumber
def _use_fake(url):
    """Return the local URL fragment if the request should use the Fake
    HTTP client as it is local, otherwise return None
    """
    slumber_local = get_slumber_local_url_prefix()
    if url.startswith(slumber_local):
        logging.debug("Using local fake HTTP due to %s starting with %s", url,
                      slumber_local)
        return url[len(slumber_local) - 1:]
    elif url.startswith('/'):
        logging.debug("Using local fake HTTP due to %s starting with /", url)
        return url
    logging.debug("Using real HTTP for %s", url)
コード例 #12
0
ファイル: server.py プロジェクト: pombredanne/django-slumber
 def test_slumber_local_url_https(self):
     with patch('slumber.server.get_slumber_directory',
                lambda: 'https://example.com/somewhere/slumber/'):
         self.assertEqual(get_slumber_local_url_prefix(),
                          'https://example.com/')
コード例 #13
0
ファイル: server.py プロジェクト: pombredanne/django-slumber
 def test_slumber_local_url_dev_server(self):
     with patch('slumber.server.get_slumber_directory',
                lambda: 'http://localhost:8008/somewhere/slumber/'):
         self.assertEqual(get_slumber_local_url_prefix(),
                          'http://localhost:8008/')
コード例 #14
0
ファイル: server.py プロジェクト: merlian/django-slumber
 def test_slumber_local_url_https(self):
     with patch("slumber.server.get_slumber_directory", lambda: "https://example.com/somewhere/slumber/"):
         self.assertEqual(get_slumber_local_url_prefix(), "https://example.com/")
コード例 #15
0
ファイル: server.py プロジェクト: merlian/django-slumber
 def test_slumber_local_url_dev_server(self):
     with patch("slumber.server.get_slumber_directory", lambda: "http://localhost:8008/somewhere/slumber/"):
         self.assertEqual(get_slumber_local_url_prefix(), "http://localhost:8008/")
コード例 #16
0
ファイル: server.py プロジェクト: DjNero/django-slumber
 def test_slumber_local_url(self):
     with patch('slumber.server.get_slumber_directory',
             lambda: 'http://example.com/somewhere/slumber/'):
         self.assertEqual(get_slumber_local_url_prefix(),
             'http://example.com/')