Skip to content

Commit

Permalink
chore: rename brand (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: Amazia Gur <[email protected]>
  • Loading branch information
amaziahub and Amazia Gur authored Nov 13, 2024
1 parent 972618f commit b70dfcc
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Mockingbird Tests
name: Mimicker Tests

on:
push:
Expand Down
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<p align="center">
<img src="mockingbird.jpg" alt="Mockingbird logo"
<img src="mimicker.jpg" alt="Mimicker logo"
style="width: 200px; height: auto; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border: 2px solid black;">
</p>
<div>

<div align="center">

> **Mockingbird** – Your lightweight, Python-native HTTP mocking server.
> **Mimicker** – Your lightweight, Python-native HTTP mocking server.
</div>

<div align="center">

[![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)

</div>
</div>


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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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")])
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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.
Mimicker is released under the MIT License. see the [LICENSE](LICENSE) for more information.
File renamed without changes
File renamed without changes.
4 changes: 2 additions & 2 deletions mockingbird/handler.py → mimicker/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions mockingbird/mockingbird.py → mimicker/mimicker.py
Original file line number Diff line number Diff line change
@@ -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")

Expand All @@ -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
File renamed without changes.
12 changes: 6 additions & 6 deletions mockingbird/server.py → mimicker/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
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)
self._thread = threading.Thread(target=self.server.serve_forever, daemon=True)
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:
Expand All @@ -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
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
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"
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
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)
)
resp = Client().delete('/remove')
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)
Expand Down
Loading

0 comments on commit b70dfcc

Please sign in to comment.