Skip to content

Commit

Permalink
Add code cleanup
Browse files Browse the repository at this point in the history
Pleasing the linter, and some more documentation
  • Loading branch information
mrchrisadams committed Apr 24, 2024
1 parent c79785b commit 9adb729
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions apps/greencheck/tests/test_domain_checker.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from ipaddress import _IPAddressBase
import ipaddress
import logging
import pytest
from unittest import mock

from conftest import hosting_provider
import pytest

from apps.accounts import models as ac_models

from .. import legacy_workers
from .. import domain_check
from .. import domain_check, legacy_workers
from .. import models as gc_models
from apps.accounts import models as ac_models
from unittest import mock

pytestmark = pytest.mark.django_db

Expand All @@ -32,6 +30,9 @@ def test_with_green_domain_by_ip(self, green_ip, checker):
assert isinstance(res, legacy_workers.SiteCheck)
assert res.ip in (green_ip.ip_start, green_ip.ip_end)

# this came out of a discussion with the folks at mythic beasts
# who have some ipv6 only domains. If we need to mock it in future,
# we can
@pytest.mark.parametrize(
"domain",
[
Expand Down Expand Up @@ -144,7 +145,8 @@ def test_order_ip_range_by_size(
large_ip_range.save()

ip_matches = gc_models.GreencheckIp.objects.filter(
ip_end__gte="127.0.1.2", ip_start__lte="127.0.1.2",
ip_end__gte="127.0.1.2",
ip_start__lte="127.0.1.2",
)

res = checker.order_ip_range_by_size(ip_matches)
Expand Down Expand Up @@ -249,13 +251,13 @@ def test_lookup_green_domain_with_no_provider(

# check that we get a response back and a grey result,
# as there is no evidence left to support the green result
assert res.green == False
assert res.green is False

def test_lookup_green_domain_with_no_ip_lookup(
self, green_domain_factory, green_ip_factory, mocker, checker
):
""""""
green_ip = green_ip_factory.create()
green_ip_factory.create()

# mock our request to avoid the network call
# mocker.patch(
Expand All @@ -281,4 +283,4 @@ def test_lookup_green_domain_with_no_ip_lookup(
site_logger.log_sitecheck_to_database(res)
# check that we get a response back and a grey result,
# as there is no evidence left to support the green result
assert res.green == False
assert res.green is False

0 comments on commit 9adb729

Please sign in to comment.