Skip to content

Commit

Permalink
Correcting unit tests after localhost change.
Browse files Browse the repository at this point in the history
  • Loading branch information
laeti-tia committed Mar 13, 2024
1 parent 9cf8b50 commit c7ab378
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions python-pscheduler/pscheduler/tests/interface_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import unittest
import socket

from base_test import PschedTestBase

Expand All @@ -15,6 +16,8 @@ class TestInterface(PschedTestBase):
Interface tests.
"""

ip_to_test = socket.gethostbyname('localhost')

# The following are wrappers around another library and don't need
# testing:
# source_interface
Expand All @@ -24,13 +27,12 @@ def test_local_ip(self):
"""Local ip test"""
localips = LocalIPList(refresh=5)

self.assertTrue('localhost' in localips)
self.assertTrue(self.ip_to_test in localips)

def test_source_interface(self):
"""Source interface test"""
ip = 'localhost'
address, interface = source_interface(ip)
self.assertEqual(address, ip)
address, interface = source_interface(self.ip_to_test)
self.assertEqual(address, self.ip_to_test)
self.assertNotEqual(interface, None)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import unittest
import socket

from base_test import PschedTestBase

Expand Down Expand Up @@ -33,7 +34,7 @@ def test_identifier(self):
ident = IdentifierLocalIF(DATA)

self.assertEqual(ident.evaluate({ "requester": "192.168.1.1" }), False)
self.assertEqual(ident.evaluate({ "requester": "localhost" }), True)
self.assertEqual(ident.evaluate({ "requester": socket.gethostbyname("localhost") }), True)



Expand Down

0 comments on commit c7ab378

Please sign in to comment.