From 9da3e4adb9aa38843ed0d4f31a85d8b5523b3293 Mon Sep 17 00:00:00 2001 From: TrisNol Date: Tue, 11 Jul 2023 18:03:23 +0200 Subject: [PATCH] test: Introducing first unit tests of new Company and News model --- tests/models/company_test.py | 35 +++++++++++++++++++++++++++++++++++ tests/models/news_test.py | 23 +++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tests/models/company_test.py create mode 100644 tests/models/news_test.py diff --git a/tests/models/company_test.py b/tests/models/company_test.py new file mode 100644 index 0000000..a044492 --- /dev/null +++ b/tests/models/company_test.py @@ -0,0 +1,35 @@ +"""Test Models.company.""" + + +from aki_prj23_transparenzregister.models.company import Company, CompanyID, Location + + +def test_to_dict() -> None: + """Tests if the version tag is entered.""" + company_id = CompanyID("The Shire", "420") + location = Location( + city="Insmouth", house_number="19", street="Harbor", zip_code="1890" + ) + company = Company( + id=company_id, + last_update="Tomorrow", + location=location, + name="BLANK GmbH", + relationships=[], + ) + + assert company.to_dict() == { + "id": { + "district_court": company_id.district_court, + "hr_number": company_id.hr_number, + }, + "last_update": company.last_update, + "location": { + "city": location.city, + "house_number": location.house_number, + "street": location.street, + "zip_code": location.zip_code, + }, + "name": "BLANK GmbH", + "relationships": [], + } diff --git a/tests/models/news_test.py b/tests/models/news_test.py new file mode 100644 index 0000000..c44b297 --- /dev/null +++ b/tests/models/news_test.py @@ -0,0 +1,23 @@ +"""Test Models.nes.""" + + +from aki_prj23_transparenzregister.models.news import News + + +def test_to_dict() -> None: + """Tests if the version tag is entered.""" + news = News( + "4711", + "Economy collapses", + "2042", + "Toilet paper prices rising", + "https://www.google.com", + ) + + assert news.to_dict() == { + "id": news.id, + "title": news.title, + "date": news.date, + "text": news.text, + "source_url": news.source_url, + }