Skip to content

Commit

Permalink
fixup! Make it possible to download anything through a proxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
funilrys committed Dec 26, 2024
1 parent b7710fe commit 2246d28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
13 changes: 0 additions & 13 deletions tests/query/dnss/test_nameserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,6 @@ def test_get_ip_from_nameserver_exceptions(self, resolver_patch) -> None:

self.assertEqual(expected, actual)

def test_get_ip_from_nameserver_not_valid_domain(self) -> None:
"""
Tests the method which let us get the IP from a nameserver for the
case that a private domain is given.
"""

given = "example.funilrys"

expected = ["example.funilrys"]
actual = self.nameserver_provider.get_ip_from_nameserver(given)

self.assertEqual(expected, actual)

@unittest.mock.patch.object(dns.resolver.Resolver, "resolve")
def test_set_nameservers(self, resolver_patch) -> None:
"""
Expand Down
26 changes: 11 additions & 15 deletions tests/query/test_http_status_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
import requests
import requests.models

import PyFunceble.factory
from PyFunceble.config.loader import ConfigLoader
from PyFunceble.query.http_status_code import HTTPStatusCode
from PyFunceble.query.requests.requester import Requester


class TestHTTPStatusCode(unittest.TestCase):
Expand Down Expand Up @@ -455,7 +455,7 @@ def test_get_status_code_no_subject(self) -> None:
# pylint: disable=unnecessary-lambda
self.assertRaises(TypeError, lambda: self.query_tool.get_status_code())

@unittest.mock.patch.object(PyFunceble.factory.Requester, "get")
@unittest.mock.patch.object(Requester, "get")
def test_get_status_code(self, request_mock) -> None:
"""
Tests the method which let us get the status code of the given subject.
Expand Down Expand Up @@ -484,17 +484,15 @@ def mocking(*args, **kwargs): # pylint: disable=unused-argument

self.assertEqual(expected, actual)

@unittest.mock.patch.object(PyFunceble.factory.Requester, "get")
@unittest.mock.patch.object(Requester, "get")
def test_get_status_code_error(self, request_mock) -> None:
"""
Tests the method which let us get the status code of the given subject
for the case that an error happened during the request.
"""

def mocking(*args, **kwargs): # pylint: disable=unused-argument
raise PyFunceble.factory.Requester.exceptions.ConnectionError(
"I'm a teapot."
)
raise Requester.exceptions.ConnectionError("I'm a teapot.")

self.query_tool.subject = "https://example.org"

Expand All @@ -505,17 +503,15 @@ def mocking(*args, **kwargs): # pylint: disable=unused-argument

self.assertEqual(expected, actual)

@unittest.mock.patch.object(PyFunceble.factory.Requester, "get")
@unittest.mock.patch.object(Requester, "get")
def test_get_status_code_too_many_redirects(self, request_mock) -> None:
"""
Tests the method which let us get the status code of the given subject
for the case that too many redirects happened during the request.
"""

def mocking(*args, **kwargs): # pylint: disable=unused-argument
raise PyFunceble.factory.Requester.exceptions.TooManyRedirects(
"Exceeded 30 redirects."
)
raise Requester.exceptions.TooManyRedirects("Exceeded 30 redirects.")

self.query_tool.subject = "https://example.org"

Expand All @@ -526,7 +522,7 @@ def mocking(*args, **kwargs): # pylint: disable=unused-argument

self.assertEqual(expected, actual)

@unittest.mock.patch.object(PyFunceble.factory.Requester, "get")
@unittest.mock.patch.object(Requester, "get")
def test_get_status_code_http_to_https(self, request_mock) -> None:
"""
Tests the method which let us get the status code of the given subject
Expand Down Expand Up @@ -559,7 +555,7 @@ def mocking(*args, **kwargs): # pylint: disable=unused-argument

self.assertEqual(expected, actual)

@unittest.mock.patch.object(PyFunceble.factory.Requester, "get")
@unittest.mock.patch.object(Requester, "get")
def test_get_status_code_http_to_https_different_subject(
self, request_mock
) -> None:
Expand Down Expand Up @@ -595,7 +591,7 @@ def mocking(*args, **kwargs): # pylint: disable=unused-argument

self.assertEqual(expected, actual)

@unittest.mock.patch.object(PyFunceble.factory.Requester, "get")
@unittest.mock.patch.object(Requester, "get")
def test_get_status_code_http_to_https_different_subject_allow_redirects(
self, request_mock
) -> None:
Expand Down Expand Up @@ -635,7 +631,7 @@ def mocking(*args, **kwargs): # pylint: disable=unused-argument

self.assertEqual(expected, actual)

@unittest.mock.patch.object(PyFunceble.factory.Requester, "get")
@unittest.mock.patch.object(Requester, "get")
def test_get_status_code_http_to_https_multiple_jump(self, request_mock) -> None:
"""
Tests the method which let us get the status code of the given subject
Expand Down Expand Up @@ -681,7 +677,7 @@ def mocking(*args, **kwargs): # pylint: disable=unused-argument

self.assertEqual(expected, actual)

@unittest.mock.patch.object(PyFunceble.factory.Requester, "get")
@unittest.mock.patch.object(Requester, "get")
def test_get_status_code_http_to_https_multiple_jump_allow_redirects(
self, request_mock
) -> None:
Expand Down

0 comments on commit 2246d28

Please sign in to comment.