Skip to content

Commit

Permalink
Merge pull request #18 from zkarpinski/deepsource-autofix-84da5e66
Browse files Browse the repository at this point in the history
refactor: remove unused imports
  • Loading branch information
zkarpinski authored Jan 16, 2024
2 parents 0276f1c + 265110c commit ab5c48f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
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("", "")

0 comments on commit ab5c48f

Please sign in to comment.