Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elyousfi5 committed Dec 6, 2024
1 parent 4a866ce commit 1ba0e76
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
5 changes: 0 additions & 5 deletions agent/subfinder_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ def set_virustotal_api_key(
if virustotal_key not in config["virustotal"]:
config["virustotal"].append(virustotal_key)
else:
# add to sources
if "sources" not in config:
config["sources"] = ["virustotal"]
elif "virustotal" not in config["sources"]:
config["sources"].append("virustotal")
config["virustotal"] = [virustotal_key]

try:
Expand Down
8 changes: 2 additions & 6 deletions tests/subfinder_agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ def testSetVirusTotalApiKey_createsSectionAndAddsKeyWhenNoSectionExists() -> Non
updated_config = yaml.load(fake_file.read_text()) or {}
assert "virustotal" in updated_config
assert updated_config["virustotal"] == ["new_key"]
assert "sources" in updated_config and "virustotal" in updated_config["sources"]


def testSetVirusTotalApiKey_whenVirusTotalSectionExists_addsKeyToExistingSection() -> (
Expand All @@ -173,7 +172,6 @@ def testSetVirusTotalApiKey_whenVirusTotalSectionExists_addsKeyToExistingSection
updated_config = yaml.load(fake_file.read_text()) or {}
assert "virustotal" in updated_config
assert updated_config["virustotal"] == ["example-api-key", "new_key"]
assert "sources" in updated_config and "virustotal" in updated_config["sources"]


def testSetVirusTotalApiKey_whenKeyAlreadyExists_doesNotAddKeyAgain() -> None:
Expand All @@ -195,12 +193,11 @@ def testSetVirusTotalApiKey_whenKeyAlreadyExists_doesNotAddKeyAgain() -> None:
updated_config = yaml.load(fake_file.read_text()) or {}
assert "virustotal" in updated_config
assert updated_config["virustotal"] == ["example-api-key"]
assert "sources" in updated_config and "virustotal" in updated_config["sources"]


def testSetVirusTotalApiKey_whenFileEmpty_createSourcesAndAddVirusTotalKey() -> None:
def testSetVirusTotalApiKey_whenFileEmpty_addVirusTotalKey() -> None:
"""
Test that the function creates a `sources` section and adds the `virustotal` key
Test that the function adds the `virustotal` key
when the configuration file is empty.
"""
fake_file_path = "/fake/path/provider-config-empty.yaml"
Expand All @@ -215,4 +212,3 @@ def testSetVirusTotalApiKey_whenFileEmpty_createSourcesAndAddVirusTotalKey() ->
updated_config = yaml.load(fake_file.read_text()) or {}
assert "virustotal" in updated_config
assert updated_config["virustotal"] == ["new_key"]
assert "sources" in updated_config and "virustotal" in updated_config["sources"]

0 comments on commit 1ba0e76

Please sign in to comment.