-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
248 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,20 @@ | ||
{ | ||
"organisasjonsnummer": "987123456", | ||
"navn": "SLETTET UNDERENHET AS", | ||
"organisasjonsform": { | ||
"kode": "AAFY", | ||
"beskrivelse": "Virksomhet til ikke-næringsdrivende person", | ||
"_links": { | ||
"self": { | ||
"href": "http://localhost/enhetsregisteret/api/organisasjonsformer/AAFY" | ||
} | ||
} | ||
}, | ||
"slettedato": "2017-10-20", | ||
"nedleggelsesdato": "2017-10-05", | ||
"_links": { | ||
"self": { | ||
"href": "http://localhost/enhetsregisteret/api/underenheter/987123456" | ||
} | ||
} | ||
} |
This file contains 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,49 @@ | ||
{ | ||
"organisasjonsnummer": "776655441", | ||
"navn": "SESAM STASJON", | ||
"organisasjonsform": { | ||
"kode": "BEDR", | ||
"beskrivelse": "Bedrift", | ||
"_links": { | ||
"self": { | ||
"href": "http://localhost/enhetsregisteret/api/organisasjonsformer/BEDR" | ||
} | ||
} | ||
}, | ||
"postadresse": { | ||
"land": "Norge", | ||
"landkode": "NO", | ||
"postnummer": "0122", | ||
"poststed": "OSLO", | ||
"adresse": ["c/o reder K. Rusing", "Postboks 1752 Vika", ""], | ||
"kommune": "OSLO", | ||
"kommunenummer": "0301" | ||
}, | ||
"registreringsdatoEnhetsregisteret": "2017-10-20", | ||
"registrertIMvaregisteret": true, | ||
"naeringskode1": { | ||
"kode": "52.292", | ||
"beskrivelse": "Skipsmegling" | ||
}, | ||
"antallAnsatte": 50, | ||
"harRegistrertAntallAnsatte": true, | ||
"overordnetEnhet": "112233445", | ||
"beliggenhetsadresse": { | ||
"land": "Norge", | ||
"landkode": "NO", | ||
"postnummer": "0122", | ||
"poststed": "OSLO", | ||
"adresse": ["Tyvholmen 1", null, null], | ||
"kommune": "OSLO", | ||
"kommunenummer": "0301" | ||
}, | ||
"nedleggelsesdato": "2018-10-20", | ||
"_links": { | ||
"self": { | ||
"href": "http://localhost/enhetsregisteret/api/underenheter/776655441" | ||
}, | ||
"overordnetEnhet": { | ||
"href": "http://localhost/enhetsregisteret/api/enheter/112233445" | ||
} | ||
} | ||
} |
This file contains 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,67 @@ | ||
from datetime import date | ||
from pathlib import Path | ||
|
||
from pytest_httpx import HTTPXMock | ||
|
||
from brreg import enhetsregisteret | ||
|
||
DATA_DIR = Path(__file__).parent.parent / "data" | ||
|
||
|
||
def test_get_underenhet(httpx_mock: HTTPXMock) -> None: | ||
httpx_mock.add_response( # pyright: ignore[reportUnknownMemberType] | ||
method="GET", | ||
url="https://data.brreg.no/enhetsregisteret/api/underenheter/776655441", | ||
status_code=200, | ||
headers={"content-type": "application/json"}, | ||
content=(DATA_DIR / "underenheter-details-response.json").read_bytes(), | ||
) | ||
|
||
org = enhetsregisteret.Client().get_underenhet("776655441") | ||
|
||
assert org is not None | ||
assert org.organisasjonsnummer == "776655441" | ||
assert org.navn == "SESAM STASJON" | ||
assert org.hjemmeside is None | ||
assert org.registreringsdato_enhetsregisteret == date(2017, 10, 20) | ||
assert org.registrert_i_mvaregisteret is True | ||
assert org.naeringskode1 == enhetsregisteret.Naeringskode( | ||
kode="52.292", beskrivelse="Skipsmegling" | ||
) | ||
assert org.antall_ansatte == 50 | ||
assert org.har_registrert_antall_ansatte is True | ||
assert org.beliggenhetsadresse == enhetsregisteret.Adresse( | ||
land="Norge", | ||
landkode="NO", | ||
postnummer="0122", | ||
poststed="OSLO", | ||
adresse=["Tyvholmen 1", None, None], | ||
kommune="OSLO", | ||
kommunenummer="0301", | ||
) | ||
assert org.oppstartsdato is None | ||
assert org.dato_eierskifte is None | ||
assert org.nedleggelsesdato == date(2018, 10, 20) | ||
assert org.slettedato is None | ||
|
||
|
||
def test_get_underenhet_when_deleted(httpx_mock: HTTPXMock) -> None: | ||
httpx_mock.add_response( # pyright: ignore[reportUnknownMemberType] | ||
method="GET", | ||
url="https://data.brreg.no/enhetsregisteret/api/underenheter/987123456", | ||
status_code=200, | ||
headers={"content-type": "application/json"}, | ||
content=(DATA_DIR / "underenheter-details-deleted-response.json").read_bytes(), | ||
) | ||
|
||
org = enhetsregisteret.Client().get_underenhet("987123456") | ||
|
||
assert org is not None | ||
assert org.organisasjonsnummer == "987123456" | ||
assert org.navn == "SLETTET UNDERENHET AS" | ||
assert org.organisasjonsform == enhetsregisteret.Organisasjonsform( | ||
kode="AAFY", | ||
beskrivelse="Virksomhet til ikke-næringsdrivende person", | ||
utgaatt=None, | ||
) | ||
assert org.slettedato == date(2017, 10, 20) |