-
Notifications
You must be signed in to change notification settings - Fork 681
Expand file tree
/
Copy pathtest_wave_01.py
More file actions
225 lines (186 loc) · 5.71 KB
/
test_wave_01.py
File metadata and controls
225 lines (186 loc) · 5.71 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import pytest
# NOTE: In production code, we developers should change import * to something more specific. Due to some constraints of this project, we will import * in our test files.
# from viewing_party.main import *
from viewing_party.party import *
from tests.test_constants import *
# @pytest.mark.skip()
def test_create_successful_movie():
# Arrange
movie_title = MOVIE_TITLE_1
genre = GENRE_1
rating = RATING_1
# Act
new_movie = create_movie(movie_title, genre, rating)
# Assert
assert new_movie["title"] == MOVIE_TITLE_1
assert new_movie["genre"] == GENRE_1
assert new_movie["rating"] == pytest.approx(RATING_1)
# @pytest.mark.skip()
def test_create_no_title_movie():
# Arrange
movie_title = None
genre = "Horror"
rating = 3.5
# Act
new_movie = create_movie(movie_title, genre, rating)
# Assert
assert new_movie is None
# @pytest.mark.skip()
def test_create_no_genre_movie():
# Arrange
movie_title = "Title A"
genre = None
rating = 3.5
# Act
new_movie = create_movie(movie_title, genre, rating)
# Assert
assert new_movie is None
# @pytest.mark.skip()
def test_create_no_rating_movie():
# Arrange
movie_title = "Title A"
genre = "Horror"
rating = None
# Act
new_movie = create_movie(movie_title, genre, rating)
# Assert
assert new_movie is None
# @pytest.mark.skip()
def test_adds_movie_to_user_watched():
# Arrange
movie = {
"title": MOVIE_TITLE_1,
"genre": GENRE_1,
"rating": RATING_1
}
user_data = {
"watched": []
}
# Act
updated_data = add_to_watched(user_data, movie)
# Assert
assert len(updated_data["watched"]) == 1
assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1
assert updated_data["watched"][0]["genre"] == GENRE_1
assert updated_data["watched"][0]["rating"] == RATING_1
# @pytest.mark.skip()
def test_adds_movie_to_non_empty_user_watched():
# Arrange
movie = {
"title": MOVIE_TITLE_1,
"genre": GENRE_1,
"rating": RATING_1
}
user_data = {
"watched": [FANTASY_2]
}
# Act
updated_data = add_to_watched(user_data, movie)
# Assert
assert len(updated_data["watched"]) == 2
assert movie in updated_data["watched"]
assert FANTASY_2 in updated_data["watched"]
# @pytest.mark.skip()
def test_adds_movie_to_user_watchlist():
# Arrange
movie = {
"title": MOVIE_TITLE_1,
"genre": GENRE_1,
"rating": RATING_1
}
user_data = {
"watchlist": []
}
# Act
updated_data = add_to_watchlist(user_data, movie)
# Assert
assert len(updated_data["watchlist"]) == 1
assert updated_data["watchlist"][0]["title"] == MOVIE_TITLE_1
assert updated_data["watchlist"][0]["genre"] == GENRE_1
assert updated_data["watchlist"][0]["rating"] == RATING_1
# @pytest.mark.skip()
def test_adds_movie_to_non_empty_user_watchlist():
# Arrange
movie = {
"title": MOVIE_TITLE_1,
"genre": GENRE_1,
"rating": RATING_1
}
user_data = {
"watchlist": [FANTASY_2]
}
# Act
updated_data = add_to_watchlist(user_data, movie)
# Assert
assert len(updated_data["watchlist"]) == 2
assert movie in updated_data["watchlist"]
assert FANTASY_2 in updated_data["watchlist"]
# @pytest.mark.skip()
def test_moves_movie_from_watchlist_to_empty_watched():
# Arrange
janes_data = {
"watchlist": [{
"title": MOVIE_TITLE_1,
"genre": GENRE_1,
"rating": RATING_1
}],
"watched": []
}
# Act
updated_data = watch_movie(janes_data, MOVIE_TITLE_1)
# Assert
assert len(updated_data["watchlist"]) == 0
assert len(updated_data["watched"]) == 1
assert updated_data == {
"watchlist": [],
"watched": [{
"title": MOVIE_TITLE_1,
"genre": GENRE_1,
"rating": RATING_1
}]
}
# raise Exception("Test needs to be completed.")
# *******************************************************************************************
# ****** Add assertions here to test that the correct movie was added to "watched" **********
# *******************************************************************************************
# @pytest.mark.skip()
def test_moves_movie_from_watchlist_to_watched():
# Arrange
movie_to_watch = HORROR_1
janes_data = {
"watchlist": [
FANTASY_1,
movie_to_watch
],
"watched": [FANTASY_2]
}
# Act
updated_data = watch_movie(janes_data, movie_to_watch["title"])
# Assert
assert len(updated_data["watchlist"]) == 1
assert len(updated_data["watched"]) == 2
assert updated_data == {
"watchlist": [
FANTASY_1
],
"watched": [FANTASY_2, HORROR_1]
}
# raise Exception("Test needs to be completed.")
# *******************************************************************************************
# ****** Add assertions here to test that the correct movie was added to "watched" **********
# *******************************************************************************************
# @pytest.mark.skip()
def test_does_nothing_if_movie_not_in_watchlist():
# Arrange
movie_to_watch = HORROR_1
janes_data = {
"watchlist": [FANTASY_1],
"watched": [FANTASY_2]
}
# Act
updated_data = watch_movie(janes_data, "Non-Existent Movie Title")
# Assert
assert len(updated_data["watchlist"]) == 1
assert len(updated_data["watched"]) == 1
assert movie_to_watch not in updated_data["watchlist"]
assert movie_to_watch not in updated_data["watched"]