Completed
Push — develop ( ae7ea2...7d38f7 )
by Jace
05:48 queued 04:36
created

it_adds_a_match_method()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
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
0 ignored issues
show
Configuration introduced by
The import expecter could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
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