Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Update #80

Merged
merged 15 commits into from
Sep 21, 2017
8 changes: 4 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
--requirement requirements.txt

# Testing
pytest==2.8.5
pytest-cov==2.2.0
coveralls==1.1
flake8==2.5.4
pytest==3.2.2
pytest-cov==2.5.1
coveralls==1.2.0
flake8==3.4.1
mock==2.0.0
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
requests==2.13.0
requests==2.18.4
suds-jurko==0.6
dogpile.cache==0.5.7
dogpile.cache==0.6.4
six==1.10.0
zope.deprecation==4.2.0
zope.deprecation==4.3.0
7 changes: 7 additions & 0 deletions tests/.cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"gateway/test_capakey.py::TestCapakeyRestGateway::()::test_list_afdelingen": true,
"gateway/test_capakey.py::TestPerceel::()::test_lazy_load": true,
"gateway/test_crab.py::TestCrabGateway::()::test_get_huisnummer_by_nummer_and_straat": true,
"gateway/test_crab.py::TestCrabGateway::()::test_list_huisnummers_by_perceel_empty": true,
"gateway/test_crab_cached.py::TestCrabCachedGateway::()::test_list_aardterreinobjecten_different_sort": true
}
21 changes: 9 additions & 12 deletions tests/gateway/test_capakey.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,17 @@ def test_fully_initialised(self):
(104154.2225, 197300.703),
(94653.453, 185680.984, 113654.992, 208920.422)
)
assert (g.id, 44021)
assert (g.naam, 'Gent')
assert (g.centroid, (104154.2225, 197300.703))
assert (
g.bounding_box,
(94653.453, 185680.984, 113654.992, 208920.422)
)
assert ('Gent (44021)', str(g))
assert ("Gemeente(44021, 'Gent')", repr(g))
assert g.id == 44021
assert g.naam == 'Gent'
assert g.centroid == (104154.2225, 197300.703)
assert g.bounding_box == (94653.453, 185680.984, 113654.992, 208920.422)
assert 'Gent (44021)' == str(g)
assert "Gemeente(44021, 'Gent')" == repr(g)

def test_str_and_repr_dont_lazy_load(self):
g = Gemeente(44021, 'Gent')
assert ('Gent (44021)', str(g))
assert ("Gemeente(44021, 'Gent')", repr(g))
assert 'Gent (44021)' == str(g)
assert "Gemeente(44021, 'Gent')" == repr(g)

def test_check_gateway_not_set(self):
g = Gemeente(44021, 'Gent')
Expand Down Expand Up @@ -506,7 +503,7 @@ def test_fully_initialised(self):
assert s.id == 'A'
assert s.centroid == (104893.06375, 196022.244094)
assert s.bounding_box == (104002.076625, 194168.3415, 105784.050875, 197876.146688)
assert ('Gent 1 AFD (44021), Sectie A', str(s))
assert 'Gent 1 AFD (44021), Sectie A' == str(s)
assert "Sectie('A', Afdeling(44021, 'Gent 1 AFD'))" == repr(s)

def test_check_gateway_not_set(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/gateway/test_capakey_cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_get_kadastrale_afdeling_by_id(self, capakey_gateway):
def test_list_secties_by_afdeling_id(self, capakey_gateway):
res = capakey_gateway.list_secties_by_afdeling(44021)
assert isinstance(res, list)
assert (len(res), 1)
assert len(res) == 1
assert capakey_gateway.caches['long'].get('ListKadSectiesByKadAfdelingcode#44021') == res

def test_get_sectie_by_id_and_afdeling(self, capakey_gateway):
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_get_kadastrale_afdeling_by_id(self, capakey_rest_gateway):
def test_list_secties_by_afdeling_id(self, capakey_rest_gateway):
res = capakey_rest_gateway.list_secties_by_afdeling(44021)
assert isinstance(res, list)
assert (len(res), 1)
assert len(res) == 1
assert capakey_rest_gateway.caches['long'].get('list_secties_by_afdeling_rest#44021') == res

def test_get_sectie_by_id_and_afdeling(self, capakey_rest_gateway):
Expand Down
44 changes: 21 additions & 23 deletions tests/gateway/test_crab.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ def test_get_provincie_by_id(self):
assert res.niscode == 40000
res = self.crab.get_provincie_by_id(50000)
assert isinstance(res, Provincie)
assert (res.niscode, 50000)
assert res.niscode == 50000
res = self.crab.get_provincie_by_id(60000)
assert isinstance(res, Provincie)
assert (res.niscode, 60000)
assert res.niscode == 60000
res = self.crab.get_provincie_by_id(70000)
assert isinstance(res, Provincie)
assert (res.niscode, 70000)
assert res.niscode == 70000
res = self.crab.get_provincie_by_id(80000)
assert isinstance(res, Provincie)
assert (res.niscode, 80000)
assert res.niscode == 80000
res = self.crab.get_provincie_by_id(90000)
assert isinstance(res, Provincie)
assert (res.niscode, 90000)
assert res.niscode == 90000

def test_get_provincie_by_unexisting_id(self):
with pytest.raises(GatewayResourceNotFoundException):
Expand All @@ -139,17 +139,17 @@ def test_list_gemeenten_by_provincie(self):
res = self.crab.list_gemeenten_by_provincie(provincie)
assert isinstance(res, list)
assert isinstance(res[0], Gemeente)
assert (str(res[0].niscode)[0], '1')
assert str(res[0].niscode)[0] == '1'
provincie = 10000
res = self.crab.list_gemeenten_by_provincie(provincie)
assert isinstance(res, list)
assert isinstance(res[0], Gemeente)
assert (str(res[0].niscode)[0], '1')
assert str(res[0].niscode)[0] == '1'

def test_get_gemeente_by_id(self):
res = self.crab.get_gemeente_by_id(1)
assert isinstance(res, Gemeente)
assert (res.id, 1)
assert res.id == 1

def test_get_gemeente_by_id_with_string(self):
with pytest.raises(GatewayRuntimeException):
Expand All @@ -162,7 +162,7 @@ def test_get_gemeente_by_unexisting_id(self):
def test_get_gemeente_by_niscode(self):
res = self.crab.get_gemeente_by_niscode(11001)
assert isinstance(res, Gemeente)
assert (res.niscode, 11001)
assert res.niscode == 11001

def test_get_gemeente_by_unexisting_niscode(self):
with pytest.raises(GatewayResourceNotFoundException):
Expand Down Expand Up @@ -342,8 +342,8 @@ def test_get_huisnummer_by_unexisting_id(self):
def test_get_huisnummer_by_nummer_and_straat(self):
res = self.crab.get_huisnummer_by_nummer_and_straat(1, 1)
assert isinstance(res, Huisnummer)
assert (res.huisnummer, '1')
assert (res.straat.id, 1)
assert res.huisnummer == '1'
assert res.straat.id == 1
straat = self.crab.get_straat_by_id(1)
res = self.crab.get_huisnummer_by_nummer_and_straat(1, straat)
assert isinstance(res, Huisnummer)
Expand Down Expand Up @@ -1060,8 +1060,8 @@ def test_lazy_load(self):

def test_str_and_repr_dont_lazy_load(self):
s = Straat(1, 'Acacialaan', 1, 3)
assert ('Acacialaan (1)', str(s))
assert ("Straat(1, 'Acacialaan', 1, 3)", repr(s))
assert 'Acacialaan (1)' == str(s)
assert "Straat(1, 'Acacialaan', 1, 3)" == repr(s)

def test_check_gateway_not_set(self):
s = Straat(1, 'Acacialaan', 1, 3)
Expand Down Expand Up @@ -1319,7 +1319,7 @@ def test_bounding_box(self):
h.set_gateway(crab)
bounding = h.bounding_box
assert isinstance(bounding, list)
assert (len(bounding), 4)
assert len(bounding) == 4

def test_check_gateway_not_set(self):
h = Huisnummer(1, 3, '51', 17718)
Expand Down Expand Up @@ -1531,12 +1531,10 @@ def test_lazy_load(self):
)
w = Wegsegment('108724', 4)
w.set_gateway(crab)
assert (w.id, "108724")
assert (int(w.status.id), 4)
assert (int(w.methode.id), 3)
assert (
w.geometrie,
"""LINESTRING (150339.255243488 201166.401677653,\
assert w.id == "108724"
assert int(w.status.id) == 4
assert int(w.methode.id) == 3
assert w.geometrie == """LINESTRING (150339.255243488 201166.401677653,\
150342.836939491 201165.832525652,\
150345.139531493 201165.466573652,\
150349.791371495 201164.769421652,\
Expand All @@ -1558,7 +1556,7 @@ def test_lazy_load(self):
150543.214411631 200773.35943738,\
150546.079307631 200764.489805374,\
150548.592075631 200754.511565369)"""
)

w.metadata.set_gateway(crab)
assert isinstance(w.metadata, Metadata)
assert not w.metadata.begin_datum == None
Expand Down Expand Up @@ -1613,7 +1611,7 @@ def test_lazy_load(self):
t = Terreinobject("13040_C_1747_G_002_00", 1)
t.set_gateway(crab)
assert t.id == "13040_C_1747_G_002_00"
assert t.centroid == (190708.59, 224667.59)
assert t.centroid == (190707.77, 224673.21)
assert t.bounding_box == (190700.24, 224649.87, 190716.95, 224701.7)
assert int(t.aard.id) == 1
t.metadata.set_gateway(crab)
Expand Down Expand Up @@ -1673,7 +1671,7 @@ def test_lazy_load(self):
p = Perceel("13040C1747/00G002")
p.set_gateway(crab)
assert p.id == "13040C1747/00G002"
assert p.centroid == (190708.59, 224667.59)
assert p.centroid == (190707.77, 224673.21)
p.metadata.set_gateway(crab)
assert isinstance(p.metadata, Metadata)
assert p.metadata.begin_datum is not None
Expand Down
6 changes: 3 additions & 3 deletions tests/gateway/test_crab_cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_list_provincies(self):
res = self.crab.list_provincies(2)
assert isinstance(res, list)
assert self.crab.caches['permanent'].get('ListProvinciesByGewestId#2') == res
assert (res[0].gewest.id, 2)
assert res[0].gewest.id == 2

def test_get_provincie_by_id(self):
res = self.crab.get_provincie_by_id(10000)
Expand All @@ -77,14 +77,14 @@ def test_list_gemeenten_default_is_Vlaanderen(self):
res = self.crab.list_gemeenten()
assert isinstance(res, list)
assert self.crab.caches['permanent'].get('ListGemeentenByGewestId#2#1') == res
assert (res[0].gewest.id, 2)
assert res[0].gewest.id == 2

def test_list_gemeenten_gewest_1(self):
gewest = Gewest(1)
r = self.crab.list_gemeenten(gewest)
assert isinstance(r, list)
assert self.crab.caches['permanent'].get('ListGemeentenByGewestId#1#1') == r
assert (r[0].gewest.id, 1)
assert r[0].gewest.id == 1

def test_list_gemeenten_different_sort(self):
res = self.crab.list_gemeenten(2, 1)
Expand Down