Skip to content

Commit

Permalink
[#13] resolve flake8 errors/warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SonnyBA committed Sep 18, 2024
1 parent 4772177 commit 9b25488
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/objects/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def create(self, validated_data):
@transaction.atomic
def update(self, instance, validated_data):
# object_data is not used since all object attributes are immutable
object_data = validated_data.pop("object", None)
validated_data.pop("object", None)
validated_data["object"] = instance.object
# version should be set
if "version" not in validated_data:
Expand Down
2 changes: 1 addition & 1 deletion src/objects/config/objecttypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ def test_configuration(self) -> None:
try:
response.json()
except requests.exceptions.JSONDecodeError:
raise SelfTestFailed(f"Object type version didn't have any data")
raise SelfTestFailed("Object type version didn't have any data")
2 changes: 1 addition & 1 deletion src/objects/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def clean(self):
try:
object_type_data = response.json()
except requests.exceptions.JSONDecodeError:
ValidationError(f"Object type version didn't have any data")
ValidationError("Object type version didn't have any data")

if not self._name:
self._name = object_type_data["name"]
Expand Down
2 changes: 1 addition & 1 deletion src/objects/tests/commands/test_setup_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_setup_configuration(self, m):
f"{ObjecttypesStep()} is successfully configured",
f"Configuring {DemoUserStep()}...",
f"{DemoUserStep()} is successfully configured",
f"Instance configuration completed.",
"Instance configuration completed.",
]

self.assertEqual(command_output, expected_output)
Expand Down
2 changes: 0 additions & 2 deletions src/objects/tests/config/test_objecttypes_configuration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from unittest.mock import patch

from django.test import TestCase, override_settings

import requests
Expand Down
18 changes: 9 additions & 9 deletions src/objects/tests/v1/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def test_filter_exclude_old_records(self):
start_at=date.today() - timedelta(days=10),
end_at=date.today() - timedelta(days=1),
)
record_new = ObjectRecordFactory.create(
ObjectRecordFactory.create(
data={"diameter": 50}, object=record_old.object, start_at=record_old.end_at
)

Expand Down Expand Up @@ -371,7 +371,7 @@ def test_filter_date_detail(self):
record1 = ObjectRecordFactory.create(
object=object, start_at="2020-01-01", end_at="2020-12-31"
)
record2 = ObjectRecordFactory.create(object=object, start_at="2021-01-01")
ObjectRecordFactory.create(object=object, start_at="2021-01-01")

url = reverse_lazy("object-detail", args=[object.uuid])

Expand All @@ -385,7 +385,7 @@ def test_filter_date_detail(self):

def test_filter_date_detail_no_actual_record(self):
object = ObjectFactory.create(object_type=self.object_type)
record = ObjectRecordFactory.create(object=object, start_at="2021-01-01")
ObjectRecordFactory.create(object=object, start_at="2021-01-01")

url = reverse_lazy("object-detail", args=[object.uuid])

Expand All @@ -399,9 +399,9 @@ def test_filter_date_list(self):
record11 = ObjectRecordFactory.create(
object=object1, start_at="2020-01-01", end_at="2020-12-31"
)
record12 = ObjectRecordFactory.create(object=object1, start_at="2021-01-01")
ObjectRecordFactory.create(object=object1, start_at="2021-01-01")
# object 2 - don't show
record21 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object__object_type=self.object_type, start_at="2021-01-01"
)

Expand All @@ -424,7 +424,7 @@ def test_filter_registration_date_detail(self):
object=object,
registration_at="2020-01-01",
)
record2 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=object, registration_at="2021-01-01"
)

Expand All @@ -440,7 +440,7 @@ def test_filter_registration_date_detail(self):

def test_filter_registration_date_detail_no_record(self):
object = ObjectFactory.create(object_type=self.object_type)
record = ObjectRecordFactory.create(object=object, registration_at="2021-01-01")
ObjectRecordFactory.create(object=object, registration_at="2021-01-01")

url = reverse_lazy("object-detail", args=[object.uuid])

Expand All @@ -454,11 +454,11 @@ def test_filter_registration_date_list(self):
record11 = ObjectRecordFactory.create(
object=object1, registration_at="2020-01-01"
)
record12 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=object1, registration_at="2021-01-01"
)
# object 2 - don't show
record21 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object__object_type=self.object_type, registration_at="2021-01-01"
)

Expand Down
2 changes: 1 addition & 1 deletion src/objects/tests/v1/test_object_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_list_actual_objects(self, m):
object__object_type=self.object_type,
start_at=date.today(),
)
object_record2 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object__object_type=self.object_type,
start_at=date.today() - timedelta(days=10),
end_at=date.today() - timedelta(days=1),
Expand Down
10 changes: 5 additions & 5 deletions src/objects/tests/v1/test_stuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_2a_2_records_found(self):
Test 2a: If records 1 and 40 exists, material history and formal history on
01-01-2020 should say: Record 40
"""
record_1 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=self.object,
data={
"geslachtsnaam": "Poepenstaart",
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_3a_3_records_found(self):
Test 3a: If records 1, 40 and 50 exists, material history and formal history
on 01-01-2020 should say: Record 50
"""
record_1 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=self.object,
data={
"geslachtsnaam": "Poepenstaart",
Expand All @@ -189,7 +189,7 @@ def test_3a_3_records_found(self):
end_at=date(2001, 9, 3),
registration_at=date(1977, 8, 7),
)
record_40 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=self.object,
data={
"geslachtsnaam": "Bergh",
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_3b_3_records_not_found(self):


class Stuf22Tests(TokenAuthMixin, APITestCase):
"""
""" # noqa
Test cases based on the Table 2.2 in the StUF 03.01
|PersoonsId|volgnummer|geslachtsnaam|voorvoegsel|voorletters|geboortedatum|burgerlijkestaat|beginGeldigheid|tijdstipRegistratie|
|----------|----------|-------------|-----------|-----------|-------------|----------------|---------------|-------------------|
Expand Down Expand Up @@ -403,7 +403,7 @@ def test_4d_not_found(self):


class Stuf23Tests(TokenAuthMixin, APITestCase):
"""
""" # noqa
Test cases based on the Table 2.2 in the StUF 03.01
|PersoonsId|volgnummer|geslachtsnaam|voorvoegsel|voorletters|geboortedatum|burgerlijkestaat|beginGeldigheid|tijdstipRegistratie|volgnrNaCorrectie|
|----------|----------|-------------|-----------|-----------|-------------|----------------|---------------|-------------------|-----------------|
Expand Down
20 changes: 10 additions & 10 deletions src/objects/tests/v2/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def test_filter_exclude_old_records(self):
start_at=date.today() - timedelta(days=10),
end_at=date.today() - timedelta(days=1),
)
record_new = ObjectRecordFactory.create(
ObjectRecordFactory.create(
data={"diameter": 50}, object=record_old.object, start_at=record_old.end_at
)

Expand All @@ -378,7 +378,7 @@ def test_filter_exclude_old_records(self):
self.assertEqual(len(data), 0)

def test_filter_date_field_gte(self):
record = ObjectRecordFactory.create(
ObjectRecordFactory.create(
data={"dateField": "2000-10-10"}, object__object_type=self.object_type
)

Expand Down Expand Up @@ -445,7 +445,7 @@ def test_filter_date_detail(self):
record1 = ObjectRecordFactory.create(
object=object, start_at="2020-01-01", end_at="2020-12-31"
)
record2 = ObjectRecordFactory.create(object=object, start_at="2021-01-01")
ObjectRecordFactory.create(object=object, start_at="2021-01-01")

url = reverse_lazy("object-detail", args=[object.uuid])

Expand All @@ -459,7 +459,7 @@ def test_filter_date_detail(self):

def test_filter_date_detail_no_actual_record(self):
object = ObjectFactory.create(object_type=self.object_type)
record = ObjectRecordFactory.create(object=object, start_at="2021-01-01")
ObjectRecordFactory.create(object=object, start_at="2021-01-01")

url = reverse_lazy("object-detail", args=[object.uuid])

Expand All @@ -473,9 +473,9 @@ def test_filter_date_list(self):
record11 = ObjectRecordFactory.create(
object=object1, start_at="2020-01-01", end_at="2020-12-31"
)
record12 = ObjectRecordFactory.create(object=object1, start_at="2021-01-01")
ObjectRecordFactory.create(object=object1, start_at="2021-01-01")
# object 2 - don't show
record21 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object__object_type=self.object_type, start_at="2021-01-01"
)

Expand All @@ -498,7 +498,7 @@ def test_filter_registration_date_detail(self):
object=object,
registration_at="2020-01-01",
)
record2 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=object, registration_at="2021-01-01"
)

Expand All @@ -514,7 +514,7 @@ def test_filter_registration_date_detail(self):

def test_filter_registration_date_detail_no_record(self):
object = ObjectFactory.create(object_type=self.object_type)
record = ObjectRecordFactory.create(object=object, registration_at="2021-01-01")
ObjectRecordFactory.create(object=object, registration_at="2021-01-01")

url = reverse_lazy("object-detail", args=[object.uuid])

Expand All @@ -528,11 +528,11 @@ def test_filter_registration_date_list(self):
record11 = ObjectRecordFactory.create(
object=object1, registration_at="2020-01-01"
)
record12 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=object1, registration_at="2021-01-01"
)
# object 2 - don't show
record21 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object__object_type=self.object_type, registration_at="2021-01-01"
)

Expand Down
2 changes: 1 addition & 1 deletion src/objects/tests/v2/test_object_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_list_actual_objects(self, m):
object__object_type=self.object_type,
start_at=date.today(),
)
object_record2 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object__object_type=self.object_type,
start_at=date.today() - timedelta(days=10),
end_at=date.today() - timedelta(days=1),
Expand Down
12 changes: 6 additions & 6 deletions src/objects/tests/v2/test_stuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


class Stuf21Tests(TokenAuthMixin, APITestCase):
"""
""" # noqa
Test cases based on the Table 2.1 in the StUF 03.01
|PersoonsId|volgnummer|geslachtsnaam|voorvoegsel|voorletters|geboortedatum|burgerlijkestaat|beginGeldigheid|
|----------|----------|-------------|-----------|-----------|-------------|----------------|---------------|
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_2a_2_records_found(self):
Test 2a: If records 1 and 40 exists, material history and formal history on
01-01-2020 should say: Record 40
"""
record_1 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=self.object,
data={
"geslachtsnaam": "Poepenstaart",
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_3a_3_records_found(self):
Test 3a: If records 1, 40 and 50 exists, material history and formal history
on 01-01-2020 should say: Record 50
"""
record_1 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=self.object,
data={
"geslachtsnaam": "Poepenstaart",
Expand All @@ -189,7 +189,7 @@ def test_3a_3_records_found(self):
end_at=date(2001, 9, 3),
registration_at=date(1977, 8, 7),
)
record_40 = ObjectRecordFactory.create(
ObjectRecordFactory.create(
object=self.object,
data={
"geslachtsnaam": "Bergh",
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_3b_3_records_not_found(self):


class Stuf22Tests(TokenAuthMixin, APITestCase):
"""
""" # noqa
Test cases based on the Table 2.2 in the StUF 03.01
|PersoonsId|volgnummer|geslachtsnaam|voorvoegsel|voorletters|geboortedatum|burgerlijkestaat|beginGeldigheid|tijdstipRegistratie|
|----------|----------|-------------|-----------|-----------|-------------|----------------|---------------|-------------------|
Expand Down Expand Up @@ -403,7 +403,7 @@ def test_4d_not_found(self):


class Stuf23Tests(TokenAuthMixin, APITestCase):
"""
""" # noqa
Test cases based on the Table 2.2 in the StUF 03.01
|PersoonsId|volgnummer|geslachtsnaam|voorvoegsel|voorletters|geboortedatum|burgerlijkestaat|beginGeldigheid|tijdstipRegistratie|volgnrNaCorrectie|
|----------|----------|-------------|-----------|-----------|-------------|----------------|---------------|-------------------|-----------------|
Expand Down

0 comments on commit 9b25488

Please sign in to comment.