Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
Add test for both manual and auto string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Sep 24, 2014
1 parent ccd4809 commit f80dfd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -7,7 +7,7 @@ ifndef TEST_RUNNER
# options are: nose, pytest
TEST_RUNNER := pytest
endif
UNIT_TEST_COVERAGE := 92
UNIT_TEST_COVERAGE := 94
INTEGRATION_TEST_COVERAGE := 100

# Project settings (automatically detected from files/directories)
Expand Down
18 changes: 18 additions & 0 deletions yorm/test/test_utilities.py
Expand Up @@ -133,6 +133,17 @@ class SampleDecoratedAttributesAutomatic:
def __init__(self, name):
self.name = name

@utilities.store_instances("{self.a}/{self.b}/{c}.yml",
{'self.b': 'b', 'c': 'c'})
class SampleDecoratedAttributesCombination:

"""Sample decorated class using an attribute value for paths."""

def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c

@utilities.store_instances("sample.yml", mapping={'var1': MockConverter})
class SampleDecoratedWithAttributes:

Expand Down Expand Up @@ -178,6 +189,13 @@ def test_filename_attributes_automatic(self):
assert "path/to/one.yml" == sample1.yorm_path
assert "path/to/two.yml" == sample2.yorm_path

def test_filename_attributes_combination(self):
"""Verify attributes can be used to determine filename (combo)."""
sample1 = self.SampleDecoratedAttributesCombination('A', 'B', 'C')
sample2 = self.SampleDecoratedAttributesCombination(1, 2, 3)
assert "A/B/C.yml" == sample1.yorm_path
assert "1/2/3.yml" == sample2.yorm_path

def test_store(self):
"""Verify store is called when setting an attribute."""
sample = self.SampleDecoratedWithAttributes()
Expand Down

0 comments on commit f80dfd3

Please sign in to comment.