Пример #1
0
def test_add_song():
    """
    TODO:
     - establish test audio filepath
    """

    # instantiate vanilla database object
    db_obj = databaseTool(db_user=DB_USER,
                          db_user_pwd=DB_USER_PWD,
                          db_nm=DB_NM)

    # try to add a song using a bad file path
    with pytest.raises(FileExistsError):
        db_obj.add_song(song_filepath=SONG_BAD_FILEPATH,
                        song_title=SONG_TITLE,
                        artist=SONG_ARTIST,
                        album=SONG_ALBUM)

    # add a song
    new_song_id = db_obj.add_song(song_filepath=SONG_FILEPATH,
                                  song_title=SONG_TITLE,
                                  artist=SONG_ARTIST,
                                  album=SONG_ALBUM)

    # check to see if song is in database
    assert db_obj.song_in_db(new_song_id) == True
Пример #2
0
    def __init__(self,
                 window_type,
                 window_size,
                 window_shift,
                 signature_type,
                 db_user,
                 db_user_pwd,
                 db_nm,
                 db_host='localhost',
                 db_port=5432):
        # store the values that define the class
        self.window_type = window_type
        self.window_size = window_size
        self.window_shift = window_shift
        self.signature_type = signature_type
        self.db_user = db_user
        self.db_user_pwd = db_user_pwd
        self.db_nm = db_nm
        self.db_host = db_host
        self.db_port = db_port

        # audio processing component
        self.audio_proc = processAudio(window_type=window_type,
                                       window_size=window_size,
                                       window_shift=window_shift,
                                       signature_type=signature_type)

        # database communication component
        self.database_con = databaseTool(db_user=db_user,
                                         db_user_pwd=db_user_pwd,
                                         db_nm=db_nm,
                                         db_host=db_host,
                                         db_port=db_port)
Пример #3
0
def test_song_in_db():

    # instantiate vanilla database object
    db_obj = databaseTool(db_user=DB_USER,
                          db_user_pwd=DB_USER_PWD,
                          db_nm=DB_NM)

    # test if existing song ID is in database
    assert db_obj.song_in_db(EXISTING_SONG_ID) != {}
    assert db_obj.song_in_db(EXISTING_SONG_ID).song_id == EXISTING_SONG_ID
Пример #4
0
def test_connect_to_db():
    """
    TODO: 
     - test connection with psycopg2
    """

    # instantiate vanilla database object
    db_obj = databaseTool(db_user=DB_USER,
                          db_user_pwd=DB_USER_PWD,
                          db_nm=DB_NM,
                          connect_to_db=False)

    # test that a connection is made
    assert db_obj.status == psycopg2.extensions.STATUS_READY
Пример #5
0
def test_create_song_features():

    # instantiate vanilla database object
    db_obj = databaseTool(db_user=DB_USER,
                          db_user_pwd=DB_USER_PWD,
                          db_nm=DB_NM)

    # add a song
    new_song_id = db_obj.add_song(song_filepath=SONG_FILEPATH,
                                  song_title=SONG_TITLE,
                                  artist=SONG_ARTIST,
                                  album=SONG_ALBUM)

    # create song features
    song_features = db_obj.create_song_features(new_song_id, test_out=True)
Пример #6
0
def test_change_song_format():

    # instantiate vanilla database object
    db_obj = databaseTool(db_user=DB_USER,
                          db_user_pwd=DB_USER_PWD,
                          db_nm=DB_NM)

    # add a song (mp3)
    new_song_id = db_obj.add_song(song_filepath=SONG_FILEPATH_MP3,
                                  song_title=SONG_TITLE,
                                  artist=SONG_ARTIST,
                                  album=SONG_ALBUM)

    # transform format of song
    db_obj.change_song_format(new_song_id, out_format=OUT_FORMAT)

    # check that the song is now in the OUT_FORMAT
    assert db_obj.song_in_db(new_song_id).song_format == OUT_FORMAT
Пример #7
0
def test_remove_song():

    # instantiate vanilla database object
    db_obj = databaseTool(db_user=DB_USER,
                          db_user_pwd=DB_USER_PWD,
                          db_nm=DB_NM)

    # add a song
    new_song_id = db_obj.add_song(song_filepath=SONG_FILEPATH,
                                  song_title=SONG_TITLE,
                                  artist=SONG_ARTIST,
                                  album=SONG_ALBUM)

    # remove song
    db_obj.remove_song(new_song_id)

    # check that song is no longer in database
    assert db_obj.song_in_db(new_song_id) == False