Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
JJFlorian committed Apr 9, 2024
1 parent 8787650 commit 2ff8749
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def save(self, *args, **kwargs):
# Accessing the authenticated user's username and token
username = self.data_owner.bro_user_token
password = self.data_owner.bro_user_password

# Start the celery task
tasks.upload_bro_data_task.delay(self.uuid, username, password)

Expand Down
27 changes: 18 additions & 9 deletions api/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,40 @@
from gmn import models as gmn_models
from gmw import models as gmw_models


@pytest.fixture
def organisation():
organisation = api_models.Organisation.objects.create(
name="Nieuwegein",
kvk_number = "12345678",
bro_user_token = "secret",
bro_user_password = "secret",
kvk_number="12345678",
bro_user_token="secret",
bro_user_password="secret",
)
organisation.save()
return organisation


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


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


@pytest.mark.django_db
def test_organisation_name(organisation):
assert str(organisation) == "Nieuwegein"


@pytest.mark.django_db
def test_import_task_name(organisation):
import_task = api_models.ImportTask(
Expand All @@ -43,10 +48,11 @@ def test_import_task_name(organisation):

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


@pytest.mark.django_db
def test_import_task_save_method(organisation):
import_task = api_models.ImportTask.objects.create(
data_owner = organisation,
data_owner=organisation,
bro_domain="gmn",
kvk_number="12345678",
status="",
Expand All @@ -55,6 +61,7 @@ def test_import_task_save_method(organisation):
import_task.refresh_from_db()
assert api_models.ImportTask.objects.count() == 1


@pytest.mark.django_db
def test_upload_task_name(organisation):
upload_task = api_models.UploadTask(
Expand All @@ -67,27 +74,29 @@ def test_upload_task_name(organisation):

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


@pytest.mark.django_db
def test_upload_task_save_method(organisation):
upload_task = api_models.UploadTask.objects.create(
data_owner = organisation,
data_owner=organisation,
bro_domain="gmn",
project_number="1",
status="PENDING",
registration_type = "GMN_StartRegistration",
request_type = "registration",
registration_type="GMN_StartRegistration",
request_type="registration",
metadata={},
sourcedocument_data={},

)
upload_task.save()
upload_task.refresh_from_db()
assert api_models.UploadTask.objects.count() == 1


@pytest.mark.django_db
def test_gmn_name(gmn):
assert str(gmn) == "GMN123456789"


@pytest.mark.django_db
def test_measuringpoint_name(organisation, gmn):
measuringpoint = gmn_models.Measuringpoint(
Expand All @@ -97,11 +106,11 @@ def test_measuringpoint_name(organisation, gmn):
assert str(measuringpoint) == "MP1234"



@pytest.mark.django_db
def test_gmw_name(gmw):
assert str(gmw) == "GMW123456789"


@pytest.mark.django_db
def test_monitoringtube_name(organisation, gmw):
monitoring_tube = gmw_models.MonitoringTube(
Expand Down

0 comments on commit 2ff8749

Please sign in to comment.