# Path: tests/conftest.py
# CAPAKEY_URL = 'https://geoservices.informatievlaanderen.be/capakey/api/v2'
# 
# Path: crabpy/gateway/capakey.py
# def capakey_rest_gateway_request(url, headers={}, params={}):
#     def __init__(self, **kwargs):
#     def _parse_centroid(center):
#     def _parse_bounding_box(bounding_box):
#     def list_gemeenten(self, sort=1):
#         def creator():
#     def get_gemeente_by_id(self, id):
#         def creator():
#     def list_kadastrale_afdelingen(self):
#         def creator():
#     def list_kadastrale_afdelingen_by_gemeente(self, gemeente, sort=1):
#         def creator():
#     def get_kadastrale_afdeling_by_id(self, aid):
#         def creator():
#     def list_secties_by_afdeling(self, afdeling):
#         def creator():
#     def get_sectie_by_id_and_afdeling(self, id, afdeling):
#         def creator():
#     def parse_percid(self, capakey):
#     def parse_capakey(self, percid):
#     def list_percelen_by_sectie(self, sectie):
#         def creator():
#     def get_perceel_by_id_and_sectie(self, id, sectie):
#         def creator():
#     def _get_perceel_by(self, url, cache_key):
#         def creator():
#     def get_perceel_by_capakey(self, capakey):
#     def get_perceel_by_coordinates(self, x, y):
#     def get_perceel_by_percid(self, percid):
#     def __init__(self, **kwargs):
#     def set_gateway(self, gateway):
#     def clear_gateway(self):
#     def check_gateway(self):
#     def __str__(self):
# def check_lazy_load_gemeente(f):
#     def wrapper(self):
#     def __init__(
#         self, id, naam=None,
#         centroid=None, bounding_box=None,
#         shape=None, **kwargs
#     ):
#     def naam(self):
#     def centroid(self):
#     def bounding_box(self):
#     def afdelingen(self):
#     def __unicode__(self):
#     def __repr__(self):
# def check_lazy_load_afdeling(f):
#     def wrapper(self):
#     def __init__(
#         self, id, naam=None, gemeente=None,
#         centroid=None, bounding_box=None,
#         shape=None, **kwargs
#     ):
#     def set_gateway(self, gateway):
#     def clear_gateway(self):
#     def naam(self):
#     def gemeente(self):
#     def centroid(self):
#     def bounding_box(self):
#     def secties(self):
#     def __unicode__(self):
#     def __repr__(self):
# def check_lazy_load_sectie(f):
#     def wrapper(self):
#     def __init__(
#         self, id, afdeling,
#         centroid=None, bounding_box=None,
#         shape=None, **kwargs
#     ):
#     def set_gateway(self, gateway):
#     def clear_gateway(self):
#     def centroid(self):
#     def bounding_box(self):
#     def percelen(self):
#     def __unicode__(self):
#     def __repr__(self):
# def check_lazy_load_perceel(f):
#     def wrapper(self):
#     def __init__(
#         self, id, sectie, capakey, percid, adres=None,
#         capatype=None, cashkey=None,
#         centroid=None, bounding_box=None,
#         shape=None, **kwargs
#     ):
#     def set_gateway(self, gateway):
#     def clear_gateway(self):
#     def get_percid_from_capakey(capakey):
#     def get_capakey_from_percid(percid):
#     def _split_capakey(self):
#     def centroid(self):
#     def bounding_box(self):
#     def capatype(self):
#     def cashkey(self):
#     def __unicode__(self):
#     def __repr__(self):
# class CapakeyRestGateway:
# class GatewayObject:
# class Gemeente(GatewayObject):
# class Afdeling(GatewayObject):
# class Sectie(GatewayObject):
# class Perceel(GatewayObject):


import re
    import unittest2 as unittest
    import unittest  # noqa
import pytest
import requests
from tests.conftest import CAPAKEY_URL
from crabpy.gateway.capakey import (
    Gemeente,
    Afdeling,
    Sectie,
    Perceel,
    capakey_rest_gateway_request,
    GatewayRuntimeException
)
    from unittest.mock import MagicMock, patch
    from unittest.mock import MagicMock, patch
        from crabpy.gateway.exception import GatewayResourceNotFoundException
        assert p.bisnummer == '02'
        assert p.exponent == 'C'
        assert p.macht == '000'

    def test_parse_capakey_other_sectie(self):
        p = Perceel(
            '1154/02C000', Sectie('F', Afdeling(46013)),
            '46013F1154/02C000', '46013_F_1154_C_000_02'
        )
        assert p.grondnummer == '1154'
        assert p.bisnummer == '02'
        assert p.exponent == 'C'
        assert p.macht == '000'

    def test_parse_invalid_capakey(self):
        with pytest.raises(ValueError):
            Perceel(
                '1154/02C000', Sectie('A', Afdeling(46013)),
                '46013_A_1154_C_000_02',
                '46013A1154/02C000',
            )

    def test_from_capakey_to_percid_and_back(self):
        assert Perceel.get_percid_from_capakey('46013A1154/02C000') == '46013_A_1154_C_000_02'
        assert Perceel.get_capakey_from_percid('46013_A_1154_C_000_02') == '46013A1154/02C000'

    def test_invalid_capakey_or_percid(self):
        with pytest.raises(ValueError):
            Perceel.get_capakey_from_percid('46013A1154/02C000')
        with pytest.raises(ValueError):

# Path: tests/conftest.py
# CAPAKEY_URL = 'https://geoservices.informatievlaanderen.be/capakey/api/v2'
# 
# Path: crabpy/gateway/capakey.py
# def capakey_rest_gateway_request(url, headers={}, params={}):
#     def __init__(self, **kwargs):
#     def _parse_centroid(center):
#     def _parse_bounding_box(bounding_box):
#     def list_gemeenten(self, sort=1):
#         def creator():
#     def get_gemeente_by_id(self, id):
#         def creator():
#     def list_kadastrale_afdelingen(self):
#         def creator():
#     def list_kadastrale_afdelingen_by_gemeente(self, gemeente, sort=1):
#         def creator():
#     def get_kadastrale_afdeling_by_id(self, aid):
#         def creator():
#     def list_secties_by_afdeling(self, afdeling):
#         def creator():
#     def get_sectie_by_id_and_afdeling(self, id, afdeling):
#         def creator():
#     def parse_percid(self, capakey):
#     def parse_capakey(self, percid):
#     def list_percelen_by_sectie(self, sectie):
#         def creator():
#     def get_perceel_by_id_and_sectie(self, id, sectie):
#         def creator():
#     def _get_perceel_by(self, url, cache_key):
#         def creator():
#     def get_perceel_by_capakey(self, capakey):
#     def get_perceel_by_coordinates(self, x, y):
#     def get_perceel_by_percid(self, percid):
#     def __init__(self, **kwargs):
#     def set_gateway(self, gateway):
#     def clear_gateway(self):
#     def check_gateway(self):
#     def __str__(self):
# def check_lazy_load_gemeente(f):
#     def wrapper(self):
#     def __init__(
#         self, id, naam=None,
#         centroid=None, bounding_box=None,
#         shape=None, **kwargs
#     ):
#     def naam(self):
#     def centroid(self):
#     def bounding_box(self):
#     def afdelingen(self):
#     def __unicode__(self):
#     def __repr__(self):
# def check_lazy_load_afdeling(f):
#     def wrapper(self):
#     def __init__(
#         self, id, naam=None, gemeente=None,
#         centroid=None, bounding_box=None,
#         shape=None, **kwargs
#     ):
#     def set_gateway(self, gateway):
#     def clear_gateway(self):
#     def naam(self):
#     def gemeente(self):
#     def centroid(self):
#     def bounding_box(self):
#     def secties(self):
#     def __unicode__(self):
#     def __repr__(self):
# def check_lazy_load_sectie(f):
#     def wrapper(self):
#     def __init__(
#         self, id, afdeling,
#         centroid=None, bounding_box=None,
#         shape=None, **kwargs
#     ):
#     def set_gateway(self, gateway):
#     def clear_gateway(self):
#     def centroid(self):
#     def bounding_box(self):
#     def percelen(self):
#     def __unicode__(self):
#     def __repr__(self):
# def check_lazy_load_perceel(f):
#     def wrapper(self):
#     def __init__(
#         self, id, sectie, capakey, percid, adres=None,
#         capatype=None, cashkey=None,
#         centroid=None, bounding_box=None,
#         shape=None, **kwargs
#     ):
#     def set_gateway(self, gateway):
#     def clear_gateway(self):
#     def get_percid_from_capakey(capakey):
#     def get_capakey_from_percid(percid):
#     def _split_capakey(self):
#     def centroid(self):
#     def bounding_box(self):
#     def capatype(self):
#     def cashkey(self):
#     def __unicode__(self):
#     def __repr__(self):
# class CapakeyRestGateway:
# class GatewayObject:
# class Gemeente(GatewayObject):
# class Afdeling(GatewayObject):
# class Sectie(GatewayObject):
# class Perceel(GatewayObject):


# Path: tests/gateway/test_capakey.py
import re
    import unittest2 as unittest
    import unittest  # noqa
import pytest
import requests
from tests.conftest import CAPAKEY_URL
from crabpy.gateway.capakey import (
    Gemeente,
    Afdeling,
    Sectie,
    Perceel,
    capakey_rest_gateway_request,
    GatewayRuntimeException
)
    from unittest.mock import MagicMock, patch
    from unittest.mock import MagicMock, patch
        from crabpy.gateway.exception import GatewayResourceNotFoundException

        assert p.bisnummer == '02'
        assert p.exponent == 'C'
        assert p.macht == '000'

    def test_parse_capakey_other_sectie(self):
        p = Perceel(
            '1154/02C000', Sectie('F', Afdeling(46013)),
            '46013F1154/02C000', '46013_F_1154_C_000_02'
        )
        assert p.grondnummer == '1154'
        assert p.bisnummer == '02'
        assert p.exponent == 'C'
        assert p.macht == '000'

    def test_parse_invalid_capakey(self):
        with pytest.raises(ValueError):
            Perceel(
                '1154/02C000', Sectie('A', Afdeling(46013)),
                '46013_A_1154_C_000_02',
                '46013A1154/02C000',
            )

    def test_from_capakey_to_percid_and_back(self):
        assert Perceel.get_percid_from_capakey('46013A1154/02C000') == '46013_A_1154_C_000_02'
        assert Perceel.get_capakey_from_percid('46013_A_1154_C_000_02') == '46013A1154/02C000'

    def test_invalid_capakey_or_percid(self):
        with pytest.raises(ValueError):
            Perceel.get_capakey_from_percid('46013A1154/02C000')
        with pytest.raises(ValueError):

            Perceel.get_percid_from_capakey('46013_A_1154_C_000_02')