Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.44 KB | None | 0 0
  1. def test_export_data_sql(self):
  2.         db_name = test_path + "test_database\\testdata.sqlite"
  3.         data = {
  4.             "projectName": "test_project",
  5.             "projectNumber": "test_project_number",
  6.             "wipDate": "1970-01-01",
  7.             "agreedVariationsNo": 1,
  8.             "budgetVariationsNo": 1,
  9.             "submittedVariationsNo": 1,
  10.             "variationsNoTotal": 3,
  11.             "orderValue": 6293357,
  12.             "agreedVariationsValue": 25450,
  13.             "budgetVariationsValue": 114,
  14.             "submittedVariationsValue": 56787,
  15.             "saleSubtotal": 6375708,
  16.             "reserveAgreed": -254,
  17.             "reserveBudget": -57,
  18.             "reserveSubmitted": -5678,
  19.             "contracharges": -9889,
  20.             "forecastSaleTotal": 6359828,
  21.             "currentCost": 54874,
  22.             "costToComplete": 87899,
  23.             "defectProvision": 68998,
  24.             "forecastCostTotal": 211771,
  25.             "contractContribution": 6148057,
  26.             "bettermentsRisks": 5587,
  27.             "managersView": 147,
  28.             "forecastMarginTotal": 6153791,
  29.             "latestApplication": 6598787,
  30.             "totalCertified": 1144,
  31.         }
  32.         # create database
  33.         export_data_sql(data, db_name)
  34.         # check database is created
  35.         assert os.path.isfile(db_name) is True
  36.         conn = sqlite3.connect(os.path.normpath(db_name))
  37.         cur = conn.cursor()
  38.         cur.execute(
  39.             """
  40.            SELECT * FROM wipdata
  41.            JOIN projectname
  42.            ON wipdata.projectName = projectname.id
  43.            """
  44.         )
  45.         all_rows = cur.fetchall()
  46.         # check data returned is correct
  47.         assert all_rows == [
  48.             (
  49.                 "test_project_number",
  50.                 1,
  51.                 "1970-01-01",
  52.                 1,
  53.                 1,
  54.                 1,
  55.                 3,
  56.                 6293357,
  57.                 25450,
  58.                 114,
  59.                 56787,
  60.                 6375708,
  61.                 -254,
  62.                 -57,
  63.                 -5678,
  64.                 -9889,
  65.                 6359828,
  66.                 54874,
  67.                 87899,
  68.                 68998,
  69.                 211771,
  70.                 6148057,
  71.                 5587,
  72.                 147,
  73.                 6153791,
  74.                 6598787,
  75.                 1144,
  76.                 1,
  77.                 "test_project",
  78.             )
  79.         ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement