Skip to content

Commit

Permalink
Merge pull request #25 from mwanjajoel/tests
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
mwanjajoel authored May 11, 2021
2 parents a02aff3 + 56538fd commit d81c3f7
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
omit =
env/*
tests/*
9 changes: 8 additions & 1 deletion .env_example
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
SECRET_KEY= # SECRET_KEY
DEBUG= #true for development dont sent in production
DEBUG= #true for development dont sent in production
DB_NAME= # database name
DB_HOST= # database host
DB_USER= # database user
DB_PASSWORD= # database password
DB_PORT = # database port
CODECOV_TOKEN = # codecov token

17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: python
python:
- '3.7'
services:
- postgresql
addons:
postgresql: '9.4'
before_script:
- pip install -r requirements.txt
- psql -c 'create database momo;' -U postgres
- python manage.py makemigrations --dry-run
- python manage.py migrate
script:
- pytest
env:
global:
secure: lyrPSV14XBHGVmo1KQT59rnb3k3Cg8WQTl1K3W7vtBqBxAWQ6EJAXyqCbvv6zte6oz1D/fgROAKX/EraQdZEGhBzIWoe4vbuK3zdG9PwQFa9IhNUx6oF6UsmFTCpmC71T352XyNKrrvd06KTtzvJkyS4wySMVQpo/jRVevaYDNw/B1sjkw6GiKp4RuKCRsU5FHXCBX5+8Kc9gIpz48IhEKrudHlctYWBXzMA/Ing8T5KItzaTAomqs3xAgoINzKGdMdakwjkc1maq53d3TpTupQubx6V7Pkr4ZVbJO1QKfWJiTqGiZ+4ACeaBfXLslRvqwRjGw2lBzWsT+rAS/EoXwCsK1e3xhwRjzHTqpbOOFw4Tl6OlPbbEsikrRxJ8JibhVK1IVagX0EJVETvYwMTUG6MQYWRFSHLX/6K3+27XnsdEkfvVedUplIEpU7P86CZ9TjrrTpe7XE3iFmTehcZ1XfXEYDcngQNdeM4AJtQ3FX6rxb70iA9skhAgselBGAd0O7gAx1SJSK8ddIvXkkzXlNiq4lSURZ2/acC5Up7obNZt01i1Rc3RIoXCns3PyZnaM6XbIR7OedN/wYPichUvnBFxW2Npwt+vSmT1VMXu1kIFuWGDyCj1HtMvzkdSlrV7+zIg9Ktbt8ptbvVKTLtRQVTx2VN3EYGz/Yuq/ORi9A=
5 changes: 5 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Authors for the Django MoMo API App.

- Mwanja Joel [(@mrmwanjajoel)](https://twitter.com/mrjoelmwanja)

- Arthur Nangai [(@arthurnangai)](https://twitter.com/arthurnangai)
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<p align="center">
<a href="https://twitter.com/mrjoelmwanja">
<img src="https://img.shields.io/badge/[email protected]?style=flat" alt="Twitter: @mrjoelmwanja" />
</a>
</p>

# Django MoMo API
This is a django package for the MTN MoMo API. It can be added to your current django-based application so as to interact with the MTN MoMo API in a much simpler way.
This is a django package for the MTN MoMo API. It can be added to your current django-based application so as to interact with the MTN MoMo API in a much simpler way.

![Build Status](https://travis-ci.com/mwanjajoel/django-momoapi.svg?branch=develop)



## Why we created the Django MoMo API Package
MTN Uganda released API documentation to their Mobile Money service and integrations for Python, NodeJS, PHP, Java etc have been created but at the time of writing, there is no django package and yet Django is a popular Python based web framework.
Expand All @@ -15,7 +14,12 @@ MTN Uganda released API documentation to their Mobile Money service and integrat
pip install django-momoapi
```
## Development Setup

```
- Create .env file following the .env_example.
- Create a postgre database and its credentials to the .env file.
- Run migrations using the command python manage.py migrate
- Run application using the command python manage.py runserver
```

## How to submit an issue

Expand All @@ -30,8 +34,9 @@ We follow a strict code of conduct and you can read it [Here](CODE_OF_CONDUCT.md

## Credits

Django MoMo API package was designed and built by Mwanja Joel, and is copyright © Mwanja Joel 2020. Django MoMo API is licensed under the MIT license; for the full license please see the [LICENSE](LICENSE) file.
Django MoMo API package was designed and built by Mwanja Joel, and is copyright © Mwanja Joel 2020. Django MoMo API is licensed under the MIT license; for the full license please see the [LICENSE](LICENSE) file.

Please see the [AUTHORS](AUTHORS) file for the full list of contributors.

If you find Django MoMo API useful and want to reach out, find me on Twitter: [@mrjoelmwanja](https://twitter.com/mrjoelmwanja).

Expand Down
13 changes: 9 additions & 4 deletions djangomomoapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv('DEBUG')

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["*"]


# Application definition
Expand All @@ -40,6 +40,8 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'momo',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -78,12 +80,15 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('DB_NAME'),
'HOST': os.environ.get('DB_HOST'),
'USER': os.environ.get('DB_USER'),
'PASSWORD': os.environ.get('DB_PASSWORD'),
'PORT': os.environ.get('DB_PORT'),
}
}


# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

Expand Down
Empty file added momo/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions momo/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions momo/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class MomoConfig(AppConfig):
name = 'momo'
Empty file added momo/migrations/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions momo/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.db import models

# Create your models here.

3 changes: 3 additions & 0 deletions momo/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions momo/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE = djangomomoapi.settings
python_files = tests.py test_*.py *_tests.py
15 changes: 14 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
asgiref==3.2.3
attrs==20.1.0
autopep8==1.5
bleach==3.1.0
bleach==3.1.1
bumpversion==0.5.3
certifi==2019.11.28
chardet==3.0.4
coverage==5.0.3
Django==3.0.3
docutils==0.16
idna==2.8
importlib-metadata==1.5.0
iniconfig==1.0.1
keyring==21.1.0
more-itertools==8.4.0
packaging==20.4
pkginfo==1.5.0.1
pluggy==0.13.1
psycopg2-binary==2.8.4
py==1.9.0
pycodestyle==2.5.0
Pygments==2.5.2
pyparsing==2.4.7
pytest==6.0.1
pytest-cov==2.10.1
pytest-django==3.9.0
python-dotenv==0.11.0
pytz==2019.3
readme-renderer==24.0
requests==2.22.0
requests-toolbelt==0.9.1
six==1.14.0
sqlparse==0.3.0
toml==0.10.1
tqdm==4.42.1
twine==3.1.1
urllib3==1.25.8
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_create_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import pytest

# create a simple Pytest
def test_user_create():
pass

0 comments on commit d81c3f7

Please sign in to comment.