forked from reingart/exercism
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscale_generator_test.py
82 lines (61 loc) · 3.17 KB
/
scale_generator_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
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/scale-generator/canonical-data.json
# File last updated on 2023-07-19
import unittest
from scale_generator import (
Scale,
)
class ScaleGeneratorTest(unittest.TestCase):
# Test chromatic scales
def test_chromatic_scale_with_sharps(self):
expected = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
self.assertEqual(Scale("C").chromatic(), expected)
def test_chromatic_scale_with_flats(self):
expected = ["F", "Gb", "G", "Ab", "A", "Bb", "B", "C", "Db", "D", "Eb", "E"]
self.assertEqual(Scale("F").chromatic(), expected)
# Test scales with specified intervals
def test_simple_major_scale(self):
expected = ["C", "D", "E", "F", "G", "A", "B", "C"]
self.assertEqual(Scale("C").interval("MMmMMMm"), expected)
def test_major_scale_with_sharps(self):
expected = ["G", "A", "B", "C", "D", "E", "F#", "G"]
self.assertEqual(Scale("G").interval("MMmMMMm"), expected)
def test_major_scale_with_flats(self):
expected = ["F", "G", "A", "Bb", "C", "D", "E", "F"]
self.assertEqual(Scale("F").interval("MMmMMMm"), expected)
def test_minor_scale_with_sharps(self):
expected = ["F#", "G#", "A", "B", "C#", "D", "E", "F#"]
self.assertEqual(Scale("f#").interval("MmMMmMM"), expected)
def test_minor_scale_with_flats(self):
expected = ["Bb", "C", "Db", "Eb", "F", "Gb", "Ab", "Bb"]
self.assertEqual(Scale("bb").interval("MmMMmMM"), expected)
def test_dorian_mode(self):
expected = ["D", "E", "F", "G", "A", "B", "C", "D"]
self.assertEqual(Scale("d").interval("MmMMMmM"), expected)
def test_mixolydian_mode(self):
expected = ["Eb", "F", "G", "Ab", "Bb", "C", "Db", "Eb"]
self.assertEqual(Scale("Eb").interval("MMmMMmM"), expected)
def test_lydian_mode(self):
expected = ["A", "B", "C#", "D#", "E", "F#", "G#", "A"]
self.assertEqual(Scale("a").interval("MMMmMMm"), expected)
def test_phrygian_mode(self):
expected = ["E", "F", "G", "A", "B", "C", "D", "E"]
self.assertEqual(Scale("e").interval("mMMMmMM"), expected)
def test_locrian_mode(self):
expected = ["G", "Ab", "Bb", "C", "Db", "Eb", "F", "G"]
self.assertEqual(Scale("g").interval("mMMmMMM"), expected)
def test_harmonic_minor(self):
expected = ["D", "E", "F", "G", "A", "Bb", "Db", "D"]
self.assertEqual(Scale("d").interval("MmMMmAm"), expected)
def test_octatonic(self):
expected = ["C", "D", "D#", "F", "F#", "G#", "A", "B", "C"]
self.assertEqual(Scale("C").interval("MmMmMmMm"), expected)
def test_hexatonic(self):
expected = ["Db", "Eb", "F", "G", "A", "B", "Db"]
self.assertEqual(Scale("Db").interval("MMMMMM"), expected)
def test_pentatonic(self):
expected = ["A", "B", "C#", "E", "F#", "A"]
self.assertEqual(Scale("A").interval("MMAMA"), expected)
def test_enigmatic(self):
expected = ["G", "G#", "B", "C#", "D#", "F", "F#", "G"]
self.assertEqual(Scale("G").interval("mAMMMmm"), expected)