-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
176 lines (160 loc) · 5.87 KB
/
test.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
165
166
167
168
169
170
171
172
173
174
175
176
from Utils.Music import Music
import unittest
class MusicTest(unittest.TestCase):
def setUp(self):
print('\nTesting:', end=' ')
def test_valid_music_notation(self):
print('Valid Music Notation...')
note = 'Eb'
music = Music(note)
is_valid = music.valid_note(note)[1]
if is_valid:
self.assertTrue(is_valid)
print('Result:\tPASS')
else:
self.assertFalse(is_valid)
print('Result:\tFAIL')
def test_invalid_music_notation(self):
print('Invalid Music Notation...')
note = 'T#'
music = Music(note)
is_valid = music.valid_note(note)[1]
if is_valid:
self.assertTrue(is_valid)
print('Result:\tFAIL')
else:
self.assertFalse(is_valid)
print('Result:\tPASS')
def test_major_scale(self):
print('Major Scale...')
note = 'C'
music = Music(note)
scale = music.major_scale()
result = ' '.join(scale)
expected_result = 'C D E F G A B'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def test_major_chord(self):
print('Major Chord...')
note = 'C'
music = Music(note)
chord = music.major_chord()
result = ' '.join(chord)
expected_result = 'C E G'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def test_notes_in_major_scale(self):
print('Notes in Major Scale...')
note = 'C'
music = Music(note)
notes_in_scale = music.notes_in_major_scale()
result = ' '.join(notes_in_scale)
expected_result = 'C Dm Em F G Am Bdim'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def test_note_in_major_scales(self):
print('Note in Major Scales...')
note = 'C'
music = Music(note)
notes_in_scale = music.note_in_major_scales()
result = ' '.join(notes_in_scale)
expected_result = 'A# C C# D# F G G#'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def test_note_shift_with_capo_position(self):
print('Note Shift with Capo Position...')
note = 'D'
capo_position = 2
music = Music(note)
result = music.capo_pos_note_shift(capo_position)
expected_result = 'C'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def test_scale_shift_with_capo_position(self):
print('Scale Shift with Capo Position...')
note = 'D'
capo_position = 2
music = Music(note)
new_scale = music.capo_pos_scale_shift(capo_position)
result = ' '.join(new_scale)
expected_result = 'C Dm Em F G Am Bdim'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def test_minor_scale(self):
print('Minor Scale...')
note = 'C'
music = Music(note)
notes_in_scale = music.minor_scale()
result = ' '.join(notes_in_scale)
expected_result = 'C D D# F G G# A#'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def test_notes_in_minor_scale(self):
print('Notes in Minor Scale...')
note = 'C'
music = Music(note)
notes_in_scale = music.notes_in_minor_scale()
result = ' '.join(notes_in_scale)
expected_result = 'Cm Dm D# F/Fm G/Gm G# A#'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def test_valid_relative_major(self):
print('Relative Major Key...')
note = 'A'
music = Music(note)
result = music.relative_major(note)
expected_result = 'C'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def test_valid_relative_minor(self):
print('Relative Minor Key...')
note = 'C'
music = Music(note)
result = music.relative_minor(note)
expected_result = 'Am'
if result == expected_result:
self.assertTrue(result == expected_result)
print('Result:\tPASS')
else:
self.assertFalse(result != expected_result)
print('Result:\tFAIL')
def tearDown(self):
print('Test Completed')
if __name__ == "__main__":
unittest.main()