Exemplo n.º 1
0
 def test_get_release(self):
     with db.engine.connect() as connection:
         recording_msid = data.submit_recording(connection, recording)
         release_msid = data.get_release(connection, recording['release'])
         recording_data = data.load_recording(connection, recording_msid)
         self.assertEqual(release_msid,
                          recording_data['ids']['release_msid'])
Exemplo n.º 2
0
 def test_add_recording_different_cases(self):
     """ Tests that recordings with only case differences get the same MessyBrainz ID.
     """
     with db.engine.connect() as connection:
         msid1 = data.submit_recording(connection, recording)
         msid2 = str(data.get_id_from_recording(connection, recording_diff_case))
         self.assertEqual(msid1, msid2)
Exemplo n.º 3
0
 def test_get_artist_credit(self):
     with db.engine.connect() as connection:
         recording_msid = data.submit_recording(connection, recording)
         artist_msid = data.get_artist_credit(connection,
                                              recording['artist'])
         recording_data = data.load_recording(connection, recording_msid)
         self.assertEqual(artist_msid, recording_data['ids']['artist_msid'])
Exemplo n.º 4
0
def insert_single(connection, recording):
    """ Inserts a single recording into MessyBrainz.

    Args:
        connection: the sqlalchemy db connection to be used to execute queries
        recording: the recording to be inserted
    Returns:
        A dict containing the recording data for inserted recording
    """

    gid = data.get_id_from_recording(connection, recording)
    if not gid:
        gid = data.submit_recording(connection, recording)
    loaded = data.load_recordings_from_msids(connection, [gid])[0]
    return loaded
Exemplo n.º 5
0
    def insert_test_data_with_metadata(self, user_id, neg_score=False):
        """ Insert test data with metadata into the database """

        with msb_db.engine.connect() as connection:
            msid = submit_recording(connection, self.sample_recording)
            artists = load_recordings_from_msids(connection, [msid])
            self.saved_artist_msid = artists[0]["ids"]["artist_msid"]

        self.sample_feedback_with_metadata[0]["recording_msid"] = msid

        query = """INSERT INTO listen_mbid_mapping
                               (id, recording_mbid, release_mbid, artist_credit_id, artist_mbids,
                                artist_credit_name, recording_name, match_type)
                        VALUES (1,
                                '076255b4-1575-11ec-ac84-135bf6a670e3',
                                '1fd178b4-1575-11ec-b98a-d72392cd8c97',
                                65, 
                                '{6a221fda-2200-11ec-ac7d-dfa16a57158f}'::UUID[],
                                'artist name', 'recording name', 'exact_match')"""

        with ts.engine.connect() as connection:
            connection.execute(sqlalchemy.text(query))

        query = """INSERT INTO listen_join_listen_mbid_mapping
                               (recording_msid, listen_mbid_mapping)
                        VALUES ('%s', 1)""" % msid

        with ts.engine.connect() as connection:
            connection.execute(sqlalchemy.text(query))

        for fb in self.sample_feedback_with_metadata:
            db_feedback.insert(
                Feedback(user_id=user_id,
                         recording_msid=fb["recording_msid"],
                         score=fb["score"]))

        return len(self.sample_feedback_with_metadata)
Exemplo n.º 6
0
 def test_load_recordings_from_msids(self):
     with db.engine.connect() as connection:
         recording_msid = data.submit_recording(connection, recording)
         result = data.load_recordings_from_msids(connection, [recording_msid])[0]
         self.assertDictEqual(result['payload'], recording)
Exemplo n.º 7
0
 def test_submit_recording(self):
     with db.engine.connect() as connection:
         recording_msid = data.submit_recording(connection, recording)
         self.assertEqual(recording_msid, str(data.get_id_from_recording(connection, recording)))
Exemplo n.º 8
0
def insert_single(connection, recording):
    gid = data.get_id_from_recording(connection, recording)
    if not gid:
        gid = data.submit_recording(connection, recording)
    loaded = data.load_recording(connection, gid)
    return loaded