def test_create_report(token):
    client = Client(api_key=token, host="localhost:8030/api2", ssl=False)
    number_of_reports = client.list_reports()['count']
    report = client.create_report(title="api created report")
    assert client.list_reports()['count'] == number_of_reports + 1
    report.delete()
    assert client.list_reports()['count'] == number_of_reports
def test_create_report_and_add_chart(token):
    client = Client(api_key=token, host="localhost:8030/api2", ssl=False)
    datasource_pk = client.list_datasources()['results'][0]['pk']
    report = client.create_report('my test')
    original_length = len(report.elements)
    resp = report.add_chart(datasource_pk, ['numitems', 'org'], y='agecat')
    report2 = client.get_report(report._pk)
    report.delete()
    assert len(report2.elements) == original_length + 1
    assert 'Type' in resp