Commit b4f68a1c authored by David Haynes's avatar David Haynes

Merge branch '43-unittests' into 40-python3port

parents 021d4fb7 77323817
Pipeline #756 passed with stage
in 1 minute and 6 seconds
image: ubuntu:14.04 image: library/python:2.7
services: services:
- mysql:latest - mysql:latest
...@@ -14,25 +14,24 @@ test_Go: ...@@ -14,25 +14,24 @@ test_Go:
type: test type: test
before_script: before_script:
- apt-get update -qy - apt-get update -qy
- apt-get install -y python-dev python-pip python-pip libldap2-dev mysql-client libmysqlclient-dev python-mysqldb libsasl2-dev libjpeg-dev git - apt-get install -y libldap2-dev mysql-client libmysqlclient-dev python-mysqldb libjpeg-dev libsasl2-dev
- pip install -r requirements.txt - pip install -r requirements.txt
- pip install coverage - cd go/
- cp go/settings/settings.py.template go/settings/settings.py - cp settings/settings.py.template settings/settings.py
- cp go/settings/secret.py.template go/settings/secret.py - cp settings/secret.py.template settings/secret.py
- export SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null) - export SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null)
- sed -i go/settings/secret.py -e 's/DB_NAME.*/DB_NAME = \"go\"/'
- sed -i go/settings/secret.py -e 's/DB_USER.*/DB_USER = \"root\"/'
- sed -i go/settings/secret.py -e 's/DB_PASSWORD.*/DB_PASSWORD = \"root\"/'
- sed -i go/settings/secret.py -e 's/DB_HOST.*/DB_HOST = \"mysql\"/'
- sed -i go/settings/secret.py -e 's/SECRET_KEY.*/SECRET_KEY = \"${SECRET_KEY}\"/'
- cd go
- export DJANGO_DEBUG="True" - export DJANGO_DEBUG="True"
- sed -i settings/secret.py -e 's/DB_NAME.*/DB_NAME = \"go\"/'
- sed -i settings/secret.py -e 's/DB_USER.*/DB_USER = \"root\"/'
- sed -i settings/secret.py -e 's/DB_PASSWORD.*/DB_PASSWORD = \"root\"/'
- sed -i settings/secret.py -e 's/DB_HOST.*/DB_HOST = \"mysql\"/'
- sed -i settings/secret.py -e 's/SECRET_KEY.*/SECRET_KEY = \"${SECRET_KEY}\"/'
- python manage.py makemigrations - python manage.py makemigrations
- python manage.py makemigrations go - python manage.py makemigrations go
- python manage.py migrate - python manage.py migrate
- echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('root', 'root@srct.gmu.edu', 'root') " | python ./manage.py shell - echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('root', 'root@srct.gmu.edu', 'root') " | python manage.py shell
script: script:
- cd .. - pip install coverage
- coverage run --source=go ./go/manage.py test - pip install tblib
- coverage html - coverage run --source=go --omit=*migrations/* manage.py test --parallel
- grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}' - coverage html -i && grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}'
...@@ -3,6 +3,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi ...@@ -3,6 +3,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# Django Imports # Django Imports
from django.test import TestCase from django.test import TestCase
from django.contrib.auth.models import User
# App Imports # App Imports
from go.models import URL, RegisteredUser from go.models import URL, RegisteredUser
...@@ -10,10 +11,23 @@ from go.models import URL, RegisteredUser ...@@ -10,10 +11,23 @@ from go.models import URL, RegisteredUser
""" """
Test cases for the URL Model Test cases for the URL Model
""" """
class URLTestCase(TestCase): class URLTest(TestCase):
""" """
Default test case, does not actually test anything Default test case, does not actually test anything
""" """
def test_Django_Test(self): def test_Django_Test(self):
self.assertEqual("Hello World!", "Hello World!") self.assertEqual("Hello World!", "Hello World!")
"""
Test cases for the RegisteredUser Model
"""
class RegisteredUserTest(TestCase):
def setUp(self):
User.objects.create(username='dhaynes', password='password')
def test_RegisteredUserCreation(self):
getUser = User.objects.get(username='dhaynes')
getRegisteredUser = RegisteredUser.objects.get(user=getUser)
self.assertTrue(getRegisteredUser)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment