mirror of
https://github.com/KevinMidboe/cloudflare-ddns.git
synced 2025-12-08 20:28:54 +00:00
Unit tests for valid IP, public IP & CF API requests
This commit is contained in:
33
tests/test_ip_address.py
Normal file
33
tests/test_ip_address.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import unittest
|
||||
from src.main import validIP
|
||||
|
||||
MOCK_IP = "44.208.147.61"
|
||||
|
||||
|
||||
class TestIPAddress(unittest.TestCase):
|
||||
def test_valid_ip(self):
|
||||
self.assertTrue(validIP(MOCK_IP))
|
||||
|
||||
def test_invalid_ip(self):
|
||||
ip = "256.0.0.1"
|
||||
self.assertFalse(validIP(ip))
|
||||
|
||||
def test_invalid_format(self):
|
||||
ip = "192.168.1"
|
||||
self.assertFalse(validIP(ip))
|
||||
|
||||
def test_empty_string(self):
|
||||
ip = ""
|
||||
self.assertFalse(validIP(ip))
|
||||
|
||||
def test_error_looking_string(self):
|
||||
ip = "upstream connect error or disconnect/reset before headers. reset reason: connection timeout."
|
||||
self.assertFalse(validIP(ip))
|
||||
|
||||
def test_none(self):
|
||||
ip = None
|
||||
self.assertFalse(validIP(ip))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user