|
1
|
|
|
# pylint: disable=unused-variable,expression-not-assigned |
|
2
|
|
|
|
|
3
|
|
|
from unittest.mock import patch, call |
|
4
|
|
|
|
|
5
|
|
|
import pytest |
|
6
|
|
|
from expecter import expect |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
import yorm |
|
9
|
|
|
from yorm.mixins import ModelMixin |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
def describe_model_mixin(): |
|
13
|
|
|
|
|
14
|
|
|
@pytest.fixture |
|
15
|
|
|
def mixed_class(): |
|
16
|
|
|
|
|
17
|
|
|
@yorm.sync("tmp/model.yml") |
|
18
|
|
|
class MyClass(ModelMixin): |
|
19
|
|
|
pass |
|
20
|
|
|
|
|
21
|
|
|
return MyClass |
|
22
|
|
|
|
|
23
|
|
|
@pytest.fixture |
|
24
|
|
|
def mixed_instance(mixed_class): |
|
25
|
|
|
return mixed_class() |
|
26
|
|
|
|
|
27
|
|
|
@patch('yorm.mixins.utilities') |
|
28
|
|
|
def it_adds_a_new_method(utilities, mixed_class): |
|
29
|
|
|
mixed_class.new('foobar', overwrite=True) |
|
30
|
|
|
|
|
31
|
|
|
expect(utilities.mock_calls) == [ |
|
32
|
|
|
call.create(mixed_class, 'foobar', overwrite=True) |
|
33
|
|
|
] |
|
34
|
|
|
|
|
35
|
|
|
@patch('yorm.mixins.utilities') |
|
36
|
|
|
def it_adds_a_find_method(utilities, mixed_class): |
|
37
|
|
|
mixed_class.find('foobar', create=True) |
|
38
|
|
|
|
|
39
|
|
|
expect(utilities.mock_calls) == [ |
|
40
|
|
|
call.find(mixed_class, 'foobar', create=True) |
|
41
|
|
|
] |
|
42
|
|
|
|
|
43
|
|
|
@patch('yorm.mixins.utilities') |
|
44
|
|
|
def it_adds_a_match_method(utilities, mixed_class): |
|
45
|
|
|
mixed_class.match(foo='bar') |
|
46
|
|
|
|
|
47
|
|
|
expect(utilities.mock_calls) == [ |
|
48
|
|
|
call.match(mixed_class, foo='bar') |
|
49
|
|
|
] |
|
50
|
|
|
|
|
51
|
|
|
@patch('yorm.mixins.utilities') |
|
52
|
|
|
def it_adds_a_load_method(utilities, mixed_instance): |
|
53
|
|
|
mixed_instance.load() |
|
54
|
|
|
|
|
55
|
|
|
expect(utilities.mock_calls) == [ |
|
56
|
|
|
call.load(mixed_instance) |
|
57
|
|
|
] |
|
58
|
|
|
|
|
59
|
|
|
@patch('yorm.mixins.utilities') |
|
60
|
|
|
def it_adds_a_save_method(utilities, mixed_instance): |
|
61
|
|
|
mixed_instance.save() |
|
62
|
|
|
|
|
63
|
|
|
expect(utilities.mock_calls) == [ |
|
64
|
|
|
call.save(mixed_instance) |
|
65
|
|
|
] |
|
66
|
|
|
|
|
67
|
|
|
@patch('yorm.mixins.utilities') |
|
68
|
|
|
def it_adds_a_delete_method(utilities, mixed_instance): |
|
69
|
|
|
mixed_instance.delete() |
|
70
|
|
|
|
|
71
|
|
|
expect(utilities.mock_calls) == [ |
|
72
|
|
|
call.delete(mixed_instance) |
|
73
|
|
|
] |
|
74
|
|
|
|
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.