-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_band.py
164 lines (124 loc) · 3.67 KB
/
test_band.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
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
# Test Bands
import pytest
from Band import Band
from Guitarist import Guitarist
from Bassist import Bassist
from Drummer import Drummer
from Musician import Musician
##################
# Test Band Data #
##################
band_one = """
Catfish and the Bottlemen
Van McCann,Guitar
Jon Barr,Drums
Benji Blakeway,Bass
Bob Hall,Guitar
"""
band_two = """
Louis the Child
Robby,Bass
Freddy,Bass
"""
#####################
# Band Member Names #
#####################
def test_name_musician():
musician_test_name = Musician('John')
assert 'John' == musician_test_name.name
def test_name_bass():
bass_test_name = Bassist('Paul')
assert 'Paul' == bass_test_name.name
def test_name_guitar():
guitar_test_name = Guitarist('George')
assert 'George' == guitar_test_name.name
def test_name_drummer():
drummer_test_name = Drummer('Ringo')
assert 'Ringo' == drummer_test_name.name
def test_class_type():
test_drummer = Drummer('Test Name')
assert isinstance(test_drummer, Drummer)
########################
# Get Instrument Tests #
########################
def test_musician_instrument():
test_musician = Musician('Name')
assert 'Nothing' == test_musician.get_instrument()
def test_get_guitar():
test_guitarist = Guitarist('Slash')
assert 'Guitar' == test_guitarist.get_instrument()
def test_get_bass():
test_bassist = Bassist('Who Plays Bass Again?')
assert 'Bass' == test_bassist.get_instrument()
def test_get_drums():
test_drummer = Drummer('Insert Name')
assert 'Drums' == test_drummer.get_instrument()
##############
# Test Solos #
##############
def test_guitar_solo():
test_guitarist = Guitarist('An Actual Ukulele')
assert 'Guitar Sounds' == test_guitarist.play_solo()
def test_bass_solo():
test_bassist = Bassist('A Really Big Ukulele')
assert 'Bass Sounds' == test_bassist.play_solo()
def test_drum_solo():
test_drummer = Drummer('Silence')
assert 'LOUD NOISES' == test_drummer.play_solo()
def test_all_band_solos():
test_band = Band('Test Band', [Guitarist('Wham'), Drummer('Bam'), Bassist('Shang-a-lang')])
assert 'Guitar Sounds LOUD NOISES Bass Sounds ' == test_band.play_solos()
#################
# Band Creation #
#################
def test_band_name():
test_band = Band('Capital Cities')
assert 'Capital Cities' == test_band.name
def test_band_by_array():
band_array = [Band('Beatles', [Musician('John'), Bassist('Paul'), Guitarist('George'), Drummer('Ringo')])]
assert band_array == Band.all_bands
def test_band_by_data():
band_array = [Band.create_from_data(band_one)]
assert band_array == Band.all_bands
def test_multiple_bands_by_data():
band_array = [Band.create_from_data(band_one), Band.create_from_data(band_two)]
assert band_array == Band.all_bands
##################
# Output Tests #
##################
def test_str_output():
test_band = Band.create_from_data(band_one)
expected = """The Band's Name is: Catfish and the Bottlemen
The Members are:
Van McCann on Guitar
Jon Barr on Drums
Benji Blakeway on Bass
Bob Hall on Guitar
"""
assert expected == test_band.__str__()
def test_diff_str_output():
test_band = Band.create_from_data(band_two)
expected = """The Band's Name is: Louis the Child
The Members are:
Robby on Bass
Freddy on Bass
"""
assert expected == test_band.__str__()
def test_all_bands_list():
Band.create_from_data(band_one)
Band.create_from_data(band_two)
expected = """The Band's Name is: Catfish and the Bottlemen
The Members are:
Van McCann on Guitar
Jon Barr on Drums
Benji Blakeway on Bass
Bob Hall on Guitar
The Band's Name is: Louis the Child
The Members are:
Robby on Bass
Freddy on Bass
"""
assert expected == Band.to_list()
@pytest.fixture(autouse = True)
def clean():
Band.all_bands = []