Exemplo n.º 1
0
def test_get_geo_ip_url_error(Client_mock):
    Client_mock.get_soap_client_service.return_value = service = MagicMock()
    service.GetGeoIP.return_value = geo_ip = Mock()
    geo_ip.CountryName = 'Country Name'
    print service, Client_mock

    result = get_geo_ip('1.2.3.4')

    Client_mock.get_soap_client_service.assert_called_once()
    service.GetGeoIP.assert_called_once_with('1.2.3.4')
    assert 'Country Name' == result
def test_get_geo_ip_url_error(Client_mock):
    Client_mock.get_soap_client_service.return_value = service = MagicMock()
    service.GetGeoIP.return_value = geo_ip = Mock()
    geo_ip.CountryName = 'Country Name'
    print service, Client_mock

    result = get_geo_ip('1.2.3.4')

    Client_mock.get_soap_client_service.assert_called_once()
    service.GetGeoIP.assert_called_once_with('1.2.3.4')
    assert 'Country Name' == result
Exemplo n.º 3
0
from lib.geoipserverice import get_geo_ip
import logging


__author__ = 'Hossein Zolfi <*****@*****.**>'

do_log = False
if do_log:
    logging.basicConfig(level=logging.INFO)
    logging.getLogger('suds.client').setLevel(logging.DEBUG)

print get_geo_ip('4.2.2.4')
Exemplo n.º 4
0
def test_get_geo_ip_timeout(Client_mock):
    Client_mock.get_soap_client_service.side_effect = timeout
    result = get_geo_ip('1.2.3.4')
    Client_mock.get_soap_client_service.assert_called_once()
    assert None == result
Exemplo n.º 5
0
def test_get_geo_ip_url_error(Client_mock):
    Client_mock.get_soap_client_service.side_effect = URLError('')
    result = get_geo_ip('1.2.3.4')
    Client_mock.get_soap_client_service.assert_called_once()
    assert None == result
def test_get_geo_ip_timeout(Client_mock):
    Client_mock.get_soap_client_service.side_effect = timeout
    result = get_geo_ip('1.2.3.4')
    Client_mock.get_soap_client_service.assert_called_once()
    assert None == result
def test_get_geo_ip_url_error(Client_mock):
    Client_mock.get_soap_client_service.side_effect = URLError('')
    result = get_geo_ip('1.2.3.4')
    Client_mock.get_soap_client_service.assert_called_once()
    assert None == result
Exemplo n.º 8
0
from lib.geoipserverice import get_geo_ip
import logging

__author__ = 'Hossein Zolfi <*****@*****.**>'

do_log = False
if do_log:
    logging.basicConfig(level=logging.INFO)
    logging.getLogger('suds.client').setLevel(logging.DEBUG)

print get_geo_ip('4.2.2.4')