def test_ThrowsErrorWithParallelOctaves(self):
     analysis = XMLChoraleAnalysis(TestFilePaths.parallel_octave)
     analysis.analyze()
     errors = analysis.get_error_list("ParallelOctaveError")
     for error in errors:
         print error.message
     self.assertEqual(1, len(errors))
 def test_ErrorHasCorrectProperties(self):
     analysis = XMLChoraleAnalysis(TestFilePaths.rep_bass)
     analysis.analyze()
     error = get_only_element(analysis.get_error_list("RepBassError"))
     self.assertEqual(3.0, error.get_measure_1())
     self.assertEqual(3.0, error.get_measure_2())
     self.assertEqual(0.0, error.get_beat_1())
     self.assertEqual(1.0, error.get_beat_2())
    def test_CorrectPropertiesOnParallelFifthError(self):
        analysis = XMLChoraleAnalysis(TestFilePaths.parallel_fifth)
        analysis.analyze()
        error = get_only_element(analysis.get_error_list("ParallelFifthError"))

        self.assertEqual("Fifth", error.get_interval_name())
        self.assertEqual(Constants.ALTO_PART_NUMBER, error.get_part_number_1())
        self.assertEqual(Constants.TENOR_PART_NUMBER, error.get_part_number_2())
        self.assertEqual(2, error.get_measure_1())
        self.assertEqual(1.0, error.get_beat_1())
        self.assertEqual(2, error.get_measure_2())
        self.assertEqual(2.0, error.get_beat_2())
Example #4
0
	def on_post(self, req, resp):
		print "Sebastian request recieved"

		resp.status = falcon.HTTP_200
		params = json.loads(req.stream.read())
		analysis = XMLChoraleAnalysis(params['chorale'])
		analysis.analyze()
		error_list = analysis.get_error_list_all()
		annotated_chorale_xml_path = analysis.get_annotated_chorale().score.write('musicxml')
		annotated_chorale_xml = open(annotated_chorale_xml_path, 'rb').read()

		out = {'errors': [], 'chorale': annotated_chorale_xml}
		for error in error_list:
			out['errors'].append(error.message)

		resp.body = json.dumps(out)
    def test_CorrectPropertiesOnParallelUnisonError(self):
        analysis = XMLChoraleAnalysis(TestFilePaths.parallel_unison)
        analysis.analyze()
        error = get_only_element(analysis.get_error_list("ParallelUnisonError"))

        self.assertEqual("Unison", error.get_interval_name())
        self.assertEqual(Constants.ALTO_PART_NUMBER, error.get_part_number_1())
        self.assertEqual(Constants.TENOR_PART_NUMBER, error.get_part_number_2())
        self.assertEqual(2, error.get_measure_1())
        self.assertEqual(1.0, error.get_beat_1())
        self.assertEqual(2, error.get_measure_2())
        self.assertEqual(2.0, error.get_beat_2())
        self.assertEqual(note.Note("C4"), error.get_notes()[0])
        self.assertEqual(note.Note("D4"), error.get_notes()[1])
        self.assertEqual(note.Note("C4"), error.get_notes()[2])
        self.assertEqual(note.Note("D4"), error.get_notes()[3])
 def test_ThrowsErrorWithRepBass(self):
     analysis = XMLChoraleAnalysis(TestFilePaths.rep_bass)
     analysis.analyze()
     errors = analysis.get_error_list("RepBassError")
     self.assertEqual(1, len(errors))
 def test_ThrowsErrorWithRange(self):
     analysis = XMLChoraleAnalysis(TestFilePaths.out_of_range)
     analysis.analyze()
     errors = analysis.get_error_list('RangeError')
     self.assertEqual(1, len(errors))
 def test_ErrorHasCorrectProperties(self):
     analysis = XMLChoraleAnalysis(TestFilePaths.out_of_range)
     analysis.analyze()
     error = get_only_element(analysis.get_error_list("RangeError"))
     self.assertEqual(1.0, error.get_measure())
 def test_ThrowsErrorWithTritoneJump(self):
     analysis = XMLChoraleAnalysis(TestFilePaths.tritone_jump)
     analysis.analyze()
     errors = analysis.get_error_list("TritoneJumpError")
     self.assertEqual(1, len(errors))
 def test_ThrowsErrorWithVoiceCrossing(self):
     analysis = XMLChoraleAnalysis(TestFilePaths.voice_crossing)
     analysis.analyze()
     errors = analysis.get_error_list("VoiceCrossingError")
     self.assertEqual(2, len(errors))
 def test_ThrowsErrorWithParallelUnisons(self):
     analysis = XMLChoraleAnalysis(TestFilePaths.parallel_unison)
     analysis.analyze()
     errors = analysis.get_error_list("ParallelUnisonError")
     self.assertEqual(1, len(errors))