added tests
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Jens Timmerman 2020-11-08 15:20:52 +01:00
parent 90b9fcdde0
commit 21a6eb656c
5 changed files with 64 additions and 6 deletions

View File

@ -8,8 +8,16 @@ platform:
arch: amd64
steps:
- name: test
commands:
- dnf install -y python3 python3-pip
- pip3 install -U Django
- python3 manage.py test
- name: install deps
commands:
- dnf install -y python3 python3-pip
- pip3 install -U Django coverage flake8 pylint django-coverage-plugin pylint-django
- name: run unittests
commands:
- coverage run --source='.' manage.py test --noinput --parallel
- name: run flake8
commands:
- flake8
- name: run pylint
commands:
- pylint --rcfile=.pylintrc -- **/*.py

14
.pylintrc Normal file
View File

@ -0,0 +1,14 @@
[MASTER]
load-plugins=pylint_django
[FORMAT]
max-line-length=120
[MESSAGES CONTROL]
disable=missing-docstring,invalid-name
[DESIGN]
max-parents=13
[TYPECHECK]
generated-members=REQUEST,acl_users,aq_parent,"[a-zA-Z]+_set{1,2}",save,delete

View File

@ -38,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'inventory.apps.InventoryConfig',
'linttest',
]
MIDDLEWARE = [
@ -100,6 +101,10 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# enabling this may speed up testing
#PASSWORD_HASHERS = [
# 'django.contrib.auth.hashers.MD5PasswordHasher',
#]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/

View File

@ -1,3 +1,25 @@
from django.test import TestCase
from django.test import Client
# Create your tests here.
from inventory.models import PantryItem, Category
class PantryItemTestCase(TestCase):
""" simple test case for a model"""
def setUp(self):
cat = Category.objects.create(name="UNCATEGORIZED")
PantryItem.objects.create(name="testitem", category=cat)
def test_pantryitem_looksok(self):
"""Pantryitems to string is ok"""
testitem = PantryItem.objects.get(name="testitem")
self.assertEqual(str(testitem), 'testitem')
class InterFaceTestCase(TestCase):
"""Simple test case for the web interface"""
def test_consume_view_exists(self):
c = Client()
response = c.get('/consume/')
self.assertTrue("TODO" not in response)

9
setup.cfg Normal file
View File

@ -0,0 +1,9 @@
[flake8]
max-line-length = 120
exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv
[coverage:run]
include = '.'
omit = *migrations*, *tests*
plugins =
django_coverage_plugin