Skip to content

Commit 693d564

Browse files
committed
Black the test, add separate action for checking upstream data
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
1 parent 4073101 commit 693d564

4 files changed

Lines changed: 61 additions & 6 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: py.test -v -m webtest
41+
run: 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

vulnerabilities/importers/project_kb_msr2019.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def updated_advisories(self):
5959

6060
def fetch(self):
6161
response = urllib.request.urlopen(self.url)
62-
lines = [l.decode("utf-8") for l in response.readlines()]
62+
lines = [line.decode("utf-8") for line in response.readlines()]
6363
return csv.reader(lines)
6464

6565
@staticmethod

vulnerabilities/tests/test_upstream.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
from vulnerabilities import importers
33
from vulnerabilities.importer_yielder import IMPORTER_REGISTRY
44

5+
56
@pytest.mark.webtest
6-
@pytest.mark.parametrize(("data_source", "config"), ( (data["data_source"] , data["data_source_cfg"]) for data in IMPORTER_REGISTRY),)
7+
@pytest.mark.parametrize(
8+
("data_source", "config"),
9+
((data["data_source"], data["data_source_cfg"]) for data in IMPORTER_REGISTRY),
10+
)
711
def test_updated_advisories(data_source, config):
812

9-
if not data_source == "GitHubAPIDataSource":
13+
if not data_source == "GitHubAPIDataSource":
1014
data_src = getattr(importers, data_source)
11-
data_src = data_src(batch_size=1,config=config)
15+
data_src = data_src(batch_size=1, config=config)
1216
with data_src:
1317
for i in data_src.updated_advisories():
14-
pass
18+
pass

0 commit comments

Comments
 (0)