From 81a55ba452a18b219750109a46f76b331d52fe12 Mon Sep 17 00:00:00 2001 From: Daniil Fajnberg Date: Mon, 3 Oct 2022 09:17:29 +0200 Subject: [PATCH] Add fixtures; minor changes --- src/compub/models/base.py | 2 +- src/compub/models/companies.py | 2 +- tests/fixtures/companies/company.json | 5 ++++ .../fixtures/companies/company_industry.json | 0 tests/fixtures/companies/industry.json | 9 ++++++++ tests/fixtures/companies/legal_form.json | 16 +++++++++++++ .../companies/legal_form_subcategory.json | 17 ++++++++++++++ tests/fixtures/geography/address.json | 8 +++++++ tests/fixtures/geography/city.json | 23 +++++++++++++++++++ tests/fixtures/geography/state_province.json | 15 ++++++++++++ tests/fixtures/geography/street.json | 7 ++++++ 11 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/companies/company.json create mode 100644 tests/fixtures/companies/company_industry.json create mode 100644 tests/fixtures/companies/industry.json create mode 100644 tests/fixtures/companies/legal_form.json create mode 100644 tests/fixtures/companies/legal_form_subcategory.json create mode 100644 tests/fixtures/geography/address.json create mode 100644 tests/fixtures/geography/city.json create mode 100644 tests/fixtures/geography/state_province.json create mode 100644 tests/fixtures/geography/street.json diff --git a/src/compub/models/base.py b/src/compub/models/base.py index 064a203..b748728 100644 --- a/src/compub/models/base.py +++ b/src/compub/models/base.py @@ -39,7 +39,7 @@ class DB: force_auto_coercion() @property - def engine(self): + def engine(self) -> Engine: if self._engine is None: self.start_engine() assert isinstance(self._engine, (AsyncEngine, Engine)) diff --git a/src/compub/models/companies.py b/src/compub/models/companies.py index 53afbe5..09be6c4 100644 --- a/src/compub/models/companies.py +++ b/src/compub/models/companies.py @@ -36,7 +36,7 @@ class LegalForm(AbstractBase, table=True): # Fields short: str = Field(max_length=32, nullable=False, index=True) name: Optional[str] = Field(default=None, max_length=255, sa_column=Column(Unicode(255))) - country: str = Field(sa_column=Column(CountryType)) + country: Optional[str] = Field(sa_column=Column(CountryType)) # Relationships subcategories: list['LegalFormSubcategory'] = Relationship( diff --git a/tests/fixtures/companies/company.json b/tests/fixtures/companies/company.json new file mode 100644 index 0000000..81ed610 --- /dev/null +++ b/tests/fixtures/companies/company.json @@ -0,0 +1,5 @@ +[ + { + + } +] \ No newline at end of file diff --git a/tests/fixtures/companies/company_industry.json b/tests/fixtures/companies/company_industry.json new file mode 100644 index 0000000..e69de29 diff --git a/tests/fixtures/companies/industry.json b/tests/fixtures/companies/industry.json new file mode 100644 index 0000000..11f56ed --- /dev/null +++ b/tests/fixtures/companies/industry.json @@ -0,0 +1,9 @@ +[ + { + "id": 1, + "name": "Energy" + }, { + "id": 2, + "name": "Retail" + } +] \ No newline at end of file diff --git a/tests/fixtures/companies/legal_form.json b/tests/fixtures/companies/legal_form.json new file mode 100644 index 0000000..00ff344 --- /dev/null +++ b/tests/fixtures/companies/legal_form.json @@ -0,0 +1,16 @@ +[ + { + "id": 1, + "short": "KG", + "name": "Kommanditgesellschaft", + "country": "DE" + }, { + "id": 2, + "short": "AG", + "name": "Aktiengesellschaft", + "country": "DE" + }, { + "id": 123, + "short": "Ausl.HRB" + } +] \ No newline at end of file diff --git a/tests/fixtures/companies/legal_form_subcategory.json b/tests/fixtures/companies/legal_form_subcategory.json new file mode 100644 index 0000000..e564ef9 --- /dev/null +++ b/tests/fixtures/companies/legal_form_subcategory.json @@ -0,0 +1,17 @@ +[ + { + "id": 111, + "short": "GmbH & Co. KG", + "name": "Gesellschaft mit beschränkter Haftung & Compagnie Kommanditgesellschaft", + "legal_form_id": 1 + }, { + "id": 112, + "short": "AG & Co. KG", + "name": "Aktiengesellschaft & Compagnie Kommanditgesellschaft", + "legal_form_id": 1 + }, { + "id": 69420, + "short": "LLC", + "legal_form_id": 123 + } +] \ No newline at end of file diff --git a/tests/fixtures/geography/address.json b/tests/fixtures/geography/address.json new file mode 100644 index 0000000..f33163d --- /dev/null +++ b/tests/fixtures/geography/address.json @@ -0,0 +1,8 @@ +[ + { + "id": 9999999, + "house_number": "123AB", + "supplement": "whatever", + "street_id": 1 + } +] \ No newline at end of file diff --git a/tests/fixtures/geography/city.json b/tests/fixtures/geography/city.json new file mode 100644 index 0000000..9efd872 --- /dev/null +++ b/tests/fixtures/geography/city.json @@ -0,0 +1,23 @@ +[ + { + "id": 1122, + "zip_code": "10405", + "name": "Berlin", + "state_province_id": 100 + }, { + "id": 9, + "zip_code": "33299", + "name": "Miami", + "state_province_id": 30 + }, { + "id": 10, + "zip_code": "33694", + "name": "Tampa", + "state_province_id": 30 + }, { + "id": 78787878, + "zip_code": "91000", + "name": "Luhansk", + "state_province_id": 4531354 + } +] \ No newline at end of file diff --git a/tests/fixtures/geography/state_province.json b/tests/fixtures/geography/state_province.json new file mode 100644 index 0000000..086367a --- /dev/null +++ b/tests/fixtures/geography/state_province.json @@ -0,0 +1,15 @@ +[ + { + "id": 100, + "country": "DE", + "name": "Berlin" + }, { + "id": 30, + "country": "US", + "name": "Florida" + }, { + "id": 4531354, + "country": "UA", + "name": "Luhansk Oblast" + } +] \ No newline at end of file diff --git a/tests/fixtures/geography/street.json b/tests/fixtures/geography/street.json new file mode 100644 index 0000000..9e0e29e --- /dev/null +++ b/tests/fixtures/geography/street.json @@ -0,0 +1,7 @@ +[ + { + "id": 1, + "name": "Some Street", + "city_id": 1122 + } +] \ No newline at end of file