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

Commit

Permalink
Raise proper exception on missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Apr 13, 2016
1 parent ea863d1 commit 55d13d5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/test_persistence_models.py
@@ -1,28 +1,32 @@
"""Integration tests using YORM as a persistence model."""
# pylint: disable=missing-docstring,no-self-use,misplaced-comparison-constant


import os

from expecter import expect

import yorm
from yorm.types import String


# CLASSES ######################################################################


class Config:
"""Domain model."""

def __init__(self, key, name=None, root=None):
self.key = key
self.name = name or ""
self.root = root or ""


@yorm.attr(key=yorm.types.String)
@yorm.attr(name=yorm.types.String)
@yorm.attr(key=String)
@yorm.attr(name=String)
@yorm.sync("{self.root}/{self.key}/config.yml",
auto_create=False, auto_save=False)
class ConfigModel:
"""Persistence model."""

def __init__(self, key, root):
self.key = key
Expand Down Expand Up @@ -76,6 +80,12 @@ def test_nonmapped_attribute_is_kept(self):
model.unmapped = 42
assert 42 == model.unmapped

def test_missing_files_are_handled(self):
model = ConfigModel('my_key_manual', self.root)

with expect.raises(yorm.exceptions.MissingFileError):
print(model.name)


class TestStore:

Expand Down

0 comments on commit 55d13d5

Please sign in to comment.