From 3a0f5b265254bae2812ebf358e04907831d97c9a Mon Sep 17 00:00:00 2001 From: Michael Benowitz Date: Wed, 18 May 2022 17:06:14 -0400 Subject: [PATCH] HOTFIX Add has_version None handler --- model/postgres/record.py | 4 +++- tests/unit/test_model_record.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/model/postgres/record.py b/model/postgres/record.py index 4e3f340494..0736553355 100644 --- a/model/postgres/record.py +++ b/model/postgres/record.py @@ -66,7 +66,9 @@ def has_version(self): @has_version.setter def has_version(self, versionNum): - if self.languages != [] and self.languages != None: + if versionNum is None: + self._has_version = versionNum + elif self.languages != [] and self.languages != None: editionNo = extract(versionNum, self.languages[0].split('|')[0]) self._has_version = f'{versionNum}|{editionNo}' else: diff --git a/tests/unit/test_model_record.py b/tests/unit/test_model_record.py index f5013a6bf4..1706b8c881 100644 --- a/tests/unit/test_model_record.py +++ b/tests/unit/test_model_record.py @@ -17,6 +17,11 @@ def test_no_language(self, testRecord): testRecord.has_version = 'first edition' assert testRecord.has_version == 'first edition|1' + # Test to assert that the setter properly handles null values + def test_no_edition(self, testRecord): + testRecord.has_version = None + assert testRecord.has_version is None + # Failed Test for setter method def test_has_version_failure(self, testRecord): testRecord.has_version = 'other edition'