Ejemplo n.º 1
0
def test_get_label(refresh_db_once, db_connection_sqlalchemy):
    df_test = pd.DataFrame()
    df_test['label_id'] = [3]
    df_test['input_data_id'] = [3]
    df_test['in_progress'] = [False]
    df_test['user_complete'] = [False]
    df_test['needs_improvement'] = [False]
    df_test['admin_complete'] = [False]
    df_test['paid'] = [False]
    df_test['user_comment'] = [None]
    df_test['admin_comment'] = [None]

    engine = db_connection_sqlalchemy
    df = sql_queries.get_label(engine,
                               user_id=1,
                               label_task_id=1,
                               input_data_id=3)

    assert_series_equal(df['label_id'], df_test['label_id'])
    assert_series_equal(df['input_data_id'], df_test['input_data_id'])
    assert_series_equal(df['in_progress'], df_test['in_progress'])
    assert_series_equal(df['user_complete'], df_test['user_complete'])
    assert_series_equal(df['needs_improvement'], df_test['needs_improvement'])
    assert_series_equal(df['admin_complete'], df_test['admin_complete'])
    assert_series_equal(df['paid'], df_test['paid'])
    assert_series_equal(df['user_comment'], df_test['user_comment'])
    assert_series_equal(df['admin_comment'], df_test['admin_comment'])
Ejemplo n.º 2
0
def test_update_label_status_admin_comment(refresh_db_every_time, db_connection_sqlalchemy):
    engine = db_connection_sqlalchemy
    label_id = sql_queries.update_label_status(engine, label_id=3, admin_comment='abcdefg')

    assert label_id == 3

    df = sql_queries.get_label(engine, user_id=1, label_task_id=1, input_data_id=3)

    assert df['admin_comment'][0] == 'abcdefg'
Ejemplo n.º 3
0
def test_update_label_status_do_nothing_if_no_statuses_specified(refresh_db_every_time, db_connection_sqlalchemy):
    engine = db_connection_sqlalchemy
    label_id = sql_queries.update_label_status(engine, label_id=3)

    assert label_id is None

    df = sql_queries.get_label(engine, user_id=1, label_task_id=1, input_data_id=3)

    assert not df['user_complete'][0]
    assert not df['needs_improvement'][0]
    assert not df['admin_complete'][0]
    assert not df['paid'][0]
Ejemplo n.º 4
0
def test_update_label_status_admin_complete_and_paid(refresh_db_every_time, db_connection_sqlalchemy):
    engine = db_connection_sqlalchemy
    label_id = sql_queries.update_label_status(engine, label_id=3, admin_complete=True, paid=True)

    assert label_id == 3

    df = sql_queries.get_label(engine, user_id=1, label_task_id=1, input_data_id=3)

    assert not df['user_complete'][0]
    assert not df['needs_improvement'][0]
    assert df['admin_complete'][0]
    assert df['paid'][0]