Skip to content

Commit 4c952ad

Browse files
authored
Merge pull request #166 from sbs2001/develop
Allow skipping internet dependent tests, fix npm dump
2 parents c5c69a4 + c97975a commit 4c952ad

5 files changed

Lines changed: 13 additions & 3 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ the code Django includes for this purpose: `SECRET_KEY=$(python -c "from django.
5656
pycodestyle --exclude=migrations,settings.py,venv --max-line-length=100 .
5757
DJANGO_DEV=1 pytest
5858
```
59-
59+
To skip tests which require internet connection:
60+
```
61+
DJANGO_DEV=1 pytest -m "not webtest"
62+
```
6063
## Data import
6164

6265
```

pytest.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
[pytest]
2-
DJANGO_SETTINGS_MODULE = vulnerablecode.settings
2+
DJANGO_SETTINGS_MODULE = vulnerablecode.settings
3+
markers =
4+
webtest: marker for tests which require internet connection.

vulnerabilities/data_dump.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def npm_dump(extract_data):
185185
for version in data['fixed_versions']:
186186
package_fixed = Package.objects.create(
187187
name=package_name,
188+
type='npm',
188189
version=version
189190
)
190191
ResolvedPackage.objects.create(

vulnerabilities/tests/test_npm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import os
2525
import json
26-
26+
import pytest
2727

2828
from vulnerabilities.scraper.npm import extract_data
2929
from vulnerabilities.scraper.npm import get_all_versions
@@ -32,13 +32,15 @@
3232
TEST_DATA = os.path.join(BASE_DIR, 'test_data/')
3333

3434

35+
@pytest.mark.webtest
3536
def test_get_all_versions():
3637
x = get_all_versions('electron')
3738
expected = ['0.1.2', '2.0.0', '3.0.0',
3839
'4.0.0', '5.0.0', '6.0.0', '7.0.0']
3940
assert set(expected) <= set(x)
4041

4142

43+
@pytest.mark.webtest
4244
def test_extract_data():
4345
with open(os.path.join(TEST_DATA, 'npm_test.json')) as f:
4446
test_data = json.load(f)

vulnerabilities/tests/test_rust.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
# VulnerableCode is a free software code scanning tool from nexB Inc. and others.
2222
# Visit https://github.com/nexB/vulnerablecode/ for support and download.
2323

24+
import pytest
2425
from vulnerabilities.scraper.rust import rust_crate_advisories
2526
from vulnerabilities.scraper.rust import load_advisory
2627

2728
RUSTSEC_DB_URL = 'https://github.com/RustSec/advisory-db/archive/master.zip'
2829

2930

31+
@pytest.mark.webtest
3032
def test_extract_data():
3133
for advisory in rust_crate_advisories(RUSTSEC_DB_URL):
3234
loaded_advisory = load_advisory(advisory)

0 commit comments

Comments
 (0)