Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unused imports #18

Merged
merged 2 commits into from
Jan 16, 2024
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
3 changes: 0 additions & 3 deletions codeinsight_sdk/handler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import abc
from typing import List

from .models import Project, ProjectInventory, ProjectInventoryItem, Report
from .exceptions import CodeInsightError

class Handler(abc.ABC):
def __init__(self, client):
Expand All @@ -12,4 +10,3 @@ def __init__(self, client):
@abc.abstractmethod
def get(self):
pass

28 changes: 19 additions & 9 deletions tests/test_experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@


from codeinsight_sdk import CodeInsightClient
from codeinsight_sdk.exceptions import CodeInsightError

logger = logging.getLogger(__name__)

## CHANGE ME ##
TEST_URL = "https://api.revenera.com"
TEST_API_TOKEN = "your_api_token"


class TestExperimental:
@pytest.fixture
def client(self):
return CodeInsightClient(TEST_URL, TEST_API_TOKEN, experimental=True)

def test_experimental_enabled(self, client):
assert client.experimental_enabled == True

def test_get_project_vulnerabilities(self, client):
project_id = 1
total_pages = 4
Expand Down Expand Up @@ -86,11 +86,21 @@ def test_get_project_vulnerabilities(self, client):
"vulnerabilityCvssV3Severity":"CRITICAL"} ] }
"""
with requests_mock.Mocker() as m:
m.get(f"{TEST_URL}/codeinsight/api/projects/{project_id}/inventorySummary",
text=fake_response_json, headers=response_header)
m.get(f"{TEST_URL}/codeinsight/api/inventories/12346/vulnerabilities",
text=mock_resp_vuln, headers=response_header)
vulnerable_items = client.experimental.get_project_vulnerabilities(project_id)
m.get(
f"{TEST_URL}/codeinsight/api/projects/{project_id}/inventorySummary",
text=fake_response_json,
headers=response_header,
)
m.get(
f"{TEST_URL}/codeinsight/api/inventories/12346/vulnerabilities",
text=mock_resp_vuln,
headers=response_header,
)
vulnerable_items = client.experimental.get_project_vulnerabilities(
project_id
)
assert len(vulnerable_items) > 0
assert vulnerable_items[0].vulnerabilities is not None
assert vulnerable_items[0].vulnerabilities[1].vulnerabilityName == "CVE-987-65432"
assert (
vulnerable_items[0].vulnerabilities[1].vulnerabilityName == "CVE-987-65432"
)
4 changes: 1 addition & 3 deletions tests/test_handlers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import pytest

from codeinsight_sdk import CodeInsightClient
from codeinsight_sdk.handlers import ProjectHandler, ReportHandler
from codeinsight_sdk.models import Project, Report


class TestHandlers(object):
@pytest.fixture
def client(self):
return CodeInsightClient("","")
return CodeInsightClient("", "")
Loading