示例#1
0
 def test_http_fallback(self):
     responses.add(responses.GET,
                   DOMAIN + '/foo/test_fallback',
                   body='foo',
                   status=200,
                   content_type='text/plain')
     storage = HttpStorage(fallback_domain=DOMAIN)
     f = storage.open('foo/test_fallback')
     self.assertIn('foo', str(f.read()))
     assert len(responses.calls) == 1
示例#2
0
 def test_http_auth(self):
     responses.add(responses.GET,
                   DOMAIN + '/foo/test_auth',
                   body='foo',
                   status=200,
                   content_type='text/plain')
     with self.settings(LOCALDEVSTORAGE_HTTP_PASSWORD='******',
                        LOCALDEVSTORAGE_HTTP_USERNAME='******'):
         storage = HttpStorage(fallback_domain='https://example.com')
     f = storage.open('foo/test_auth')
     self.assertIn('Authorization', responses.calls[0].request.headers)
class HttpStorageTest(TestCase):
    def setUp(self):
        self.storage = HttpStorage(
            fallback_url="https://github.com/piquadrat/django-localdevstorage/blob/master/localdevstorage/"
        )

    def test_http_fallback(self):
        self.f = self.storage.open("base.py")
        self.assertIn("BaseStorage", self.f.read())

    def tearDown(self):
        self.storage.delete("base.py")
示例#4
0
 def test_exists(self):
     responses.add(responses.HEAD,
                   DOMAIN + '/foo/test_exists',
                   body='foo',
                   status=200,
                   content_type='text/plain')
     responses.add(responses.HEAD,
                   DOMAIN + '/foo/test_does_not_exist',
                   body='foo',
                   status=404,
                   content_type='text/plain')
     storage = HttpStorage(fallback_domain=DOMAIN)
     self.assertTrue(storage.exists('foo/test_exists'))
     self.assertFalse(storage.exists('foo/test_does_not_exist'))
 def setUp(self):
     self.storage = HttpStorage(
         fallback_url="https://github.com/piquadrat/django-localdevstorage/blob/master/localdevstorage/"
     )