-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
137 lines (120 loc) · 3.09 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import pytest
from pytest_mock_resources import create_mongo_fixture
from src import api
from src.app import create_app
mongo = create_mongo_fixture()
@pytest.fixture()
def app():
app = create_app()
app.config.update({
'TESTING': True,
})
yield app
@pytest.fixture()
def client(app):
return app.test_client()
@pytest.fixture()
def expected_error_message():
return {
'errors': [
{
'status': '418',
'source': {
'pointer': '/stub_url',
},
'title': 'test',
'detail': 'test',
},
],
}
@pytest.fixture()
def songs():
return [
{
'artist': 'Artist 1',
'title': 'Lycanthropic Metamorphosis',
'difficulty': 14.6,
'level': 13,
'released': '2016-10-26',
},
{
'artist': 'Artist 1',
'title': 'A New Kennel',
'difficulty': 9.1,
'level': 9,
'released': '2010-02-03',
},
{
'artist': 'Artist 2',
'title': 'Awaki-Waki',
'difficulty': 15,
'level': 13,
'released': '2012-05-11',
},
{
'artist': 'Artist 1',
'title': 'You\'ve Got The Power',
'difficulty': 13.22,
'level': 13,
'released': '2014-12-20',
},
{
'artist': 'Artist 1',
'title': 'Wishing In The Night',
'difficulty': 10.98,
'level': 9,
'released': '2016-01-01',
},
{
'artist': 'Artist 1',
'title': 'Opa Opa',
'difficulty': 14.66,
'level': 13,
'released': '2013-04-27',
},
{
'artist': 'Artist 1',
'title': 'Greasy Fingers - boss level',
'difficulty': 2,
'level': 3,
'released': '2016-03-01',
},
{
'artist': 'Artist 1',
'title': 'Alabama Sunrise',
'difficulty': 5,
'level': 6,
'released': '2016-04-01',
},
{
'artist': 'Artist 1',
'title': 'Can\'t Buy Me Skills',
'difficulty': 9,
'level': 9,
'released': '2016-05-01',
},
{
'artist': 'Artist 1',
'title': 'Vivaldi Allegro Mashup',
'difficulty': 13,
'level': 13,
'released': '2016-06-01',
},
{
'artist': 'Artist 1',
'title': 'Babysitting',
'difficulty': 7,
'level': 6,
'released': '2016-07-01',
},
]
@pytest.fixture()
def environment(monkeypatch, client, songs, mongo):
def mock_mongo():
return mongo
monkeypatch.setattr(api, '_get_mongo_connection', mock_mongo)
mongo.songs.insert_many(songs)
mongo.songs.create_index([('artist', 'text'), ('title', 'text')])
for song in songs:
del song['_id']
return client