def test_manage_used_ips_registers_ip(self): """ Test that '_manage_used_ips' successfully registers current IP. """ tor_ip_changer = TorIpChanger() current_ip = "1.1.1.1" tor_ip_changer._manage_used_ips(current_ip) self.assertEqual([current_ip], tor_ip_changer.used_ips)
def test_manage_usable_ips_releases_used_ip(self): """ Test that '_manage_used_ips' successfully releases an used IP. """ tor_ip_changer = TorIpChanger() tor_ip_changer.used_ips = ["1.1.1.1"] current_ip = "2.2.2.2" tor_ip_changer._manage_used_ips(current_ip) self.assertEqual([current_ip], tor_ip_changer.used_ips)
def test_manage_used_ips_releases_oldest_used_ip(self): """ Test that '_manage_used_ips' successfully releases oldest used IP. """ tor_ip_changer = TorIpChanger(3) tor_ip_changer._real_ip = "0.0.0.0" tor_ip_changer.used_ips = ["1.1.1.1", "2.2.2.2", "3.3.3.3"] current_ip = "4.4.4.4" expected_used_ips = ["2.2.2.2", "3.3.3.3", current_ip] tor_ip_changer._manage_used_ips(current_ip) self.assertEqual(tor_ip_changer.used_ips, expected_used_ips)