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:
parent
7384dd7a2f
commit
6ca1ca2aec
|
@ -166,3 +166,55 @@ jobs:
|
|||
- name: Test
|
||||
run: make test
|
||||
working-directory: ${{ matrix.context }}
|
||||
|
||||
test-with-database:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
context: [api]
|
||||
release: [bionic, buster]
|
||||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
env:
|
||||
POSTGRES_PASSWORD: libretime
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
|
||||
container: ghcr.io/libretime/libretime-dev:${{ matrix.release }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
env:
|
||||
LIBRETIME_CONF_FILE: /tmp/libretime-test.conf
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ matrix.context }}-${{ hashFiles('**/setup.py') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-${{ matrix.context }}
|
||||
|
||||
- name: Setup libretime configuration
|
||||
run: |
|
||||
cat <<EOF > $LIBRETIME_CONF_FILE
|
||||
[general]
|
||||
api_key = test_key
|
||||
[database]
|
||||
host = postgres
|
||||
dbname = libretime
|
||||
dbuser = postgres
|
||||
dbpass = libretime
|
||||
EOF
|
||||
cat $LIBRETIME_CONF_FILE
|
||||
|
||||
- name: Test
|
||||
run: make test
|
||||
working-directory: ${{ matrix.context }}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue