def test_all_data_in_db(): production_code.drop_table_on_new_api_call(cursor) production_code.create_table(cursor) production_code.insert_data_into_db(cursor, production_code.get_api_data()) production_code.insert_data_into_db(cursor, production_code.data_from_stack_overflow()) result = cursor.execute('SELECT * FROM api_jobs') jobs = production_code.get_api_data() for (job, row) in zip(jobs, result): assert job['id'] == row[0] assert job['company'] == row[1] assert job['company_logo'] == row[2] assert job['company_url'] == row[3] assert job['created_at'] == row[4] assert job['description'] == row[5] assert job['how_to_apply'] == row[6] assert job['location'] == row[7] assert job['title'] == row[8] assert job['type'] == row[9] assert job['url'] == row[10]
def test_bad_data_input(): job_list = [{ "company_logo": 'test', "company_url": "test", "created_at": "test", "description": "test", "how_to_apply": "test", "id": "test", "location": "test", "title": "test", "type": "test", "url": "test" }] result = production_code.insert_data_into_db(cursor, job_list) assert result == "failed"
def test_data_from_stack_overflow(): production_code.insert_data_into_db(cursor, production_code.data_from_stack_overflow()) result = cursor.execute('SELECT company FROM api_jobs WHERE company = "X-Team"') assert result.fetchone()[0] == "X-Team"
def test_known_result_in_db(): production_code.insert_data_into_db(cursor, production_code.get_api_data()) result = cursor.execute('SELECT company FROM api_jobs WHERE company = "DevsData"') assert result.fetchone()[0] == "DevsData"