Skip to content

Commit

Permalink
Merge 623ecb1 into 0093178
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmiller committed Oct 4, 2018
2 parents 0093178 + 623ecb1 commit 5bb7ab8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog.md
@@ -1,5 +1,11 @@
### 0.13.0 (Major Release)

#### Lookuplist data format

Lookuplist entries in data files are no longer required to have an empty synonyms list
if the entry doesn't have a synonym. This reduces the file size and makes it easier to
hand craft data files for new applications.

#### Removes the deprecated Model._title property

Use of `Model._title` to set a display name of a subrecord has issued a warning for several
Expand Down
2 changes: 1 addition & 1 deletion opal/core/lookuplists.py
Expand Up @@ -16,7 +16,7 @@ def load_lookuplist_item(model, item):
instance, created = model.objects.get_or_create(name=item['name'])
synonyms_created = 0

for synonym in item['synonyms']:
for synonym in item.get('synonyms', []):
syn, created_synonym = Synonym.objects.get_or_create(
content_type=content_type,
object_id=instance.id,
Expand Down
7 changes: 7 additions & 0 deletions opal/tests/test_lookuplists.py
Expand Up @@ -20,6 +20,7 @@ def setUp(self):


class LookupListLoadingTestCase(AbstractLookupListTestCase):

def test_create_instance(self):
data = {"hat": [dict(name="Bowler", synonyms=[])]}
_, created, _ = load_lookuplist(data)
Expand Down Expand Up @@ -48,6 +49,12 @@ def test_create_instance_and_synonym(self):
self.assertEqual(created, 1)
self.assertEqual(synonyms, 1)

def test_create_instance_allow_no_symptom(self):
data = {"hat": [dict(name="Bowler")]}
_, created, synonyms = load_lookuplist(data)
self.assertEqual(created, 1)
self.assertEqual(synonyms, 0)


class LookupListClassTestCase(AbstractLookupListTestCase):
def test_unicode(self):
Expand Down

0 comments on commit 5bb7ab8

Please sign in to comment.