def test_can_insert_into_total(test_client, db):
    build_catalog(db, test_client)
    add_artist_expense(test_client)
    pe.normalize_artist()
    pe.normalize_catalog()
    pe.normalize_expense_type()
    pe.insert_into_imported_statements()
    pe.normalize_statement_id()
    pe.move_from_pending_expense_to_total()
    res = db.session.query(ExpenseTotal).all()
    assert len(res) == 4
def test_can_normalize_statement_id(test_client, db):
    build_catalog(db, test_client)
    add_artist_expense(test_client)
    pe.normalize_artist()
    pe.normalize_catalog()
    pe.normalize_expense_type()
    pe.insert_into_imported_statements()
    assert pe.normalize_statement_id() == True
    new_statement_id = db.session.query(ImportedStatement).first().id
    res = db.session.query(ExpensePending).first()
    assert res.imported_statement_id == new_statement_id
def test_can_normalize_artist(test_client, db):
    build_catalog(db, test_client)
    add_artist_expense(test_client)
    res = db.session.query(ExpensePending).first()
    assert res.artist_name == 'Ahmed Ag Kaedy'
    new_artist = db.session.query(Artist).filter(
        Artist.artist_name == 'Ahmed Ag Kaedy').first().id
    pe.normalize_artist()
    res = db.session.query(ExpensePending).filter(
        ExpensePending.artist_id == '1').first()
    assert res.artist_id == new_artist
def test_can_insert_into_imported_statements_table(test_client, db):
    build_catalog(db, test_client)
    add_artist_expense(test_client)
    pe.normalize_artist()
    pe.normalize_catalog()
    pe.normalize_expense_type()
    assert pe.insert_into_imported_statements() == True
    query = db.session.query(ImportedStatement).all()
    assert len(query) != 0
    res = db.session.query(ImportedStatement).first()
    assert res.statement_name == 'expense_artist.csv'
    assert res.transaction_type == 'expense'
    assert res.start_date.strftime("%Y-%m-%d") == '2020-01-01'
    assert res.end_date.strftime("%Y-%m-%d") == '2020-01-01'
示例#5
0
def setup_test1(test_client, db):
    path = os.getcwd() + "/tests/files/test1_catalog.csv"
    f = open(path, 'rb')
    data = {'CSV': f}
    response = test_client.post('/catalog/import-catalog', data=data)
    path = os.getcwd() + "/tests/files/test1_track.csv"
    f = open(path, 'rb')
    data = {'CSV': f}
    response = test_client.post('/catalog/import-track', data=data)
    path = os.getcwd() + "/tests/files/test1_version.csv"
    f = open(path, 'rb')
    data = {'CSV': f}
    response = test_client.post('/catalog/import-version', data=data)
    path = os.getcwd() + "/tests/files/test1_bandcamp.csv"
    data = {'statement_source': 'bandcamp'}
    data['file'] = (path, 'test1_bandcamp.csv')
    response = test_client.post('/income/import-sales',
                                data=data,
                                content_type="multipart/form-data")
    add_order_settings(db)
    path = os.getcwd() + "/tests/files/test1_expense_artist.csv"
    data = {'file': (path, 'test1_expense_artist.csv')}
    response = test_client.post('/expense/import-statement',
                                data=data,
                                content_type="multipart/form-data")
    path = os.getcwd() + "/tests/files/test1_expense_catalog.csv"
    data = {'file': (path, 'test1_expense_catalog.csv')}
    response = test_client.post('/expense/import-statement',
                                data=data,
                                content_type="multipart/form-data")
    pi.normalize_distributor()
    pi.normalize_version()
    pi.normalize_track()
    pi.insert_into_imported_statements()
    pi.normalize_statement_id()
    pi.calculate_adjusted_amount()
    pi.move_from_pending_income_to_total()
    pe.normalize_artist()
    pe.normalize_catalog()
    pe.normalize_expense_type()
    pe.insert_into_imported_statements()
    pe.normalize_statement_id()
    pe.move_from_pending_expense_to_total()