30 lines
891 B
Python
30 lines
891 B
Python
from django.test import TestCase
|
|
|
|
from byostorage.http import HTTPStorage
|
|
|
|
class HTTPStorageTestCase(TestCase):
|
|
|
|
def test_url(self):
|
|
s = HTTPStorage()
|
|
|
|
self.assertEqual(s.url('//google.com'), 'https://google.com')
|
|
|
|
def test_exists(self):
|
|
s = HTTPStorage()
|
|
|
|
self.assertTrue(s.exists('//gitea.tfconsulting.com.au/tris'))
|
|
self.assertFalse(s.exists('//gitea.tfconsulting.com.au/foo.txt'))
|
|
|
|
def test_save(self):
|
|
return # already caught as suspicious activity
|
|
s = HTTPStorage()
|
|
with self.assertRaisesMessage(NotImplementedError, "Unable to save to web locations"):
|
|
s.save('//gitea.tfconsulting.com.au/foo', 'Some content')
|
|
|
|
def test_open(self):
|
|
s = HTTPStorage()
|
|
with s.open('//gitea.tfconsulting.com.au', 'rb') as f:
|
|
data = f.read()
|
|
|
|
self.assertTrue(len(data) > 4000)
|