Commit 89bceb35 authored by Nico Alt's avatar Nico Alt

Add unit tests with pytest

parent 1f991db7
Pipeline #3499 failed with stage
in 3 minutes and 48 seconds
builddir
.flatpak-builder
__pycache__
test:lints:
test:pycodestyle:
image: debian:stretch
script:
- apt update && apt install --no-install-recommends -y gir1.2-gtk-3.0 python3-gi python3-pip python3-setuptools
- pip3 install -r requirements-dev.txt
- tools/tests/test-pycodestyle.sh
test:pylint:
image: debian:stretch
script:
- apt update && apt install --no-install-recommends -y gir1.2-gtk-3.0 python3-gi python3-pip python3-setuptools
- pip3 install -r requirements-dev.txt
- tools/tests/test-pylint.sh
test:pytest:
image: debian:stretch
script:
- apt update && apt install --no-install-recommends -y gir1.2-gtk-3.0 python3-gi python3-pip python3-setuptools
- pip3 install -r requirements-dev.txt
- tools/tests/test-pytest.sh
-r requirements.txt
pycodestyle>=2.5.0
pylint>=2.3.1
pytest>=4.6.2
requests_mock>=1.6.0
# Copyright (c) 2019 Nico Alt
# SPDX-License-Identifier: AGPL-3.0-only
# License-Filename: LICENSE.md
import json
import requests_mock
from unittest import mock, TestCase
from briar.api.models.contacts import Contacts
class TestContacts(TestCase):
@requests_mock.Mocker()
def test_get(self, requests_mock):
api = mock.Mock()
contacts = Contacts(api)
response_mock = {}
response_mock["author"] = {}
response_mock["author"]["formatVersion"] = 1
response_mock["author"]["id"] = "y1wkIzAimAbYoCGgWxkWlr6vnq1F8t1QRA/UMPgI0E0="
response_mock["author"]["name"] = "Test"
response_mock["author"]["publicKey"] = "BDu6h1S02bF4W6rgoZfZ6BMjTj/9S9hNN7EQoV05qUo="
response_mock["contactId"] = 1
response_mock["alias"] = "A local nickname"
response_mock["handshakePublicKey"] = "XnYRd7a7E4CTqgAvh4hCxh/YZ0EPscxknB9ZcEOpSzY="
response_mock["verified"] = True
requests_mock.get("http://localhost:7000/v1/contacts", text=json.dumps(response_mock))
self.assertEqual(contacts.get(), response_mock)
......@@ -2,3 +2,4 @@
tools/tests/test-pycodestyle.sh
tools/tests/test-pylint.sh
tools/tests/test-pytest.sh
#!/usr/bin/env bash
PYTHONPATH=src pytest tests/
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