Skip to content

Commit 86424ee

Browse files
authored
Merge pull request #365 from sbs2001/test_upstream_data
Add tests to check upstream data
2 parents 8f9850f + 60370ee commit 86424ee

4 files changed

Lines changed: 71 additions & 2 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
pip install -r requirements.txt
3939
4040
- name: Run tests
41-
run: python -m pytest
41+
run: python -m pytest -v -m "not webtest"
4242
env:
4343
# The hostname, username used to communicate with the PostgreSQL service container
4444
POSTGRES_HOST: localhost
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
on:
2+
workflow_dispatch: # allow manual execution
3+
push:
4+
schedule:
5+
# run on every 9 o'clock
6+
- cron: '0 9 * * *'
7+
8+
jobs:
9+
unit_tests:
10+
runs-on: ubuntu-latest
11+
12+
services:
13+
# Label used to access the service container
14+
postgres:
15+
image: postgres
16+
env:
17+
POSTGRES_PASSWORD: vulnerablecode
18+
POSTGRES_DB: vulnerablecode
19+
# Set health checks to wait until postgres has started
20+
options: >-
21+
--health-cmd pg_isready
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
25+
ports:
26+
# Maps tcp port 5432 on service container to the host
27+
- 5432:5432
28+
steps:
29+
- name: Check out repository code
30+
uses: actions/checkout@v2
31+
32+
- name: Set up Python 3.8
33+
uses: actions/setup-python@v2
34+
with:
35+
python-version: 3.8
36+
37+
- name: Install dependencies
38+
run: |
39+
sudo apt install python3-dev postgresql libpq-dev build-essential libxml2-dev libxslt1-dev
40+
python -m pip install --upgrade pip
41+
pip install -r requirements.txt
42+
43+
- name: Run tests
44+
run: pytest -v -m webtest
45+
env:
46+
# The hostname, username used to communicate with the PostgreSQL service container
47+
POSTGRES_HOST: localhost
48+
VC_DB_USER: postgres
49+
POSTGRES_PORT: 5432
50+
DJANGO_DEV: 1
51+
GH_TOKEN: 1

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ before_script:
1818

1919
script:
2020
- ./manage.py collectstatic
21-
- python -m pytest
21+
- python -m pytest -v -m "not webtest"
2222

2323
notifications:
2424
email: false
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import pytest
2+
from vulnerabilities import importers
3+
from vulnerabilities.importer_yielder import IMPORTER_REGISTRY
4+
5+
6+
@pytest.mark.webtest
7+
@pytest.mark.parametrize(
8+
("data_source", "config"),
9+
((data["data_source"], data["data_source_cfg"]) for data in IMPORTER_REGISTRY),
10+
)
11+
def test_updated_advisories(data_source, config):
12+
13+
if not data_source == "GitHubAPIDataSource":
14+
data_src = getattr(importers, data_source)
15+
data_src = data_src(batch_size=1, config=config)
16+
with data_src:
17+
for i in data_src.updated_advisories():
18+
pass

0 commit comments

Comments
 (0)