from datetime import datetime
from uuid import UUID

import pytest

DATASETT_ID = UUID("32e32ab8-2761-4277-94da-1c8ce95d51bc")
S3_PATH = "32e32ab8-2761-4277-94da-1c8ce95d51bc/ip0"
S3_BUCKET = "mock-s3-bucket-name-0001"

DATETIME_NOW = datetime.now()
from app.database.dbo.mottak import BevaringDatasett as BevaringDatasett_DBO
from app.domain.models.BevaringDatasett import BevaringDatasett


@pytest.fixture
def testobj_bevaring_datasett_dbo() -> BevaringDatasett_DBO:
    return BevaringDatasett_DBO(
        id=13,
        arkivuttrekk_id=154,
        overforingspakke_id=212,
        datasett_id=DATASETT_ID,
        s3_path=S3_PATH,
        s3_bucket=S3_BUCKET,
        opprettet=DATETIME_NOW,
    )


def test_bevaring_datasett_domain_maps_from_dbo(testobj_bevaring_datasett_dbo):
    """
    GIVEN   a static bevaring_datasett_DBO object
    WHEN    calling BevaringDatasett constructor using unpack (**)
    THEN    control that the returned BevaringDatasett is correct
    """
    expected = BevaringDatasett(
        arkivuttrekk_id=154,
        overforingspakke_id=212,
        datasett_id=DATASETT_ID,
        s3_path=S3_PATH,
        s3_bucket=S3_BUCKET,
    )
    actual = BevaringDatasett(**vars(testobj_bevaring_datasett_dbo))

    assert actual == expected
