Commit 163b57b3 authored by Jerome Flesch's avatar Jerome Flesch
Browse files

Start adding tests on API



Signed-off-by: Jerome Flesch's avatarJerome Flesch <jflesch@openpaper.work>
parent 64536d3e
......@@ -15,6 +15,20 @@ check:
- apt-get install -y -q pycodestyle flake8 python3-flake8 tox
- make check
tests:
stage: test
tags:
- linux
- volatile
script:
- sh ./set_apt_proxy.sh
- apt-get install -y -q make
- apt-get install -y -q libmariadbclient-dev build-essential
- apt-get install -y -q python3 python3-dev python3-pip
- apt-get install -y -q gettext npm
- pip3 install -r ./requirements.txt
- make test
deploy_testing:
stage: deploy
only:
......
......@@ -16,6 +16,7 @@ check:
flake8
test:
python3 ./manage.py test
linux_exe:
......
# from django.test import TestCase
# Create your tests here.
import json
import django.test
import rest_framework.test
import backend.models.scannerdb
class ScannerDbGet(django.test.TestCase):
def setUp(self):
backend.models.scannerdb.ScannerManufacturer.objects.create(
id=1,
moderated=True,
name="test manufacturer A",
)
backend.models.scannerdb.ScannerManufacturer.objects.create(
id=2,
moderated=False,
name="test manufacturer B",
)
def test_get_manufacturers(self):
request = rest_framework.test.APIClient()
request = request.get("/api/v1/scannerdb/scanner_manufacturers/")
self.assertEqual(request.status_code, 200)
body = json.loads(request.content)
self.assertEqual(body['count'], 2)
self.assertEqual(body['results'][0]["name"], "test manufacturer A")
self.assertEqual(body['results'][1]["name"], "test manufacturer B")
def test_get_manufacturer(self):
request = rest_framework.test.APIClient()
request = request.get("/api/v1/scannerdb/scanner_manufacturers/1/")
self.assertEqual(request.status_code, 200)
body = json.loads(request.content)
self.assertEqual(body["name"], "test manufacturer A")
self.assertEqual(body["moderated"], True)
Supports Markdown
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