failmap/admin

View on GitHub
websecmap/api/tests/test_zorgkaart.py

Summary

Maintainability
C
7 hrs
Test Coverage
import logging

import websecmap
from websecmap.api.apis.zorgkaart import organization_and_url_import
from websecmap.organizations.models import Coordinate, Organization, OrganizationType, Url

log = logging.getLogger("websecmap")


def default_coordinate(argument):
    return [0, 0]


def test_add_flat_organizations(db, monkeypatch):

    # don't connect to google during a test
    monkeypatch.setattr(websecmap.api.apis.zorgkaart, "retrieve_geocode", default_coordinate)

    z = OrganizationType(**{"name": "Zorg"})
    z.save()

    example_data = [
        {
            "name": "StadHolland (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.4035898, 51.922178],
            "address": "'s-Gravelandseweg 555, 3119 XT Schiedam, Nederland",
            "surrogate_id": "StadHolland_Zorgverzekeraar_1296f1e3306a3d819effc4df25f4ac98",
            "urls": ["https://www.stadholland.nl"],
        },
        {
            "name": "VvAA (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.080751, 52.0700558],
            "address": "Orteliuslaan 750, 3528 BB Utrecht, Nederland",
            "surrogate_id": "VvAA_Zorgverzekeraar_13289b4b57f73e81b06c5ef6a5468c79",
            "urls": ["https://www.vvaa.nl"],
        },
        {
            "name": "Nationale-Nederlanden (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.056375, 51.5852528],
            "address": "Postbus 4016, 5004 JA Tilburg, Nederland",
            "surrogate_id": "Nationale-Nederlanden_Zorgverzekeraar_1651f4e08df73eb1b24673244dab2aeb",
            "urls": ["http://www.deltalloyd.nl"],
        },
        {
            "name": "Just (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.0654375, 51.5575842],
            "address": "Ringbaan West 236, 5038 KE Tilburg, Nederland",
            "surrogate_id": "Just_Zorgverzekeraar_1817faee1ec83ea1a2b6061fa7324a18",
            "urls": ["www.just.nl"],
        },
        {
            "name": "De Amersfoortse (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.3826107, 52.1564922],
            "address": "Stadsring 15, 3811 HM Amersfoort, Nederland",
            "surrogate_id": "De Amersfoortse_Zorgverzekeraar_2a8c1c5be302347d948d24d38f2c2738",
            "urls": ["https://www.amersfoortse.nl"],
        },
        {
            "name": "AZVZ (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.835225, 52.3910663],
            "address": "Radarweg 60, 1043 NT Amsterdam, Nederland",
            "surrogate_id": "AZVZ_Zorgverzekeraar_2aed95722cb13e6e90d8f81db4026b78",
            "urls": ["http://www.scheepvaartnet.nl"],
        },
        {
            "name": "HollandZorg (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [6.1552165, 52.2660751],
            "address": "Postbus 166, 7400 AD Deventer, Nederland",
            "surrogate_id": "HollandZorg_Zorgverzekeraar_2e05526130f833258e0c8d01f5346277",
            "urls": ["http://www.hollandzorg.nl"],
        },
        {
            "name": "Bewuzt (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.4745817, 51.4356044],
            "address": "Postbus 25150, 5600 RS Eindhoven, Nederland",
            "surrogate_id": "Bewuzt_Zorgverzekeraar_2e099890952b3b2eb5c5967f2e4ee3c5",
            "urls": ["http://www.bewuzt.nl"],
        },
        {
            "name": "ONVZ (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.1709957, 52.0313438],
            "address": "De Molen 66, 3995 AX Houten, Nederland",
            "surrogate_id": "ONVZ_Zorgverzekeraar_32e9686af61130f78637330692dd2fd5",
            "urls": ["https://www.onvz.nl"],
        },
        {
            "name": "Besured (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.6487567, 51.8070836],
            "address": "Laan der Verenigde Naties 9, 3316 AK Dordrecht, Nederland",
            "surrogate_id": "Besured_Zorgverzekeraar_38a4427739213b0a81d4b229392973c6",
            "urls": ["http://www.besured.nl"],
        },
        {
            "name": "FBTO (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.7900797, 53.1979409],
            "address": "Lange Marktstraat 26, 8911 AD Leeuwarden, Nederland",
            "surrogate_id": "FBTO_Zorgverzekeraar_43b2bb32f25b3b9aa5fbb3695959bc62",
            "urls": ["https://www.fbto.nl"],
        },
        {
            "name": "VGZ (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.8997819, 51.9844703],
            "address": "Nieuwe Stationsstraat 12, 6811 KS Arnhem, Nederland",
            "surrogate_id": "VGZ_Zorgverzekeraar_4c9802fac3e73040964c94536e41fa77",
            "urls": ["https://www.vgz.nl"],
        },
        {
            "name": "ZorgDirect (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [6.1880151, 52.2399084],
            "address": "Munsterstraat 7, 7418 EV Deventer, Nederland",
            "surrogate_id": "ZorgDirect_Zorgverzekeraar_500b1addf2363a808cbbe92d4ce1ea2a",
            "urls": ["http://www.zorgdirect.nl"],
        },
        {
            "name": "Hema (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [6.8936619, 52.2215372],
            "address": "Postbus 704, 7500 AS Enschede, Nederland",
            "surrogate_id": "Hema_Zorgverzekeraar_57fa6672b1c13a3580d09d8db2b365a8",
            "urls": ["https://www.hemaverzekeringen.nl/zorgverzekering"],
        },
        {
            "name": "IZZ zorgverzekering (VGZ voor de zorg) (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.4697225, 51.441642],
            "address": "Postbus 25150, 5600 RS Eindhoven, Nederland",
            "surrogate_id": "IZZ zorgverzekering (VGZ voor de zorg)_Zorgverzekeraar_5e30d585e2c43879ad5108f4e7d262b7",
            "urls": ["https://www.izz.nl"],
        },
        {
            "name": "UMC (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.4697225, 51.441642],
            "address": "Postbus 25030, 5600 RS Eindhoven, Nederland",
            "surrogate_id": "UMC_Zorgverzekeraar_6a839a9090593f88a77760b63e1775f9",
            "urls": ["https://www.umczorgverzekering.nl"],
        },
        {
            "name": "Menzis (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [0, 0],
            "address": "Postbus 75000, 7500 KC Enschede, Nederland",
            "surrogate_id": "Menzis_Zorgverzekeraar_6c58a8b95bfe39f285608c22dc35291e",
            "urls": ["https://www.menzis.nl"],
        },
        {
            "name": "Univé Verzekeringen (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.8997819, 51.9844703],
            "address": "Nieuwe Stationsstraat 12, 6811 KS Arnhem, Nederland",
            "surrogate_id": "Univé Verzekeringen_Zorgverzekeraar_6ff61f21b2b63b3ba95467b721383b84",
            "urls": ["https://www.unive.nl"],
        },
        {
            "name": "Aevitae (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.9618443, 50.8827224],
            "address": "Nieuw-Eyckholt 284, 6419 DJ Heerlen, Nederland",
            "surrogate_id": "Aevitae_Zorgverzekeraar_70443129833930a990dd765d7a03eae7",
            "urls": ["https://www.aevitae.com"],
        },
        {
            "name": "ZEKUR (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.4697225, 51.441642],
            "address": "Postbus 25030, 5600 RS Eindhoven, Nederland",
            "surrogate_id": "ZEKUR_Zorgverzekeraar_728ee3c0559a3566b153eed1c799a15e",
            "urls": ["http://www.zekur.nl"],
        },
        {
            "name": "Promovendum (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [0, 0],
            "address": "Postbus 362, 3300 AJ Dordrecht, Nederland",
            "surrogate_id": "Promovendum_Zorgverzekeraar_78de3b6c6211389daaf9b26ad37a5ad7",
            "urls": ["http://www.promovendum.nl"],
        },
        {
            "name": "Salland Zorgverzekeringen (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [6.1880552, 52.2399299],
            "address": "Munsterstraat 7, 7418 EV Deventer, Nederland",
            "surrogate_id": "Salland Zorgverzekeringen_Zorgverzekeraar_7dd6c7f3891c3594b0358d2538f96a7e",
            "urls": ["https://www.salland.nl"],
        },
        {
            "name": "CZ (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.0654505, 51.5574715],
            "address": "Ringbaan West 236, 5038 KE Tilburg, Nederland",
            "surrogate_id": "CZ_Zorgverzekeraar_889565e785953fd9a6eed2f19844a954",
            "urls": ["https://www.cz.nl"],
        },
        {
            "name": "Ziezo (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.4970097, 52.1601144],
            "address": "Postbus 444, 2300 AK Leiden, Nederland",
            "surrogate_id": "Ziezo_Zorgverzekeraar_97b477f6a914335b8ed4936df24b822d",
            "urls": ["https://www.zilverenkruis.nl/Consumenten/zorgverzekering/ziezo/Paginas/default.aspx"],
        },
        {
            "name": "Vanbreda Risk & Benefits (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.6807141, 52.0273893],
            "address": "Kampenringweg 45 D, 2803 PE Gouda, Nederland",
            "surrogate_id": "Vanbreda Risk & Benefits_Zorgverzekeraar_a41d07fc968e31b5aba127d15e1effc9",
            "urls": ["https://www.vanbredanl.com/"],
        },
        {
            "name": "CZdirect (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.0646836, 51.5578414],
            "address": "Ringbaan-West 236, 5038 KE Tilburg, Nederland",
            "surrogate_id": "CZdirect_Zorgverzekeraar_a62d7bb7c47131b9a32a103171f2dcdb",
            "urls": ["http://www.czdirect.nl"],
        },
        {
            "name": "Avéro Achmea (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.3806275, 52.1547118],
            "address": "Van Asch van Wijckstraat 55, 3811 LP Amersfoort, Nederland",
            "surrogate_id": "Avéro Achmea_Zorgverzekeraar_ad0cd6c325603778a0e06e021f2bbbe8",
            "urls": ["https://www.averoachmea.nl"],
        },
        {
            "name": "PlusGezond (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.9618443, 50.8827224],
            "address": "Nieuw-Eyckholt 284, 6419 DJ Heerlen, Nederland",
            "surrogate_id": "PlusGezond_Zorgverzekeraar_b28918211d383d20b67831c865a6bb96",
            "urls": ["https://www.plusgezond.nl/"],
        },
        {
            "name": "PNOzorg (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.1709957, 52.0313438],
            "address": "De Molen 66, 3995 AX Houten, Nederland",
            "surrogate_id": "PNOzorg_Zorgverzekeraar_b90c1dd7a72933b7943ccc58a752a498",
            "urls": ["http://www.pnozorg.nl"],
        },
        {
            "name": "Pro Life (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.3961917, 52.1894953],
            "address": "Postbus 709, 3800 AS Amersfoort, Nederland",
            "surrogate_id": "Pro Life_Zorgverzekeraar_bb56c53b30383d2f95da5fae44f35a18",
            "urls": ["http://www.prolife.nl"],
        },
        {
            "name": "Aon (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.4481193, 51.4458311],
            "address": "Beukenlaan 70, 5651 CD Eindhoven, Nederland",
            "surrogate_id": "Aon_Zorgverzekeraar_bc64ec25bbc93726b8796461bafbaff2",
            "urls": ["http://www.iak.nl"],
        },
        {
            "name": "FLKS (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.9618443, 50.8827224],
            "address": "Nieuw-Eyckholt 284, 6419 DJ Heerlen, Nederland",
            "surrogate_id": "FLKS_Zorgverzekeraar_bf0bfeae070c3e6a809cb7f6e0ff3f5b",
            "urls": ["https://www.flks.nl/"],
        },
        {
            "name": "UnitedConsumers Zorgverzekering (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.3910857, 51.4561211],
            "address": "Luchthavenweg 20, 5657 EB Eindhoven, Nederland",
            "surrogate_id": "UnitedConsumers Zorgverzekering_Zorgverzekeraar_bf30227e83a53c789959ca0868f4697c",
            "urls": ["https://www.unitedconsumers.com/zorgverzekering/"],
        },
        {
            "name": "Interpolis (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.0942351, 51.5593304],
            "address": "Spoorlaan 298, 5017 JZ Tilburg, Nederland",
            "surrogate_id": "Interpolis_Zorgverzekeraar_c4cda8d8e2fa33a380a616bc8687d49c",
            "urls": ["http://www.interpolis.nl"],
        },
        {
            "name": "De Friesland (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.7792228, 53.1979714],
            "address": "Harlingertrekweg 53, 8913 HR Leeuwarden, Nederland",
            "surrogate_id": "De Friesland_Zorgverzekeraar_c4fd578512da3a6ca5a829597c695aad",
            "urls": ["https://www.defriesland.nl"],
        },
        {
            "name": "OHRA (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.876376, 51.9523898],
            "address": "Rijksweg-West 2, 6842 BD Arnhem, Nederland",
            "surrogate_id": "OHRA_Zorgverzekeraar_cacbd531ad56338eacb963c4281525a3",
            "urls": ["https://www.ohra.nl/zorgverzekering"],
        },
        {
            "name": "Ditzo (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.1545789, 52.0930915],
            "address": "Archimedeslaan 10, 3584 BA Utrecht, Nederland",
            "surrogate_id": "Ditzo_Zorgverzekeraar_ce46d3da0d4635dab97867042fcec36e",
            "urls": ["http://www.ditzo.nl"],
        },
        {
            "name": "Zorg en Zekerheid (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.4546232, 52.1647595],
            "address": "Haagse Schouwweg 12, 2332 KG Leiden, Nederland",
            "surrogate_id": "Zorg en Zekerheid_Zorgverzekeraar_cf9d374aa64b3c2799e1898baf9d57a3",
            "urls": ["https://www.zorgenzekerheid.nl"],
        },
        {
            "name": "IZA (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.4697225, 51.441642],
            "address": "Postbus 25030, 5600 RS Eindhoven, Nederland",
            "surrogate_id": "IZA_Zorgverzekeraar_e2a08d6dfc6c38639e298a2034b9ab13",
            "urls": ["https://www.iza.nl"],
        },
        {
            "name": "National Academic (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.6487846, 51.8072548],
            "address": "Laan der Verenigde Naties 9, 3316 AK Dordrecht, Nederland",
            "surrogate_id": "National Academic_Zorgverzekeraar_e8acbe07a44d3b4da0f802a116549a96",
            "urls": ["http://www.nationalacademic.nl"],
        },
        {
            "name": "IZZ Zorgverzekering (CZ voor de zorg) (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [5.0654375, 51.5575842],
            "address": "Ringbaan West 236, 5038 KE Tilburg, Nederland",
            "surrogate_id": "IZZ Zorgverzekering (CZ voor de zorg)_Zorgverzekeraar_eb0f220bc6353dc3a6e7e1a50b6bbab4",
            "urls": ["https://www.izz.nl/"],
        },
        {
            "name": "Anderzorg (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [6.5880498, 53.2091626],
            "address": "Winschoterdiep 70, 9723 AB Groningen, Nederland",
            "surrogate_id": "Anderzorg_Zorgverzekeraar_ecbfcbb860fe39128d0489c3803427cf",
            "urls": ["https://www.anderzorg.nl"],
        },
        {
            "name": "InTwente (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [6.8936619, 52.2215372],
            "address": "Postbus 1070, 7500 BB Enschede, Nederland",
            "surrogate_id": "InTwente_Zorgverzekeraar_f87b92bc53c634039c437301432c234b",
            "urls": ["http://www.intwente.nl"],
        },
        {
            "name": "DSW (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.4035898, 51.922178],
            "address": "'s-Gravelandseweg 555, 3119 XT Schiedam, Nederland",
            "surrogate_id": "DSW_Zorgverzekeraar_f9880632361c30ffbed5901ce14961d8",
            "urls": ["https://www.dsw.nl"],
        },
        {
            "name": "PMA Zorgverzekering (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.6158773, 51.9747541],
            "address": "Postbus 313, 2910 AH Nieuwerkerk aan den IJssel, Nederland",
            "surrogate_id": "PMA Zorgverzekering_Zorgverzekeraar_fc93b684d3df325e808d5fa649d2640b",
            "urls": ["https://www.pmazorgverzekering.nl"],
        },
        {
            "name": "Zilveren Kruis (Zorgverzekeraar)",
            "layer": "Zorg",
            "country": "NL",
            "coordinate_type": "Point",
            "coordinate_area": [4.4857178, 52.1683468],
            "address": "Dellaertweg 1, 2316 WZ Leiden, Nederland",
            "surrogate_id": "Zilveren Kruis_Zorgverzekeraar_fe513d225f493f28a4902eb47f56e6e0",
            "urls": ["http://www.zilverenkruis.nl"],
        },
    ]

    organization_and_url_import(example_data)

    assert Organization.objects.all().count() == 46
    assert Url.objects.all().count() == 88
    assert Coordinate.objects.all().count() == 44

    # add this dataset again, and nothing new should be added
    organization_and_url_import(example_data)
    assert Organization.objects.all().count() == 46
    assert Url.objects.all().count() == 88
    assert Coordinate.objects.all().count() == 44