mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-16 22:10:26 +00:00
Add a test for the LocationInfo plugin
Because the GeoIP database now requires registration to download the result of the lookup using geoip-database is not going to change.
This commit is contained in:
parent
b328520f08
commit
10170b2966
4 changed files with 45 additions and 0 deletions
|
|
@ -21,6 +21,8 @@ addons:
|
|||
apt:
|
||||
packages:
|
||||
- clamav-daemon
|
||||
- geoip-database
|
||||
- libgeoip-dev
|
||||
install:
|
||||
- pip install tox-travis coveralls
|
||||
before_script:
|
||||
|
|
|
|||
|
|
@ -220,6 +220,16 @@ def has_x11():
|
|||
need_x11 = _need_func(has_x11, "X11")
|
||||
|
||||
|
||||
@lru_cache(1)
|
||||
def has_geoip():
|
||||
from linkcheck.plugins import locationinfo
|
||||
|
||||
return locationinfo.geoip is not None
|
||||
|
||||
|
||||
need_geoip = _need_func(has_geoip, "geoip")
|
||||
|
||||
|
||||
@lru_cache(1)
|
||||
def has_word():
|
||||
"""Test if Word is available."""
|
||||
|
|
|
|||
32
tests/test_locationinfo.py
Normal file
32
tests/test_locationinfo.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Copyright (C) 2020 Chris Mayo
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
"""
|
||||
Test LocationInfo plugin.
|
||||
|
||||
Requires GeoIP (libgeoip-dev to build) and geoip-database
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from linkcheck.plugins import locationinfo
|
||||
from tests import need_geoip
|
||||
|
||||
|
||||
class TestLocationInfo(unittest.TestCase):
|
||||
@need_geoip
|
||||
def test_get_location(self):
|
||||
location = locationinfo.get_location("8.8.8.8")
|
||||
self.assertEqual(location, "United States")
|
||||
1
tox.ini
1
tox.ini
|
|
@ -11,6 +11,7 @@ deps =
|
|||
pytest-cov
|
||||
miniboa >= 1.0.8
|
||||
biplist
|
||||
GeoIP
|
||||
|
||||
[testenv]
|
||||
usedevelop = true
|
||||
|
|
|
|||
Loading…
Reference in a new issue