Run black on moto & test directories.
This commit is contained in:
parent
c820395dbf
commit
96e5b1993d
507 changed files with 52541 additions and 47814 deletions
|
|
@ -4,16 +4,16 @@ import sure # noqa
|
|||
from flask.testing import FlaskClient
|
||||
import moto.server as server
|
||||
|
||||
'''
|
||||
"""
|
||||
Test the different server responses
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
class AuthenticatedClient(FlaskClient):
|
||||
def open(self, *args, **kwargs):
|
||||
kwargs['headers'] = kwargs.get('headers', {})
|
||||
kwargs['headers']['Authorization'] = "Any authorization header"
|
||||
kwargs['content_length'] = 0 # Fixes content-length complaints.
|
||||
kwargs["headers"] = kwargs.get("headers", {})
|
||||
kwargs["headers"]["Authorization"] = "Any authorization header"
|
||||
kwargs["content_length"] = 0 # Fixes content-length complaints.
|
||||
return super(AuthenticatedClient, self).open(*args, **kwargs)
|
||||
|
||||
|
||||
|
|
@ -26,42 +26,41 @@ def authenticated_client():
|
|||
def test_s3_server_get():
|
||||
test_client = authenticated_client()
|
||||
|
||||
res = test_client.get('/')
|
||||
res = test_client.get("/")
|
||||
|
||||
res.data.should.contain(b'ListAllMyBucketsResult')
|
||||
res.data.should.contain(b"ListAllMyBucketsResult")
|
||||
|
||||
|
||||
def test_s3_server_bucket_create():
|
||||
test_client = authenticated_client()
|
||||
|
||||
res = test_client.put('/foobar', 'http://localhost:5000')
|
||||
res = test_client.put("/foobar", "http://localhost:5000")
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
res = test_client.get('/')
|
||||
res.data.should.contain(b'<Name>foobar</Name>')
|
||||
res = test_client.get("/")
|
||||
res.data.should.contain(b"<Name>foobar</Name>")
|
||||
|
||||
res = test_client.get('/foobar', 'http://localhost:5000')
|
||||
res = test_client.get("/foobar", "http://localhost:5000")
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.contain(b"ListBucketResult")
|
||||
|
||||
res = test_client.put('/foobar2/', 'http://localhost:5000')
|
||||
res = test_client.put("/foobar2/", "http://localhost:5000")
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
res = test_client.get('/')
|
||||
res.data.should.contain(b'<Name>foobar2</Name>')
|
||||
res = test_client.get("/")
|
||||
res.data.should.contain(b"<Name>foobar2</Name>")
|
||||
|
||||
res = test_client.get('/foobar2/', 'http://localhost:5000')
|
||||
res = test_client.get("/foobar2/", "http://localhost:5000")
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.contain(b"ListBucketResult")
|
||||
|
||||
res = test_client.get('/missing-bucket', 'http://localhost:5000')
|
||||
res = test_client.get("/missing-bucket", "http://localhost:5000")
|
||||
res.status_code.should.equal(404)
|
||||
|
||||
res = test_client.put(
|
||||
'/foobar/bar', 'http://localhost:5000', data='test value')
|
||||
res = test_client.put("/foobar/bar", "http://localhost:5000", data="test value")
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
res = test_client.get('/foobar/bar', 'http://localhost:5000')
|
||||
res = test_client.get("/foobar/bar", "http://localhost:5000")
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal(b"test value")
|
||||
|
||||
|
|
@ -69,15 +68,16 @@ def test_s3_server_bucket_create():
|
|||
def test_s3_server_post_to_bucket():
|
||||
test_client = authenticated_client()
|
||||
|
||||
res = test_client.put('/foobar2', 'http://localhost:5000/')
|
||||
res = test_client.put("/foobar2", "http://localhost:5000/")
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
test_client.post('/foobar2', "https://localhost:5000/", data={
|
||||
'key': 'the-key',
|
||||
'file': 'nothing'
|
||||
})
|
||||
test_client.post(
|
||||
"/foobar2",
|
||||
"https://localhost:5000/",
|
||||
data={"key": "the-key", "file": "nothing"},
|
||||
)
|
||||
|
||||
res = test_client.get('/foobar2/the-key', 'http://localhost:5000/')
|
||||
res = test_client.get("/foobar2/the-key", "http://localhost:5000/")
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal(b"nothing")
|
||||
|
||||
|
|
@ -85,15 +85,14 @@ def test_s3_server_post_to_bucket():
|
|||
def test_s3_server_put_ipv6():
|
||||
test_client = authenticated_client()
|
||||
|
||||
res = test_client.put('/foobar2', 'http://[::]:5000/')
|
||||
res = test_client.put("/foobar2", "http://[::]:5000/")
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
test_client.post('/foobar2', "https://[::]:5000/", data={
|
||||
'key': 'the-key',
|
||||
'file': 'nothing'
|
||||
})
|
||||
test_client.post(
|
||||
"/foobar2", "https://[::]:5000/", data={"key": "the-key", "file": "nothing"}
|
||||
)
|
||||
|
||||
res = test_client.get('/foobar2/the-key', 'http://[::]:5000/')
|
||||
res = test_client.get("/foobar2/the-key", "http://[::]:5000/")
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal(b"nothing")
|
||||
|
||||
|
|
@ -101,14 +100,15 @@ def test_s3_server_put_ipv6():
|
|||
def test_s3_server_put_ipv4():
|
||||
test_client = authenticated_client()
|
||||
|
||||
res = test_client.put('/foobar2', 'http://127.0.0.1:5000/')
|
||||
res = test_client.put("/foobar2", "http://127.0.0.1:5000/")
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
test_client.post('/foobar2', "https://127.0.0.1:5000/", data={
|
||||
'key': 'the-key',
|
||||
'file': 'nothing'
|
||||
})
|
||||
test_client.post(
|
||||
"/foobar2",
|
||||
"https://127.0.0.1:5000/",
|
||||
data={"key": "the-key", "file": "nothing"},
|
||||
)
|
||||
|
||||
res = test_client.get('/foobar2/the-key', 'http://127.0.0.1:5000/')
|
||||
res = test_client.get("/foobar2/the-key", "http://127.0.0.1:5000/")
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal(b"nothing")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue