feat: run API tests in CI (#1421)

* feat: run API tests in CI

* fix: remove incorrect test for guest user viewing themself
This commit is contained in:
Kyle Robbertze 2021-10-18 12:17:34 +00:00 committed by GitHub
parent 7384dd7a2f
commit 6ca1ca2aec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 5 deletions

View file

@ -9,3 +9,7 @@ MYPY_ARG := libretimeapi
format: .format
lint: .format-check .pylint .mypy
clean: .clean
test: $(VENV)
source $(VENV)/bin/activate
LIBRETIME_DEBUG=True $(VENV)/bin/libretime-api test libretimeapi

View file

@ -30,13 +30,13 @@ sudo systemctl stop libretime-api
sudo systemctl restart libretime-analyzer libretime-celery libretime-liquidsoap libretime-playout
cd /vagrant/api
sudo pip3 install -e .
sudo -u www-data LIBRETIME_DEBUG=True python3 bin/libretime-api runserver 0.0.0.0:8081
sudo -u www-data LIBRETIME_DEBUG=True libretime-api runserver 0.0.0.0:8081
```
Unit tests can be run in the vagrant environment using
```
sudo -u www-data LIBRETIME_DEBUG=True python3 bin/libretime-api test libretimeapi
sudo -u www-data LIBRETIME_DEBUG=True libretime-api test libretimeapi
```
## 3rd Party Licences

View file

@ -1,5 +1,6 @@
import configparser
import os
import sys
from .utils import get_random_string, read_config_file
@ -11,7 +12,9 @@ API_VERSION = "2.0.0"
try:
CONFIG = read_config_file(DEFAULT_CONFIG_PATH)
except IOError:
except IOError as e:
print(f"Unable to read config file {DEFAULT_CONFIG_PATH}", file=sys.stderr)
print(e, file=sys.stderr)
CONFIG = configparser.ConfigParser()

View file

@ -92,8 +92,6 @@ class TestPermissions(APITestCase):
self.assertEqual(
response.status_code, 403, msg="Invalid for model {}".format(model)
)
response = self.logged_in_test_model("users", "guest", GUEST, self.client.get)
self.assertEqual(response.status_code, 403, msg="Invalid for model users")
def test_dj_get_permissions(self):
for model in self.URLS: