def test_detect_input_type(self):
        # Load some input: DbInput
        dbi = DbInput.from_file(DB_SEQUENCES_FILE, {"index": 0})
        # Run it through the preprocessor
        datatype, obj = detect_input_type(dbi)
        # Get the datatype from the type name lists
        datatype2 = input_type_name(type(obj))
        self.assertEqual(datatype, datatype2)

        # Do the same with ChordInput
        ci = ChordInput.from_file(CHORDS_FILE, options={"roman": True})
        datatype, obj = detect_input_type(ci)
        datatype2 = input_type_name(type(obj))
        self.assertEqual(datatype, datatype2)

        # Try some bulk input
        bulk = DbBulkInput.from_file(DB_SEQUENCES_FILE)
        datatype, obj = detect_input_type(bulk, allow_bulk=True)
        datatype2 = input_type_name(type(obj))
        self.assertEqual(datatype, datatype2)

        # Try restricting the allowed type
        datatype, obj = detect_input_type(ci, allowed=["chords"])
        # And this one should get rejected
        self.assertRaises(InputTypeError, detect_input_type, (ci,), {"allowed": "db"})
Exemple #2
0
    def test_detect_input_type(self):
        # Load some input: DbInput
        dbi = DbInput.from_file(DB_SEQUENCES_FILE, {'index': 0})
        # Run it through the preprocessor
        datatype, obj = detect_input_type(dbi)
        # Get the datatype from the type name lists
        datatype2 = input_type_name(type(obj))
        self.assertEqual(datatype, datatype2)

        # Do the same with ChordInput
        ci = ChordInput.from_file(CHORDS_FILE, options={'roman': True})
        datatype, obj = detect_input_type(ci)
        datatype2 = input_type_name(type(obj))
        self.assertEqual(datatype, datatype2)

        # Try some bulk input
        bulk = DbBulkInput.from_file(DB_SEQUENCES_FILE)
        datatype, obj = detect_input_type(bulk, allow_bulk=True)
        datatype2 = input_type_name(type(obj))
        self.assertEqual(datatype, datatype2)

        # Try restricting the allowed type
        datatype, obj = detect_input_type(ci, allowed=['chords'])
        # And this one should get rejected
        self.assertRaises(InputTypeError, detect_input_type, (ci, ),
                          {'allowed': 'db'})
 def test_from_file(self):
     # Just load the file
     ci = ChordInput.from_file(CHORDS_FILE, options={"roman": True})
Exemple #4
0
 def test_from_file(self):
     # Just load the file
     ci = ChordInput.from_file(CHORDS_FILE, options={'roman': True})