From b70dfcc34aeb23ec8153bcaea6d2990b45d36592 Mon Sep 17 00:00:00 2001 From: Amazia Gur <149373874+amaziahub@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:25:09 +0000 Subject: [PATCH] chore: rename brand (#8) Co-authored-by: Amazia Gur --- .github/workflows/test.yml | 2 +- README.md | 62 +++++++++--------- mockingbird.jpg => mimicker.jpg | Bin {mockingbird => mimicker}/__init__.py | 0 {mockingbird => mimicker}/handler.py | 4 +- .../mockingbird.py => mimicker/mimicker.py | 8 +-- {mockingbird => mimicker}/route.py | 0 {mockingbird => mimicker}/server.py | 12 ++-- {mockingbird => mimicker}/stub_group.py | 0 pyproject.toml | 6 +- tests/conftest.py | 6 +- ...bird_delete.py => test_mimicker_delete.py} | 18 ++--- ...ockingbird_get.py => test_mimicker_get.py} | 34 +++++----- ...kingbird_post.py => test_mimicker_post.py} | 38 +++++------ ...ockingbird_put.py => test_mimicker_put.py} | 34 +++++----- tests/test_route.py | 2 +- tests/test_stub_group.py | 6 +- 17 files changed, 116 insertions(+), 116 deletions(-) rename mockingbird.jpg => mimicker.jpg (100%) rename {mockingbird => mimicker}/__init__.py (100%) rename {mockingbird => mimicker}/handler.py (96%) rename mockingbird/mockingbird.py => mimicker/mimicker.py (66%) rename {mockingbird => mimicker}/route.py (100%) rename {mockingbird => mimicker}/server.py (80%) rename {mockingbird => mimicker}/stub_group.py (100%) rename tests/{test_mockingbird_delete.py => test_mimicker_delete.py} (63%) rename tests/{test_mockingbird_get.py => test_mimicker_get.py} (68%) rename tests/{test_mockingbird_post.py => test_mimicker_post.py} (73%) rename tests/{test_mockingbird_put.py => test_mimicker_put.py} (70%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 45e1c0c..a223ebe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Mockingbird Tests +name: Mimicker Tests on: push: diff --git a/README.md b/README.md index d57b649..14cb6e2 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@

- Mockingbird logo

-> **Mockingbird** – Your lightweight, Python-native HTTP mocking server. +> **Mimicker** – Your lightweight, Python-native HTTP mocking server.
-[![Mockingbird Tests](https://github.com/amaziahub/mockingbird/actions/workflows/test.yml/badge.svg)](https://github.com/amaziahub/mockingbird/actions/workflows/test.yml) +[![Mimicker Tests](https://github.com/amaziahub/mockingbird/actions/workflows/test.yml/badge.svg)](https://github.com/amaziahub/mockingbird/actions/workflows/test.yml) [![License](http://img.shields.io/:license-apache2.0-red.svg)](http://doge.mit-license.org) ![Poetry](https://img.shields.io/badge/managed%20with-poetry-blue) @@ -20,9 +20,9 @@
-Mockingbird is a Python-native HTTP mocking server inspired by WireMock, designed to simplify the process of stubbing and +Mimicker is a Python-native HTTP mocking server inspired by WireMock, designed to simplify the process of stubbing and mocking HTTP endpoints for testing purposes. -Mockingbird requires no third-party libraries and is lightweight, making it ideal for integration testing, local +Mimicker requires no third-party libraries and is lightweight, making it ideal for integration testing, local development, and CI environments. ## Features @@ -33,28 +33,28 @@ development, and CI environments. ## Installation -Mockingbird can be installed directly from PyPI using pip or Poetry: +Mimicker can be installed directly from PyPI using pip or Poetry: ### Using pip: ```bash -pip install mockingbird +pip install mimicker ``` ### Using poetry: ```bash -poetry add mockingbird +poetry add mimicker ``` ## Usage -To start Mockingbird on a specific port with a simple endpoint, you can use the following code snippet: +To start Mimicker on a specific port with a simple endpoint, you can use the following code snippet: ```python -from mockingbird.mockingbird import mockingbird, get +from mimicker.mimicker import mimicker, get -mockingbird(8080).routes( +mimicker(8080).routes( get("/hello"). body({"message": "Hello, World!"}). status(200) @@ -65,12 +65,12 @@ mockingbird(8080).routes( #### Using Path Parameters -Mockingbird can handle path parameters dynamically. Here's how you can mock an endpoint with a variable in the path: +Mimicker can handle path parameters dynamically. Here's how you can mock an endpoint with a variable in the path: ```python -from mockingbird.mockingbird import mockingbird, get +from mimicker.mimicker import mimicker, get -mockingbird(8080).routes( +mimicker(8080).routes( get("/hello/{name}") .body({"message": "Hello, {name}!"}) .status(200) @@ -85,9 +85,9 @@ mockingbird(8080).routes( You can also mock responses with custom headers: ```python -from mockingbird.mockingbird import mockingbird, get +from mimicker.mimicker import mimicker, get -mockingbird(8080).routes( +mimicker(8080).routes( get("/hello") .body("Hello with headers") .headers([("Content-Type", "text/plain"), ("Custom-Header", "Value")]) @@ -99,13 +99,13 @@ mockingbird(8080).routes( #### Multiple Routes -Mockingbird allows you to define multiple routes for different HTTP methods and paths. Here's an example with `GET` +Mimicker allows you to define multiple routes for different HTTP methods and paths. Here's an example with `GET` and `POST` routes: ```python -from mockingbird.mockingbird import mockingbird, get, post +from mimicker.mimicker import mimicker, get, post -mockingbird(8080).routes( +mimicker(8080).routes( get("/greet") .body({"message": "Hello, world!"}) .status(200), @@ -126,9 +126,9 @@ mockingbird(8080).routes( You can also mock different HTTP status codes for the same endpoint: ```python -from mockingbird.mockingbird import mockingbird, get +from mimicker.mimicker import mimicker, get -mockingbird(8080).routes( +mimicker(8080).routes( get("/status") .body({"message": "Success"}) .status(200), @@ -144,12 +144,12 @@ mockingbird(8080).routes( #### Mocking Responses with JSON Body -Mockingbird supports JSON bodies, making it ideal for API testing: +Mimicker supports JSON bodies, making it ideal for API testing: ```python -from mockingbird.mockingbird import mockingbird, get +from mimicker.mimicker import mimicker, get -mockingbird(8080).routes( +mimicker(8080).routes( get("/json") .body({"message": "Hello, JSON!"}) .status(200) @@ -160,15 +160,15 @@ mockingbird(8080).routes( #### Supporting Other Body Types (Text, Files, etc.) -In addition to JSON bodies, Mockingbird supports other types of content for the response body. Here's how you can return +In addition to JSON bodies, Mimicker supports other types of content for the response body. Here's how you can return text or file content: ##### Text Response: ```python -from mockingbird.mockingbird import mockingbird, get +from mimicker.mimicker import mimicker, get -mockingbird(8080).routes( +mimicker(8080).routes( get("/text") .body("This is a plain text response") .status(200) @@ -182,9 +182,9 @@ mockingbird(8080).routes( You can also return files from a mock endpoint: ```python -from mockingbird.mockingbird import mockingbird, get +from mimicker.mimicker import mimicker, get -mockingbird(8080).routes( +mimicker(8080).routes( get("/file") .body(open("example.txt", "rb").read()) # Mock a file response .status(200) @@ -205,8 +205,8 @@ mockingbird(8080).routes( * `.headers(headers)`: Defines response `headers`. ## Requirements -Mockingbird supports Python 3.7 and above. +Mimicker supports Python 3.7 and above. ## License -Mockingbird is released under the MIT License. see the [LICENSE](LICENSE) for more information. \ No newline at end of file +Mimicker is released under the MIT License. see the [LICENSE](LICENSE) for more information. \ No newline at end of file diff --git a/mockingbird.jpg b/mimicker.jpg similarity index 100% rename from mockingbird.jpg rename to mimicker.jpg diff --git a/mockingbird/__init__.py b/mimicker/__init__.py similarity index 100% rename from mockingbird/__init__.py rename to mimicker/__init__.py diff --git a/mockingbird/handler.py b/mimicker/handler.py similarity index 96% rename from mockingbird/handler.py rename to mimicker/handler.py index 2c0f8c8..c028d3c 100644 --- a/mockingbird/handler.py +++ b/mimicker/handler.py @@ -2,10 +2,10 @@ import json from typing import Any, Tuple, Optional, Dict, Callable, List -from mockingbird.stub_group import StubGroup +from mimicker.stub_group import StubGroup -class MockingbirdHandler(http.server.SimpleHTTPRequestHandler): +class MimickerHandler(http.server.SimpleHTTPRequestHandler): def __init__(self, stub_matcher: StubGroup, *args, **kwargs): self.stub_matcher = stub_matcher super().__init__(*args, **kwargs) diff --git a/mockingbird/mockingbird.py b/mimicker/mimicker.py similarity index 66% rename from mockingbird/mockingbird.py rename to mimicker/mimicker.py index c1a9c3d..a10a1e2 100644 --- a/mockingbird/mockingbird.py +++ b/mimicker/mimicker.py @@ -1,7 +1,7 @@ import logging -from mockingbird.route import Route -from mockingbird.server import MockingbirdServer +from mimicker.route import Route +from mimicker.server import MimickerServer logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(message)s") @@ -22,6 +22,6 @@ def delete(path: str) -> Route: return Route("DELETE", path) -def mockingbird(port: int = 8080) -> MockingbirdServer: - server = MockingbirdServer(port).start() +def mimicker(port: int = 8080) -> MimickerServer: + server = MimickerServer(port).start() return server diff --git a/mockingbird/route.py b/mimicker/route.py similarity index 100% rename from mockingbird/route.py rename to mimicker/route.py diff --git a/mockingbird/server.py b/mimicker/server.py similarity index 80% rename from mockingbird/server.py rename to mimicker/server.py index 4e6a526..46bd1d0 100644 --- a/mockingbird/server.py +++ b/mimicker/server.py @@ -3,12 +3,12 @@ import socketserver import threading -from mockingbird.handler import MockingbirdHandler -from mockingbird.route import Route -from mockingbird.stub_group import StubGroup +from mimicker.handler import MimickerHandler +from mimicker.route import Route +from mimicker.stub_group import StubGroup -class MockingbirdServer: +class MimickerServer: def __init__(self, port: int = 8080): self.stub_matcher = StubGroup() self.server = socketserver.TCPServer(("", port), self._handler_factory) @@ -16,7 +16,7 @@ def __init__(self, port: int = 8080): atexit.register(self.shutdown) def _handler_factory(self, *args): - return MockingbirdHandler(self.stub_matcher, *args) + return MimickerHandler(self.stub_matcher, *args) def routes(self, *routes: Route): for route in routes: @@ -32,7 +32,7 @@ def routes(self, *routes: Route): return self def start(self): - logging.info("MockingbirdServer starting on port %s", + logging.info("MimickerServer starting on port %s", self.server.server_address[1]) self._thread.start() return self diff --git a/mockingbird/stub_group.py b/mimicker/stub_group.py similarity index 100% rename from mockingbird/stub_group.py rename to mimicker/stub_group.py diff --git a/pyproject.toml b/pyproject.toml index aa786d3..6dbfbcb 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,13 @@ [tool.poetry] -name = "mockingbird" +name = "mimicker" version = "0.1.0" description = "A lightweight HTTP mocking server for Python" authors = ["Amazia Gur "] license = "MIT" readme = "README.md" keywords = ["http", "mocking", "testing", "mock-server", "stubbing", "ci-cd", "http-server", "testing-tools", "stub-server", "purepython"] -repository = "https://github.com/amaziahub/mockingbird" -homepage = "https://github.com/amaziahub/mockingbird" +repository = "https://github.com/amaziahub/mimicker" +homepage = "https://github.com/amaziahub/mimicker" [tool.poetry.dependencies] python = "^3.7" diff --git a/tests/conftest.py b/tests/conftest.py index 004aaea..4a37bdf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,11 @@ import pytest -from mockingbird.mockingbird import mockingbird +from mimicker.mimicker import mimicker @pytest.fixture(scope="session") -def mockingbird_server(): - server = mockingbird(port=8080) +def mimicker_server(): + server = mimicker(port=8080) yield server diff --git a/tests/test_mockingbird_delete.py b/tests/test_mimicker_delete.py similarity index 63% rename from tests/test_mockingbird_delete.py rename to tests/test_mimicker_delete.py index 4c05da4..c75c04e 100644 --- a/tests/test_mockingbird_delete.py +++ b/tests/test_mimicker_delete.py @@ -1,27 +1,27 @@ from hamcrest import assert_that, is_ -from mockingbird.mockingbird import delete +from mimicker.mimicker import delete from tests.support.client import Client -def test_delete_404(mockingbird_server): - mockingbird_server.routes( +def test_delete_404(mimicker_server): + mimicker_server.routes( delete("/remove") ) resp = Client().delete('/not-found') assert_that(resp.status_code, is_(404)) -def test_delete_default_200_status_code(mockingbird_server): - mockingbird_server.routes( +def test_delete_default_200_status_code(mimicker_server): + mimicker_server.routes( delete("/remove") ) resp = Client().delete('/remove') assert_that(resp.status_code, is_(200)) -def test_delete_picked_status_code(mockingbird_server): - mockingbird_server.routes( +def test_delete_picked_status_code(mimicker_server): + mimicker_server.routes( delete("/remove"). status(204) ) @@ -29,8 +29,8 @@ def test_delete_picked_status_code(mockingbird_server): assert_that(resp.status_code, is_(204)) -def test_delete_empty_response(mockingbird_server): - mockingbird_server.routes( +def test_delete_empty_response(mimicker_server): + mimicker_server.routes( delete("/remove"). body(None). status(204) diff --git a/tests/test_mockingbird_get.py b/tests/test_mimicker_get.py similarity index 68% rename from tests/test_mockingbird_get.py rename to tests/test_mimicker_get.py index 3e63e7c..3d1da3b 100644 --- a/tests/test_mockingbird_get.py +++ b/tests/test_mimicker_get.py @@ -1,27 +1,27 @@ from hamcrest import assert_that, is_, has_entry, equal_to -from mockingbird.mockingbird import get +from mimicker.mimicker import get from tests.support.client import Client -def test_get_404(mockingbird_server): - mockingbird_server.routes( +def test_get_404(mimicker_server): + mimicker_server.routes( get("/hello") ) resp = Client().get('/not-found') assert_that(resp.status_code, is_(404)) -def test_get_default_200_status_code(mockingbird_server): - mockingbird_server.routes( +def test_get_default_200_status_code(mimicker_server): + mimicker_server.routes( get("/hello") ) resp = Client().get('/hello') assert_that(resp.status_code, is_(200)) -def test_get_picked_status_code(mockingbird_server): - mockingbird_server.routes( +def test_get_picked_status_code(mimicker_server): + mimicker_server.routes( get("/hello"). status(201) ) @@ -29,8 +29,8 @@ def test_get_picked_status_code(mockingbird_server): assert_that(resp.status_code, is_(201)) -def test_get_body_as_text(mockingbird_server): - mockingbird_server.routes( +def test_get_body_as_text(mimicker_server): + mimicker_server.routes( get('/hello'). body("hello world") ) @@ -38,9 +38,9 @@ def test_get_body_as_text(mockingbird_server): assert_that(resp.text, is_("hello world")) -def test_get_body_as_json(mockingbird_server): +def test_get_body_as_json(mimicker_server): body = {"message": "Hello, World!"} - mockingbird_server.routes( + mimicker_server.routes( get("/hello"). body(body). status(200) @@ -50,8 +50,8 @@ def test_get_body_as_json(mockingbird_server): assert_that(resp.json(), equal_to(body)) -def test_get_path_param(mockingbird_server): - mockingbird_server.routes( +def test_get_path_param(mimicker_server): + mimicker_server.routes( get("/hello/{greet}"). body({"message": "Hello, {greet}!"}). status(200) @@ -60,8 +60,8 @@ def test_get_path_param(mockingbird_server): assert_that(resp.json(), equal_to({"message": "Hello, world!"})) -def test_get_empty_response(mockingbird_server): - mockingbird_server.routes( +def test_get_empty_response(mimicker_server): + mimicker_server.routes( get("/empty"). body(None). status(204) @@ -71,8 +71,8 @@ def test_get_empty_response(mockingbird_server): assert_that(resp.text, is_("")) -def test_get_headers(mockingbird_server): - mockingbird_server.routes( +def test_get_headers(mimicker_server): + mimicker_server.routes( get("/hello"). body("hi there"). headers([("Content-Type", "text/plain")]) diff --git a/tests/test_mockingbird_post.py b/tests/test_mimicker_post.py similarity index 73% rename from tests/test_mockingbird_post.py rename to tests/test_mimicker_post.py index 83757be..a8e7d55 100644 --- a/tests/test_mockingbird_post.py +++ b/tests/test_mimicker_post.py @@ -1,27 +1,27 @@ from hamcrest import assert_that, is_, has_entry, equal_to -from mockingbird.mockingbird import post +from mimicker.mimicker import post from tests.support.client import Client -def test_post_404(mockingbird_server): - mockingbird_server.routes( +def test_post_404(mimicker_server): + mimicker_server.routes( post("/submit") ) resp = Client().post_as_json('/not-found') assert_that(resp.status_code, is_(404)) -def test_post_default_200_status_code(mockingbird_server): - mockingbird_server.routes( +def test_post_default_200_status_code(mimicker_server): + mimicker_server.routes( post("/submit") ) resp = Client().post_as_json('/submit') assert_that(resp.status_code, is_(200)) -def test_post_picked_status_code(mockingbird_server): - mockingbird_server.routes( +def test_post_picked_status_code(mimicker_server): + mimicker_server.routes( post("/submit"). status(201) ) @@ -29,8 +29,8 @@ def test_post_picked_status_code(mockingbird_server): assert_that(resp.status_code, is_(201)) -def test_post_body_as_text(mockingbird_server): - mockingbird_server.routes( +def test_post_body_as_text(mimicker_server): + mimicker_server.routes( post('/submit'). body("submission successful") ) @@ -38,9 +38,9 @@ def test_post_body_as_text(mockingbird_server): assert_that(resp.text, is_("submission successful")) -def test_post_body_as_json(mockingbird_server): +def test_post_body_as_json(mimicker_server): body = {"result": "created"} - mockingbird_server.routes( + mimicker_server.routes( post("/submit"). body(body). status(201) @@ -50,8 +50,8 @@ def test_post_body_as_json(mockingbird_server): assert_that(resp.json(), equal_to(body)) -def test_post_empty_response(mockingbird_server): - mockingbird_server.routes( +def test_post_empty_response(mimicker_server): + mimicker_server.routes( post("/clear"). body(None). status(204) @@ -61,9 +61,9 @@ def test_post_empty_response(mockingbird_server): assert_that(resp.text, is_("")) -def test_post_body_with_text_content(mockingbird_server): +def test_post_body_with_text_content(mimicker_server): body = "This is a plain text submission." - mockingbird_server.routes( + mimicker_server.routes( post("/submit-text"). body(body). status(200) @@ -73,9 +73,9 @@ def test_post_body_with_text_content(mockingbird_server): assert_that(resp.text, is_(body)) -def test_post_body_with_json_content(mockingbird_server): +def test_post_body_with_json_content(mimicker_server): body = {"message": "Data submitted"} - mockingbird_server.routes( + mimicker_server.routes( post("/submit-json"). body(body). status(201) @@ -85,9 +85,9 @@ def test_post_body_with_json_content(mockingbird_server): assert_that(resp.json(), equal_to(body)) -def test_post_file_upload(mockingbird_server): +def test_post_file_upload(mimicker_server): file_content = b"Test file content" - mockingbird_server.routes( + mimicker_server.routes( post("/upload"). body("File uploaded successfully"). status(200) diff --git a/tests/test_mockingbird_put.py b/tests/test_mimicker_put.py similarity index 70% rename from tests/test_mockingbird_put.py rename to tests/test_mimicker_put.py index f2b5994..90b8c12 100644 --- a/tests/test_mockingbird_put.py +++ b/tests/test_mimicker_put.py @@ -1,27 +1,27 @@ from hamcrest import assert_that, is_, has_entry, equal_to -from mockingbird.mockingbird import put +from mimicker.mimicker import put from tests.support.client import Client -def test_put_404(mockingbird_server): - mockingbird_server.routes( +def test_put_404(mimicker_server): + mimicker_server.routes( put("/update") ) resp = Client().put('/not-found') assert_that(resp.status_code, is_(404)) -def test_put_default_200_status_code(mockingbird_server): - mockingbird_server.routes( +def test_put_default_200_status_code(mimicker_server): + mimicker_server.routes( put("/update") ) resp = Client().put('/update') assert_that(resp.status_code, is_(200)) -def test_put_picked_status_code(mockingbird_server): - mockingbird_server.routes( +def test_put_picked_status_code(mimicker_server): + mimicker_server.routes( put("/update"). status(202) ) @@ -29,8 +29,8 @@ def test_put_picked_status_code(mockingbird_server): assert_that(resp.status_code, is_(202)) -def test_put_body_as_text(mockingbird_server): - mockingbird_server.routes( +def test_put_body_as_text(mimicker_server): + mimicker_server.routes( put('/update'). body("update successful") ) @@ -38,9 +38,9 @@ def test_put_body_as_text(mockingbird_server): assert_that(resp.text, is_("update successful")) -def test_put_body_as_json(mockingbird_server): +def test_put_body_as_json(mimicker_server): body = {"result": "updated"} - mockingbird_server.routes( + mimicker_server.routes( put("/update"). body(body). status(200) @@ -50,8 +50,8 @@ def test_put_body_as_json(mockingbird_server): assert_that(resp.json(), equal_to(body)) -def test_put_empty_response(mockingbird_server): - mockingbird_server.routes( +def test_put_empty_response(mimicker_server): + mimicker_server.routes( put("/clear"). body(None). status(204) @@ -61,9 +61,9 @@ def test_put_empty_response(mockingbird_server): assert_that(resp.text, is_("")) -def test_put_text_content(mockingbird_server): +def test_put_text_content(mimicker_server): body = "This is an update with plain text." - mockingbird_server.routes( + mimicker_server.routes( put("/update-text"). body(body). status(200) @@ -73,9 +73,9 @@ def test_put_text_content(mockingbird_server): assert_that(resp.text, is_(body)) -def test_put_json_content(mockingbird_server): +def test_put_json_content(mimicker_server): body = {"message": "Updated successfully"} - mockingbird_server.routes( + mimicker_server.routes( put("/update-json"). body(body). status(200) diff --git a/tests/test_route.py b/tests/test_route.py index 7a8f3d5..4102bf0 100644 --- a/tests/test_route.py +++ b/tests/test_route.py @@ -1,5 +1,5 @@ import re -from mockingbird.route import Route +from mimicker.route import Route from hamcrest import assert_that, equal_to, has_entry, instance_of diff --git a/tests/test_stub_group.py b/tests/test_stub_group.py index 1ef0fc2..0ef8e57 100644 --- a/tests/test_stub_group.py +++ b/tests/test_stub_group.py @@ -1,5 +1,5 @@ from hamcrest import assert_that, none, is_ -from mockingbird.stub_group import StubGroup +from mimicker.stub_group import StubGroup def test_none_given_no_stubs(): @@ -36,10 +36,10 @@ def test_match_w_path_param(): 200, {"message": "Hello, {name}!"}) - matched, path_param = stub_group.match("GET", "/hello/mockingbird") + matched, path_param = stub_group.match("GET", "/hello/mimicker") assert_that(matched, is_((200, {"message": "Hello, {name}!"}, None, None))) - assert_that(path_param, is_({"name": "mockingbird"})) + assert_that(path_param, is_({"name": "mimicker"})) def test_match_stub_with_response_func():