Skip to content
Snippets Groups Projects
Commit 7456aac3 authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-214: Fixing formatting and updating test

parent 8d12f61e
No related branches found
No related tags found
1 merge request!284GREG-214: Switching to showing orgreg ID in dropdown for units
Pipeline #116280 passed
......@@ -487,8 +487,8 @@ class OrganizationalUnit(BaseModel):
"""Gets the Norwegian bokmaal acronym if it exists"""
return (
self.identifiers.filter(name="acronym_nob")
.values_list("value", flat=True)
.first()
.values_list("value", flat=True)
.first()
)
def __repr__(self) -> str:
......
......@@ -33,3 +33,33 @@ def test_orgreg_field_empty_if_identifier_not_present(
assert len(data) == 1
assert data[0]["orgreg_id"] is None
@pytest.mark.django_db
def test_acronym_nob_populated_if_identifier_present(
unit_foo, client, log_in, user_sponsor, sponsor_foo
):
acronym_nob = "test-unit-01"
OuIdentifier.objects.create(
source="orgreg", name="acronym_nob", value=acronym_nob, orgunit=unit_foo
)
log_in(user_sponsor)
resp = client.get(reverse("gregui-v1:ou-list"))
data = resp.json()
assert len(data) == 1
assert data[0]["acronym_nob"] == acronym_nob
@pytest.mark.django_db
def test_acronym_nob_field_empty_if_identifier_not_present(
unit_foo, client, log_in, user_sponsor, sponsor_foo
):
log_in(user_sponsor)
resp = client.get(reverse("gregui-v1:ou-list"))
data = resp.json()
assert len(data) == 1
assert data[0]["acronym_nob"] is None
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment