From 9ad437103267b404cab689c4a3bc9dd6b7457561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Tue, 27 Apr 2021 13:07:36 +0200 Subject: [PATCH] fix: fix error in the serialization of the Object type (#18) --- .github/workflows/tests.yml | 24 ++++++++++++++++++------ kosmorrolib/model.py | 8 +++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d0d15ef..112ddfc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,21 +31,27 @@ jobs: with: python-version: ${{ matrix.python_version }} - - name: Prepare environment + - name: Prepare environment (non-Windows systems) + if: ${{ matrix.os != 'windows-2019' }} run: | pip install --upgrade pip pipenv + - name: Prepare environment (Windows) + if: ${{ matrix.os == 'windows-2019' }} + run: | + python -mpip install --upgrade pip pipenv + - name: Install dependencies (all systems) run: | pipenv lock --pre pipenv sync --dev pipenv install --dev - - name: Install dependencies (Windows-specific) + - name: Install dependencies (Windows) if: ${{ matrix.os == 'windows-2019' }} run: | pipenv lock --dev -r > requirements.txt - pip install -r requirements.txt + python -mpip install -r requirements.txt - name: Run legacy tests run: | @@ -75,21 +81,27 @@ jobs: with: python-version: ${{ matrix.python_version }} - - name: Prepare environment + - name: Prepare environment (non-Windows systems) + if: ${{ matrix.os != 'windows-2019' }} run: | pip install --upgrade pip pipenv + - name: Prepare environment (Windows) + if: ${{ matrix.os == 'windows-2019' }} + run: | + python -mpip install --upgrade pip pipenv + - name: Install dependencies (all systems) run: | pipenv lock --pre pipenv sync --dev pipenv install --dev - - name: Install dependencies (Windows-specific) + - name: Install dependencies (Windows) if: ${{ matrix.os == 'windows-2019' }} run: | pipenv lock -r > requirements.txt - pip install -r requirements.txt + python -mpip install -r requirements.txt - name: Run doc tests (with coverage) if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.9' }} diff --git a/kosmorrolib/model.py b/kosmorrolib/model.py index 42db7a9..1f4a362 100644 --- a/kosmorrolib/model.py +++ b/kosmorrolib/model.py @@ -114,9 +114,15 @@ class Object(Serializable): ) def serialize(self) -> dict: + """Serialize the given object + + >>> planet = Planet(ObjectIdentifier.MARS, "MARS") + >>> planet.serialize() + {'identifier': 'MARS', 'type': 'PLANET', 'radius': None} + """ return { "identifier": self.identifier.name, - "type": self.get_type(), + "type": self.get_type().name, "radius": self.radius, }