Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ the code Django includes for this purpose: `SECRET_KEY=$(python -c "from django.
pycodestyle --exclude=migrations,settings.py,venv --max-line-length=100 .
DJANGO_DEV=1 pytest
```

To skip tests which require internet connection:
```
DJANGO_DEV=1 pytest -m "not webtest"
```
## Data import

```
Expand Down
4 changes: 3 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[pytest]
DJANGO_SETTINGS_MODULE = vulnerablecode.settings
DJANGO_SETTINGS_MODULE = vulnerablecode.settings
markers =
webtest: marker for tests which require internet connection.
1 change: 1 addition & 0 deletions vulnerabilities/data_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def npm_dump(extract_data):
for version in data['fixed_versions']:
package_fixed = Package.objects.create(
name=package_name,
type='npm',
version=version
)
ResolvedPackage.objects.create(
Expand Down
4 changes: 3 additions & 1 deletion vulnerabilities/tests/test_npm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import os
import json

import pytest

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


@pytest.mark.webtest
def test_get_all_versions():
x = get_all_versions('electron')
expected = ['0.1.2', '2.0.0', '3.0.0',
'4.0.0', '5.0.0', '6.0.0', '7.0.0']
assert set(expected) <= set(x)


@pytest.mark.webtest
def test_extract_data():
with open(os.path.join(TEST_DATA, 'npm_test.json')) as f:
test_data = json.load(f)
Expand Down
2 changes: 2 additions & 0 deletions vulnerabilities/tests/test_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
# VulnerableCode is a free software code scanning tool from nexB Inc. and others.
# Visit https://github.com/nexB/vulnerablecode/ for support and download.

import pytest
from vulnerabilities.scraper.rust import rust_crate_advisories
from vulnerabilities.scraper.rust import load_advisory

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


@pytest.mark.webtest
def test_extract_data():
for advisory in rust_crate_advisories(RUSTSEC_DB_URL):
loaded_advisory = load_advisory(advisory)
Expand Down