Skip to content

Commit

Permalink
Tests for CoreTemplateSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
smmaurer committed Apr 2, 2019
1 parent 7516717 commit e6380ca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
26 changes: 26 additions & 0 deletions tests/test_shared_core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import print_function

import pytest

from urbansim_templates.shared import CoreTemplateSettings


def test_property_persistence():
"""
Confirm properties persist through to_dict() and from_dict().
"""
obj = CoreTemplateSettings()
obj.name = 'name'
obj.tags = ['tag1', 'tag2']
obj.notes = 'notes'
obj.autorun = True
obj.template = 'CoolNewTemplate'
obj.template_version = '0.1.dev0'

d = obj.to_dict()
print(d)

obj2 = CoreTemplateSettings.from_dict(d)
assert(obj2.to_dict() == d)

5 changes: 2 additions & 3 deletions urbansim_templates/shared/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

from urbansim_templates import __version__


Expand Down Expand Up @@ -77,7 +75,7 @@ def from_dict(cls, d):
template = d['template'],
template_version = d['template_version'],
)
return d
return obj


def to_dict(self):
Expand All @@ -98,4 +96,5 @@ def to_dict(self):
'template_version': self.template_version,
'modelmanager_version': self.modelmanager_version,
}
return d

0 comments on commit e6380ca

Please sign in to comment.