|
@@ 108-131 (lines=24) @@
|
| 105 |
|
utilities.load(Mock) |
| 106 |
|
|
| 107 |
|
|
| 108 |
|
def describe_save(): |
| 109 |
|
|
| 110 |
|
def it_creates_files(instance): |
| 111 |
|
utilities.save(instance) |
| 112 |
|
|
| 113 |
|
expect(instance.__mapper__.exists) == True |
| 114 |
|
|
| 115 |
|
def it_marks_files_as_modified(instance): |
| 116 |
|
instance.__mapper__.create() |
| 117 |
|
instance.__mapper__.modified = False |
| 118 |
|
|
| 119 |
|
utilities.save(instance) |
| 120 |
|
|
| 121 |
|
expect(instance.__mapper__.modified) == True |
| 122 |
|
|
| 123 |
|
def it_expects_the_file_to_not_be_deleted(instance): |
| 124 |
|
instance.__mapper__.delete() |
| 125 |
|
|
| 126 |
|
with expect.raises(exceptions.DeletedFileError): |
| 127 |
|
utilities.save(instance) |
| 128 |
|
|
| 129 |
|
def it_requires_a_mapped_instance(): |
| 130 |
|
with expect.raises(TypeError): |
| 131 |
|
utilities.save(Mock) |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
def describe_delete(): |
|
@@ 38-61 (lines=24) @@
|
| 35 |
|
return model_class('foo', 'bar') |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
def describe_create(): |
| 39 |
|
|
| 40 |
|
def it_creates_files(model_class): |
| 41 |
|
instance = utilities.create(model_class, 'foo', 'bar') |
| 42 |
|
|
| 43 |
|
expect(instance.__mapper__.exists) == True |
| 44 |
|
|
| 45 |
|
def it_requires_files_to_not_yet_exist(model_class, instance): |
| 46 |
|
instance.__mapper__.create() |
| 47 |
|
|
| 48 |
|
with expect.raises(exceptions.DuplicateMappingError): |
| 49 |
|
utilities.create(model_class, 'foo', 'bar') |
| 50 |
|
|
| 51 |
|
def it_can_overwrite_files(model_class, instance): |
| 52 |
|
instance.__mapper__.create() |
| 53 |
|
|
| 54 |
|
utilities.create(model_class, 'foo', 'bar', overwrite=True) |
| 55 |
|
|
| 56 |
|
def it_can_also_be_called_with_an_instance(instance): |
| 57 |
|
expect(yorm.create(instance)) == instance |
| 58 |
|
|
| 59 |
|
def it_requires_a_mapped_class_or_instance(): |
| 60 |
|
with expect.raises(TypeError): |
| 61 |
|
utilities.create(Mock) |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
def describe_find(): |