Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def test_export_data_sql(self):
- db_name = test_path + "test_database\\testdata.sqlite"
- data = {
- "projectName": "test_project",
- "projectNumber": "test_project_number",
- "wipDate": "1970-01-01",
- "agreedVariationsNo": 1,
- "budgetVariationsNo": 1,
- "submittedVariationsNo": 1,
- "variationsNoTotal": 3,
- "orderValue": 6293357,
- "agreedVariationsValue": 25450,
- "budgetVariationsValue": 114,
- "submittedVariationsValue": 56787,
- "saleSubtotal": 6375708,
- "reserveAgreed": -254,
- "reserveBudget": -57,
- "reserveSubmitted": -5678,
- "contracharges": -9889,
- "forecastSaleTotal": 6359828,
- "currentCost": 54874,
- "costToComplete": 87899,
- "defectProvision": 68998,
- "forecastCostTotal": 211771,
- "contractContribution": 6148057,
- "bettermentsRisks": 5587,
- "managersView": 147,
- "forecastMarginTotal": 6153791,
- "latestApplication": 6598787,
- "totalCertified": 1144,
- }
- # create database
- export_data_sql(data, db_name)
- # check database is created
- assert os.path.isfile(db_name) is True
- conn = sqlite3.connect(os.path.normpath(db_name))
- cur = conn.cursor()
- cur.execute(
- """
- SELECT * FROM wipdata
- JOIN projectname
- ON wipdata.projectName = projectname.id
- """
- )
- all_rows = cur.fetchall()
- # check data returned is correct
- assert all_rows == [
- (
- "test_project_number",
- 1,
- "1970-01-01",
- 1,
- 1,
- 1,
- 3,
- 6293357,
- 25450,
- 114,
- 56787,
- 6375708,
- -254,
- -57,
- -5678,
- -9889,
- 6359828,
- 54874,
- 87899,
- 68998,
- 211771,
- 6148057,
- 5587,
- 147,
- 6153791,
- 6598787,
- 1144,
- 1,
- "test_project",
- )
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement