Skip to main content
# Light weight BDD Pattern

## Installation
* `pip install apple-mango`

## Goal
* Easy to Use
* Compatible with Python unittest
* Compatible with existing test code
* Support Python3

## Next Step
* Register to pypi
* Add CI
* Support pytest

## Usage
* Define regular test class
* Define regular test method with `@mango.given()`
* Define inner `when` method with `@mango.when()`
* Define inner `then` method with `@mango.then()`
* Run python test: `python -m unittest test_file.py`
* No need to call inner `when` and `then` method becuase `given(), when(), then()` decorators will take care of it

### Example
```python
# test_exampel.py

class MangoUseCase(TestCase):
def setUp(self):
self.user = 'jun'

@mango.given('I am logged-in user')
def test_profile(self):
self.given.user_profile = 'my_profile'
self.given.user_photo = 'my_photo'

self.given.notifications_count = 3
self.given.unread_notifications_count = 1

@mango.when('I click profile')
def when_click_profile():
print('click')

@mango.then('I see profile')
def then_profile():
self.assertEqual(self.given.user_profile, 'my_profile')

@mango.then('I see my photo')
def then_photo():
self.assertEqual(self.given.user_photo, 'my_photo')

@mango.when('I click notification')
def when_click_notification():
print('click')

@mango.then('I see 3 notifications')
def then_notification():
self.assertEqual(self.given.notifications_count, 3)

@mango.then('I see 1 unread notification')
def then_unread_notification():
self.assertEqual(self.given.unread_notifications_count, 1)

@mango.given('I am logged-out user')
def test_auth(self):
self.given.status_code = 401

@mango.when('I access profile by url')
def when_access_profile():
print('access profile')

@mango.then('I see 401 error')
def then_error():
self.assertEqual(self.given.status_code, 401)

```

### Run Example
```python
python -m unittest test_example.py
```

## Contributing

### Run Test
```python
python -m unittest tests/test_mango.py
```


Metadata

Release files for apple-mango 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for apple-mango 0.2
File Interpreter ABI Platform
apple_mango-0.2-py3-none-any.whl Python 3 none any Details

Release files / apple_mango-0.2-py3-none-any.whl

Download URL apple_mango-0.2-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad3b069b9e7afb1d8b18d7dcb7e6847b4aa435c67574f0195a95455248192f1b
BLAKE2b-256 checksum
How to use checksums
0f00541ab2ffdf4e67933b7ad984ff0d7784fd05f547d70317b7f07fd9fe9f9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page