https://github.com/dimanu-py/character-copier-kata
Solution for Character Copier kata
https://github.com/dimanu-py/character-copier-kata
kata learning-by-doing mock
Last synced: about 2 months ago
JSON representation
Solution for Character Copier kata
- Host: GitHub
- URL: https://github.com/dimanu-py/character-copier-kata
- Owner: dimanu-py
- Created: 2024-06-04T16:06:59.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-04T16:10:06.000Z (12 months ago)
- Last Synced: 2025-02-13T21:47:22.683Z (3 months ago)
- Topics: kata, learning-by-doing, mock
- Language: Python
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# :paperclip: Character Copy Kata :paperclip:
[](https://python.org)
## Resources
These instructions where extracted from Urls Enzler blog. The link to the original instructions can be found in the link bellow.
[](https://www.planetgeek.ch/2010/03/31/mocking-kata-copier-net/)
## Description
The character copier is a simple class that reads characters from a source and copies them to a destination one character at a time.
The character copier gets the source and destination injected in the constructor.

When the method Copy is called on the copier then it should read characters from the source and copy them to the destination until the
source returns a newline (ā\nā).The exercise is to implement the character copier using mocks for the source and the destination (try using manually written mocks and
mocks written with a mocking framework.## Objective
The objective of the kata is to practice Mocking and Stubs to test a class without depending on other classes.
We will try to work with the concept of baby steps and compare manually writen mocks with mocks written with a mocking framework.
## Configuration
The project can be configured with `poetry` and `pyenv`.
1. Install python version with pyenv:
```bash
pyenv install 3.12.0
```
2. Install poetry:
```bash
pip install poetry
```
3. Create a virtual environment and install dependencies:
```bash
poetry install
poetry install --dev
```By default, it will create the virtual environment outside the project. To create it inside, use the following command:
```bash
poetry config virtualenvs.in-project true
poetry install
```
4. Activate the virtual environment:
```bash
poetry shell
```
You can activate it manually running `source .venv/bin/activate` on Unix systems or `source .venv/Scripts/activate` on Windows.## Running the tests
To run the tests, execute one of the following commands:
```bash
pytest
```or
```bash
poetry run pytest
```## Learnings
We've learnt how to implement Copier class by not depending on its collaborators, just focusing on how we want them to interact.
### Visit my GitHub profile to see all solved katas š
[](https://github.com/dimanu-py/code-katas)