Skip to content

Commit

Permalink
added all model name tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JJFlorian committed Mar 14, 2024
1 parent 317ddea commit 88ef18e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ImportTask(models.Model):
log = models.TextField(blank=True)

def __str__(self):
return f"{self.bro_domain} import - {self.data_owner} ({self.created})"
return f"{self.bro_domain} import - {self.data_owner}"


class UploadTask(models.Model):
Expand All @@ -79,4 +79,4 @@ class UploadTask(models.Model):
log = models.TextField(blank=True)

def __str__(self) -> str:
return f"{self.request_type} {self.registration_type} {self.created}"
return f"{self.data_owner}: {self.registration_type} ({self.request_type})"
File renamed without changes.
74 changes: 72 additions & 2 deletions api/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,76 @@
import pytest

from api import models as api_models
from gmn import models as gmn_models
from gmw import models as gmw_models


@pytest.fixture
def organisation():
return api_models.Organisation(name="Nieuwegein")


def test_organisation1():
organisation = api_models.Organisation(name="Nieuwegein")
def test_organisation_name(organisation):
assert str(organisation) == "Nieuwegein"


def test_import_task_name(organisation):
import_task = api_models.ImportTask(
bro_domain="GMN",
kvk_number="123456789",
data_owner=organisation,
)

assert str(import_task) == "GMN import - Nieuwegein"


def test_upload_task_name(organisation):
upload_task = api_models.UploadTask(
bro_domain="GMN",
data_owner=organisation,
project_number="1",
registration_type="GMN_StartRegistration",
request_type="registration",
)

assert str(upload_task) == "Nieuwegein: GMN_StartRegistration (registration)"


@pytest.fixture
def gmn(organisation):
return gmn_models.GMN(
data_owner=organisation,
bro_id="GMN123456789",
)


def test_gmn_name(gmn):
assert str(gmn) == "GMN123456789"


def test_measuringpoint_name(organisation, gmn):
measuringpoint = gmn_models.Measuringpoint(
data_owner=organisation, gmn=gmn, measuringpoint_code="MP1234"
)

assert str(measuringpoint) == "MP1234"


@pytest.fixture
def gmw(organisation):
return gmw_models.GMW(
data_owner=organisation,
bro_id="GMW123456789",
)


def test_gmw_name(gmw):
assert str(gmw) == "GMW123456789"


def test_monitoringtube_name(organisation, gmw):
monitoring_tube = gmw_models.MonitoringTube(
data_owner=organisation, gmw=gmw, tube_number="1"
)

assert str(monitoring_tube) == "GMW123456789-1"

0 comments on commit 88ef18e

Please sign in to comment.