-
Notifications
You must be signed in to change notification settings - Fork 18
Rework Saarland parser #183
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,4 +13,5 @@ dependencies = [ | |
| "requests==2.32.4", | ||
| "scrapy==2.13.3", | ||
| "sqlalchemy==1.3.10", | ||
| "xmltodict==0.13.0", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import unittest | ||
|
|
||
| from scrapy.http import TextResponse | ||
|
|
||
| from jedeschule.spiders.saarland import SaarlandSpider | ||
|
|
||
|
|
||
| class TestSaarlandSpider(unittest.TestCase): | ||
| def test_parse(self): | ||
| xml_response = """<?xml version="1.0" encoding="utf-8" ?> | ||
| <wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:Staatliche_Dienste="https://geoportal.saarland.de/arcgis/services/Internet/Staatliche_Dienste/MapServer/WFSServer" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" timeStamp="2025-07-20T17:40:21Z" numberMatched="317" numberReturned="1" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd https://geoportal.saarland.de/arcgis/services/Internet/Staatliche_Dienste/MapServer/WFSServer https://geoportal.saarland.de/arcgis/services/Internet/Staatliche_Dienste/MapServer/WFSServer?service=wfs%26version=2.0.0%26request=DescribeFeatureType"> | ||
| <wfs:member> | ||
| <Staatliche_Dienste:Schulen_SL gml:id="Schulen_SL.1"> | ||
| <Staatliche_Dienste:SHAPE> | ||
| <gml:Point gml:id="Schulen_SL.1.pn.0" srsName="urn:ogc:def:crs:EPSG::4326"> | ||
| <gml:pos>49.24067452 7.02085050</gml:pos> | ||
| </gml:Point> | ||
| </Staatliche_Dienste:SHAPE> | ||
| <Staatliche_Dienste:OBJECTID>1</Staatliche_Dienste:OBJECTID> | ||
| <Staatliche_Dienste:fid>1.00000000</Staatliche_Dienste:fid> | ||
| <Staatliche_Dienste:Gemeindenu>1100.00000000</Staatliche_Dienste:Gemeindenu> | ||
| <Staatliche_Dienste:PLZ>66123.00000000</Staatliche_Dienste:PLZ> | ||
| <Staatliche_Dienste:Ort>Saarbrücken</Staatliche_Dienste:Ort> | ||
| <Staatliche_Dienste:Straße>Kohlweg 7</Staatliche_Dienste:Straße> | ||
| <Staatliche_Dienste:Bezeichnun>Deutsch-Französiche Hochschule, Université franco-allemande</Staatliche_Dienste:Bezeichnun> | ||
| <Staatliche_Dienste:Telefon>0681-93812100</Staatliche_Dienste:Telefon> | ||
| <Staatliche_Dienste:Fax>0681-93812111</Staatliche_Dienste:Fax> | ||
| <Staatliche_Dienste:Email>[email protected]</Staatliche_Dienste:Email> | ||
| <Staatliche_Dienste:Schulform>Hochschule</Staatliche_Dienste:Schulform> | ||
| <Staatliche_Dienste:Homepage>https://www.dfh-ufa.org/</Staatliche_Dienste:Homepage> | ||
| <Staatliche_Dienste:Schulregio>Saarbrücken</Staatliche_Dienste:Schulregio> | ||
| <Staatliche_Dienste:KARTENERST>Hochschule</Staatliche_Dienste:KARTENERST> | ||
| <Staatliche_Dienste:Rechtswert>355942.97630000</Staatliche_Dienste:Rechtswert> | ||
| <Staatliche_Dienste:Hochwert>5456095.93600000</Staatliche_Dienste:Hochwert> | ||
| <Staatliche_Dienste:Aktualisie>20.05.2025</Staatliche_Dienste:Aktualisie> | ||
| </Staatliche_Dienste:Schulen_SL> | ||
| </wfs:member> | ||
| </wfs:FeatureCollection> | ||
| """ | ||
|
|
||
| spider = SaarlandSpider() | ||
| response = TextResponse(url="https://test.com", body=xml_response, encoding="utf-8") | ||
| schools = list(spider.parse(response)) | ||
| self.assertEqual(len(schools), 1) | ||
|
|
||
| school = schools[0] | ||
|
|
||
| self.assertEqual(school["OBJECTID"], "1") | ||
| self.assertEqual(school["fid"], "1.00000000") | ||
| self.assertEqual(school["Gemeindenu"], "1100.00000000") | ||
| self.assertEqual(school["PLZ"], "66123") | ||
| self.assertEqual(school["Ort"], "Saarbrücken") | ||
| self.assertEqual(school["Straße"], "Kohlweg 7") | ||
| self.assertEqual(school["Bezeichnun"], "Deutsch-Französiche Hochschule, Université franco-allemande") | ||
| self.assertEqual(school["Telefon"], "0681-93812100") | ||
| self.assertEqual(school["Fax"], "0681-93812111") | ||
| self.assertEqual(school["Email"], "[email protected]") | ||
| self.assertEqual(school["Schulform"], "Hochschule") | ||
| self.assertEqual(school["Homepage"], "https://www.dfh-ufa.org/") | ||
| self.assertEqual(school["Schulregio"], "Saarbrücken") | ||
| self.assertEqual(school["KARTENERST"], "Hochschule") | ||
| self.assertEqual(school["Rechtswert"], "355942.97630000") | ||
| self.assertEqual(school["Hochwert"], "5456095.93600000") | ||
| self.assertEqual(school["Aktualisie"], "20.05.2025") | ||
| self.assertAlmostEqual(school["lat"], 49.24067452) | ||
| self.assertAlmostEqual(school["lon"], 7.02085050) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the configuration of their WFS server is now wrong and returns the PLZ as a float where actually it should be a string (not even an integer since PLZs are always 5 digits in Germany and might start with zero). Can you parse to an integer here and pad with zeros (padding is strictly not necessary since the 0-leading zips are all in Sachsen afaik), please? 🙏