Skip to content

Commit

Permalink
Merge pull request #168 from NYPL/HOTFIX-has-version-none-handler
Browse files Browse the repository at this point in the history
HOTFIX Add has_version None handler
  • Loading branch information
mitri-slory authored May 18, 2022
2 parents 330b72f + 3a0f5b2 commit 6b4bb11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion model/postgres/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_model_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 6b4bb11

Please sign in to comment.