# Path: moonlight/score/elements/clef.py
# class Clef(object):
# class TrebleClef(Clef):
# class BassClef(Clef):
# class _ScalePitch(object):
#   def y_position_to_midi(self, y_position):
#   def __init__(self):
#   def __init__(self):
#   def __init__(self, scale, midi):
#   def midi(self):
#   def pitch_index(self):
#   def __add__(self, interval):
# 
# Path: moonlight/score/elements/key_signature.py
# class _BaseAccidentals(object):
# class Accidentals(_BaseAccidentals):
# class KeySignature(_BaseAccidentals):
#   def __init__(self, clef, accidentals=None):
#   def _normalize_position(self, position):
#   def get_accidental_for_position(self, position):
#   def __init__(self, clef):
#   def put(self, position, accidental):
#   def _normalize_position(self, position):
#   def try_put(self, position, accidental):
#   def _can_put(self, position, accidental):
#   def get_next_accidental(self):
#   def get_type(self):
#   def __len__(self):
# def _key_sig_pitch_classes(note_name, ascending_fifths):
# _KEY_SIGNATURE_PITCH_CLASS_LIST = {
#     # The sharp key signature starts with F#, and each subsequent note ascends
#     # by a fifth.
#     Glyph.SHARP:
#         _key_sig_pitch_classes('F', ascending_fifths=True),
#     # The flat key signature starts with Bb, and each subsequent note descends
#     # by a fifth.
#     Glyph.FLAT:
#         _key_sig_pitch_classes('B', ascending_fifths=False),
# }
# _KEY_SIGNATURE_Y_POSITION_RANGES = {
#     (Glyph.CLEF_TREBLE, Glyph.SHARP): range(-1, 6),  # A#4 to G#5
#     (Glyph.CLEF_TREBLE, Glyph.FLAT): range(-3, 4),  # Fb4 to Eb5
#     (Glyph.CLEF_BASS, Glyph.SHARP): range(-3, 4),  # A#2 to G#3
#     (Glyph.CLEF_BASS, Glyph.FLAT): range(-5, 2),  # Fb2 to Eb3
# }


from absl.testing import absltest
from moonlight.protobuf import musicscore_pb2
from moonlight.score.elements import clef
from moonlight.score.elements import key_signature

  def testGMajor(self):
    sig = key_signature.KeySignature(clef.TrebleClef())
    self.assertTrue(sig.try_put(+4, musicscore_pb2.Glyph.SHARP))  # F#
    self.assertEqual(sig.get_next_accidental(),
                     (+1, musicscore_pb2.Glyph.SHARP))  # C#

  def testGMajor_bassClef(self):
    sig = key_signature.KeySignature(clef.BassClef())
    self.assertTrue(sig.try_put(+2, musicscore_pb2.Glyph.SHARP))  # F#
    self.assertEqual(sig.get_next_accidental(),
                     (-1, musicscore_pb2.Glyph.SHARP))  # C#

  def testBMajor(self):
    sig = key_signature.KeySignature(clef.TrebleClef())
    self.assertTrue(sig.try_put(+4, musicscore_pb2.Glyph.SHARP))  # F#
    self.assertTrue(sig.try_put(+1, musicscore_pb2.Glyph.SHARP))  # C#
    self.assertTrue(sig.try_put(+5, musicscore_pb2.Glyph.SHARP))  # G#
    self.assertEqual(sig.get_next_accidental(),
                     (+2, musicscore_pb2.Glyph.SHARP))  # D#

  def testEFlatMajor(self):
    sig = key_signature.KeySignature(clef.TrebleClef())
    self.assertTrue(sig.try_put(0, musicscore_pb2.Glyph.FLAT))  # Bb
    self.assertTrue(sig.try_put(+3, musicscore_pb2.Glyph.FLAT))  # Eb
    self.assertTrue(sig.try_put(-1, musicscore_pb2.Glyph.FLAT))  # Ab
    self.assertEqual(sig.get_next_accidental(),
                     (+2, musicscore_pb2.Glyph.FLAT))  # Db

  def testEFlatMajor_bassClef(self):

# Path: moonlight/score/elements/clef.py
# class Clef(object):
# class TrebleClef(Clef):
# class BassClef(Clef):
# class _ScalePitch(object):
#   def y_position_to_midi(self, y_position):
#   def __init__(self):
#   def __init__(self):
#   def __init__(self, scale, midi):
#   def midi(self):
#   def pitch_index(self):
#   def __add__(self, interval):
# 
# Path: moonlight/score/elements/key_signature.py
# class _BaseAccidentals(object):
# class Accidentals(_BaseAccidentals):
# class KeySignature(_BaseAccidentals):
#   def __init__(self, clef, accidentals=None):
#   def _normalize_position(self, position):
#   def get_accidental_for_position(self, position):
#   def __init__(self, clef):
#   def put(self, position, accidental):
#   def _normalize_position(self, position):
#   def try_put(self, position, accidental):
#   def _can_put(self, position, accidental):
#   def get_next_accidental(self):
#   def get_type(self):
#   def __len__(self):
# def _key_sig_pitch_classes(note_name, ascending_fifths):
# _KEY_SIGNATURE_PITCH_CLASS_LIST = {
#     # The sharp key signature starts with F#, and each subsequent note ascends
#     # by a fifth.
#     Glyph.SHARP:
#         _key_sig_pitch_classes('F', ascending_fifths=True),
#     # The flat key signature starts with Bb, and each subsequent note descends
#     # by a fifth.
#     Glyph.FLAT:
#         _key_sig_pitch_classes('B', ascending_fifths=False),
# }
# _KEY_SIGNATURE_Y_POSITION_RANGES = {
#     (Glyph.CLEF_TREBLE, Glyph.SHARP): range(-1, 6),  # A#4 to G#5
#     (Glyph.CLEF_TREBLE, Glyph.FLAT): range(-3, 4),  # Fb4 to Eb5
#     (Glyph.CLEF_BASS, Glyph.SHARP): range(-3, 4),  # A#2 to G#3
#     (Glyph.CLEF_BASS, Glyph.FLAT): range(-5, 2),  # Fb2 to Eb3
# }


# Path: moonlight/score/elements/key_signature_test.py
from absl.testing import absltest
from moonlight.protobuf import musicscore_pb2
from moonlight.score.elements import clef
from moonlight.score.elements import key_signature


  def testGMajor(self):
    sig = key_signature.KeySignature(clef.TrebleClef())
    self.assertTrue(sig.try_put(+4, musicscore_pb2.Glyph.SHARP))  # F#
    self.assertEqual(sig.get_next_accidental(),
                     (+1, musicscore_pb2.Glyph.SHARP))  # C#

  def testGMajor_bassClef(self):
    sig = key_signature.KeySignature(clef.BassClef())
    self.assertTrue(sig.try_put(+2, musicscore_pb2.Glyph.SHARP))  # F#
    self.assertEqual(sig.get_next_accidental(),
                     (-1, musicscore_pb2.Glyph.SHARP))  # C#

  def testBMajor(self):
    sig = key_signature.KeySignature(clef.TrebleClef())
    self.assertTrue(sig.try_put(+4, musicscore_pb2.Glyph.SHARP))  # F#
    self.assertTrue(sig.try_put(+1, musicscore_pb2.Glyph.SHARP))  # C#
    self.assertTrue(sig.try_put(+5, musicscore_pb2.Glyph.SHARP))  # G#
    self.assertEqual(sig.get_next_accidental(),
                     (+2, musicscore_pb2.Glyph.SHARP))  # D#

  def testEFlatMajor(self):
    sig = key_signature.KeySignature(clef.TrebleClef())
    self.assertTrue(sig.try_put(0, musicscore_pb2.Glyph.FLAT))  # Bb
    self.assertTrue(sig.try_put(+3, musicscore_pb2.Glyph.FLAT))  # Eb
    self.assertTrue(sig.try_put(-1, musicscore_pb2.Glyph.FLAT))  # Ab
    self.assertEqual(sig.get_next_accidental(),
                     (+2, musicscore_pb2.Glyph.FLAT))  # Db

  def testEFlatMajor_bassClef(self):

    sig = key_signature.KeySignature(clef.BassClef())