From 7a17e0f89d0f36338a29968edf4295558cc745d2 Mon Sep 17 00:00:00 2001 From: kbalk <7536198+kbalk@users.noreply.github.com> Date: Fri, 4 Aug 2023 17:52:10 -0400 Subject: [PATCH] Techdebt: Replace sure with regular assertions in s3bucket_path (#6601) --- .../test_s3bucket_path_utils.py | 9 ++-- tests/test_s3bucket_path/test_server.py | 51 +++++++++---------- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/tests/test_s3bucket_path/test_s3bucket_path_utils.py b/tests/test_s3bucket_path/test_s3bucket_path_utils.py index 255bdb3f6..98d80ec3e 100644 --- a/tests/test_s3bucket_path/test_s3bucket_path_utils.py +++ b/tests/test_s3bucket_path/test_s3bucket_path_utils.py @@ -1,16 +1,13 @@ -from sure import expect from moto.s3bucket_path.utils import bucket_name_from_url def test_base_url(): - expect(bucket_name_from_url("https://s3.amazonaws.com/")).should.equal(None) + assert bucket_name_from_url("https://s3.amazonaws.com/") is None def test_localhost_bucket(): - expect(bucket_name_from_url("https://localhost:5000/wfoobar/abc")).should.equal( - "wfoobar" - ) + assert bucket_name_from_url("https://localhost:5000/wfoobar/abc") == "wfoobar" def test_localhost_without_bucket(): - expect(bucket_name_from_url("https://www.localhost:5000")).should.equal(None) + assert bucket_name_from_url("https://www.localhost:5000") is None diff --git a/tests/test_s3bucket_path/test_server.py b/tests/test_s3bucket_path/test_server.py index 302e77685..1af7f3d11 100644 --- a/tests/test_s3bucket_path/test_server.py +++ b/tests/test_s3bucket_path/test_server.py @@ -1,12 +1,7 @@ -import sure # noqa # pylint: disable=unused-import - +"""Test the different server responses.""" from flask.testing import FlaskClient import moto.server as server -""" -Test the different server responses -""" - class AuthenticatedClient(FlaskClient): def open(self, *args, **kwargs): @@ -27,48 +22,48 @@ def test_s3_server_get(): res = test_client.get("/") - res.data.should.contain(b"ListAllMyBucketsResult") + assert b"ListAllMyBucketsResult" in res.data def test_s3_server_bucket_create(): test_client = authenticated_client() res = test_client.put("/foobar", "http://localhost:5000") - res.status_code.should.equal(200) + assert res.status_code == 200 res = test_client.get("/") - res.data.should.contain(b"foobar") + assert b"foobar" in res.data res = test_client.get("/foobar", "http://localhost:5000") - res.status_code.should.equal(200) - res.data.should.contain(b"ListBucketResult") + assert res.status_code == 200 + assert b"ListBucketResult" in res.data res = test_client.put("/foobar2/", "http://localhost:5000") - res.status_code.should.equal(200) + assert res.status_code == 200 res = test_client.get("/") - res.data.should.contain(b"foobar2") + assert b"foobar2" in res.data res = test_client.get("/foobar2/", "http://localhost:5000") - res.status_code.should.equal(200) - res.data.should.contain(b"ListBucketResult") + assert res.status_code == 200 + assert b"ListBucketResult" in res.data res = test_client.get("/missing-bucket", "http://localhost:5000") - res.status_code.should.equal(404) + assert res.status_code == 404 res = test_client.put("/foobar/bar", "http://localhost:5000", data="test value") - res.status_code.should.equal(200) + assert res.status_code == 200 res = test_client.get("/foobar/bar", "http://localhost:5000") - res.status_code.should.equal(200) - res.data.should.equal(b"test value") + assert res.status_code == 200 + assert res.data == b"test value" def test_s3_server_post_to_bucket(): test_client = authenticated_client() res = test_client.put("/foobar2", "http://localhost:5000/") - res.status_code.should.equal(200) + assert res.status_code == 200 test_client.post( "/foobar2", @@ -77,30 +72,30 @@ def test_s3_server_post_to_bucket(): ) res = test_client.get("/foobar2/the-key", "http://localhost:5000/") - res.status_code.should.equal(200) - res.data.should.equal(b"nothing") + assert res.status_code == 200 + assert res.data == b"nothing" def test_s3_server_put_ipv6(): test_client = authenticated_client() res = test_client.put("/foobar2", "http://[::]:5000/") - res.status_code.should.equal(200) + assert res.status_code == 200 test_client.post( "/foobar2", "https://[::]:5000/", data={"key": "the-key", "file": "nothing"} ) res = test_client.get("/foobar2/the-key", "http://[::]:5000/") - res.status_code.should.equal(200) - res.data.should.equal(b"nothing") + assert res.status_code == 200 + assert res.data == b"nothing" def test_s3_server_put_ipv4(): test_client = authenticated_client() res = test_client.put("/foobar2", "http://127.0.0.1:5000/") - res.status_code.should.equal(200) + assert res.status_code == 200 test_client.post( "/foobar2", @@ -109,5 +104,5 @@ def test_s3_server_put_ipv4(): ) 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") + assert res.status_code == 200 + assert res.data == b"nothing"