Skip to content

Commit

Permalink
Merge pull request #777 from krebslw/fix_test_punktinfo
Browse files Browse the repository at this point in the history
Fix fejl i test_punktinformation introduceret ved merge af #768
  • Loading branch information
kbevers authored Oct 1, 2024
2 parents c0986b1 + 76b484f commit ab0870f
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions test/test_punktinformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,25 @@


def test_indset_punktinformation(firedb, sag, punkt, punktinformationtype):
firedb.session.flush()

pi = PunktInformation(infotype=punktinformationtype, punkt=punkt)
firedb.indset_sagsevent(
Sagsevent(
sag=sag,
sagseventinfos=[SagseventInfo(beskrivelse="Testindsættelse af punktinfo")],
eventtype=EventType.PUNKTINFO_TILFOEJET,
punktinformationer=[pi],
)
),
commit=False,
)
firedb.session.flush()
firedb.session.rollback()


def test_opdatering_punktinformation(firedb, sag, punkt):
firedb.session.flush()

pit = firedb.hent_punktinformationtype("IDENT:landsnr")

pi1 = PunktInformation(infotype=pit, punkt=punkt, tekst="K-12-1231")
Expand All @@ -31,8 +38,11 @@ def test_opdatering_punktinformation(firedb, sag, punkt):
sagseventinfos=[SagseventInfo(beskrivelse="Testindsættelse af punktinfo")],
eventtype=EventType.PUNKTINFO_TILFOEJET,
punktinformationer=[pi1],
)
),
commit=False,
)
# Flush sagsevent og punktinformation til CI-databasen
firedb.session.flush()

pi2 = PunktInformation(infotype=pit, punkt=punkt, tekst="K-22-2231")
firedb.indset_sagsevent(
Expand All @@ -41,8 +51,11 @@ def test_opdatering_punktinformation(firedb, sag, punkt):
sagseventinfos=[SagseventInfo(beskrivelse="Testindsættelse af punktinfo")],
eventtype=EventType.PUNKTINFO_TILFOEJET,
punktinformationer=[pi2],
)
),
commit=False,
)
# Flush sagsevent og punktinformation til CI-databasen
firedb.session.flush()

infotyper = (
firedb.session.query(PunktInformation)
Expand All @@ -57,20 +70,26 @@ def test_opdatering_punktinformation(firedb, sag, punkt):
assert infotyper[0].registreringtil == infotyper[1].registreringfra
assert infotyper[0].sagseventtilid == infotyper[1].sagseventfraid

firedb.session.rollback()


def test_luk_punktinfo(
firedb: FireDb,
punktinformationtype: PunktInformationType,
punkt: Punkt,
sagsevent: Sagsevent,
):
firedb.session.flush()

punktinfo = PunktInformation(
infotype=punktinformationtype, punkt=punkt, sagsevent=sagsevent
)
firedb.session.add(punktinfo)
firedb.session.commit()
firedb.session.flush()
assert punktinfo.registreringtil is None

firedb.luk_punktinfo(punktinfo, sagsevent)
firedb.luk_punktinfo(punktinfo, sagsevent, commit=False)
firedb.session.flush()
assert punktinfo.registreringtil is not None
assert punktinfo.sagsevent.eventtype == EventType.PUNKTINFO_FJERNET
firedb.session.rollback()

0 comments on commit ab0870f

Please sign in to comment.