From 615147e43647dbc6260118f25e7bceaa0c341334 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 2 Mar 2020 18:27:21 -0500 Subject: [PATCH 1/9] Move code structure --- bloclink/apps/bis/features/environment.py | 28 +++++++++++ .../apps/bis/features/steps/submitAnswers.py | 12 ++--- .../apps/bis/features/steps/submitBuilding.py | 14 +++--- .../apps/bis/features/submitAnswers.feature | 46 ++++++++----------- 4 files changed, 60 insertions(+), 40 deletions(-) diff --git a/bloclink/apps/bis/features/environment.py b/bloclink/apps/bis/features/environment.py index 28f4199..e116104 100644 --- a/bloclink/apps/bis/features/environment.py +++ b/bloclink/apps/bis/features/environment.py @@ -1,10 +1,38 @@ +from behave import fixture, use_fixture from decouple import config import os +import json import psycopg2 from psycopg2 import sql from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT +@fixture +def load_fuel_types(context): + context.questionId = context.questions['fuelTypes']['questionId'] + +@fixture +def load_submit_answers(context): + with open('features/data/submitAnswers.json', 'r') as outfile: + data = json.load(outfile)[0] + context.surveyId = data['surveyId'] + context.buildingId = data['buildingId'] + context.userId = data['userId'] + context.questions = data['questions'] + print(context.surveyId) + print(context.buildingId) + print(context.userId) + print(context.questions) + +def before_tag(context, tag): + if tag == "fixture.load.fuelTypes": + use_fixture(load_fuel_types, context) + +def before_feature(context, feature): + feature_name = feature.filename.split('/')[-1] + if feature_name == 'submitAnswers.feature': + use_fixture(load_submit_answers, context) + def before_all(context): prefix = 'http://' if config('ENVIRONMENT') == 'local' else 'https://' basePath = prefix + config('DOMAIN') + '/buildings/bis/' diff --git a/bloclink/apps/bis/features/steps/submitAnswers.py b/bloclink/apps/bis/features/steps/submitAnswers.py index 766fad2..a9b3dc0 100644 --- a/bloclink/apps/bis/features/steps/submitAnswers.py +++ b/bloclink/apps/bis/features/steps/submitAnswers.py @@ -3,14 +3,14 @@ import requests import json -@given('I input {questionId} {answerId} {surveyId} {buildingId} {userId} as answers') -def step_impl(context, questionId, answerId, surveyId, buildingId, userId): +@given('I input as answers') +def step_impl(context, answerId): context.inputs = { - 'questionId': questionId.split(','), + 'surveyId': context.surveyId, + 'buildingId': context.buildingId, + 'userId': context.userId, + 'questionId': context.questionId.split(','), 'answerId': answerId.split(','), - 'surveyId': surveyId, - 'buildingId': buildingId, - 'userId': userId, } @when('I click on continue button') diff --git a/bloclink/apps/bis/features/steps/submitBuilding.py b/bloclink/apps/bis/features/steps/submitBuilding.py index a7ad6a6..cb8bcc6 100644 --- a/bloclink/apps/bis/features/steps/submitBuilding.py +++ b/bloclink/apps/bis/features/steps/submitBuilding.py @@ -11,11 +11,11 @@ def step_impl(context, address): def step_impl(context): context.response = requests.put(url=context.endpoints['submitBuilding'], json={'address': context.address}, headers={'Content-Type': 'PUT'}) -@then('result page should include code {code}') -def step_impl(context, code): - assert code == str(context.response.status_code) - -@then('result page should include success as {success}') -def step_impl(context, success): - assert success == str(json.loads(context.response.text)['success']) +@then('it will to the next question') +def step_impl(context, go): + if go == True: + assert str(context.response.status_code) == 200 + else: + assert str(context.response.status_code) != 200 + # assert context.success == str(json.loads(context.response.text)['success']) diff --git a/bloclink/apps/bis/features/submitAnswers.feature b/bloclink/apps/bis/features/submitAnswers.feature index a4edfad..634af6a 100644 --- a/bloclink/apps/bis/features/submitAnswers.feature +++ b/bloclink/apps/bis/features/submitAnswers.feature @@ -1,44 +1,36 @@ Feature: A building owner can submit answers - @newyorkcity + @newyorkcity @fixture.load.fuelTypes Scenario Outline: Fuel types - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 1 | 3 | 1 | 152699 | 1594 | 200 | True | + | answerId | go | + | 9 | True | - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 1 | 3 | 0 | 152699 | 1594 | 400 | False | - | 1 | 3 | 100 | 152699 | 1594 | 400 | False | - - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 1 | 3 | 1 | 0 | 1594 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 29 | False | + | -9 | False | + | 99 | False | - @newyorkcity + @newyorkcity @fixture.load.heatDistribution Scenario Outline: Heat distribution - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 2 | 9 | 1 | 152699 | 1594 | 200 | True | + | answerId | go | + | 9 | True | Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 2 | 9 | 0 | 152699 | 1594 | 400 | False | - | 2 | 9 | 100 | 152699 | 1594 | 400 | False | - - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 2 | 9 | 1 | 0 | 1594 | 400 | False | + | answerId | go | + | 9 | False | + | 9 | False | + | 9 | False | @newyorkcity Scenario Outline: Heating system age -- GitLab From d8494d3a727e4d2b5db8e8a72f832a639e038b64 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 3 Mar 2020 13:25:49 -0500 Subject: [PATCH 2/9] restructured the json and use scenario outline --- bloclink/apps/bis/features/environment.py | 16 +- .../apps/bis/features/steps/submitAnswers.py | 2 +- .../apps/bis/features/steps/submitBuilding.py | 3 +- .../apps/bis/features/submitAnswers.feature | 274 +++++++----------- 4 files changed, 110 insertions(+), 185 deletions(-) diff --git a/bloclink/apps/bis/features/environment.py b/bloclink/apps/bis/features/environment.py index e116104..68ed013 100644 --- a/bloclink/apps/bis/features/environment.py +++ b/bloclink/apps/bis/features/environment.py @@ -8,8 +8,8 @@ from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT @fixture -def load_fuel_types(context): - context.questionId = context.questions['fuelTypes']['questionId'] +def load_question(context): + context.questionId = context.questions[context.city][context.question] @fixture def load_submit_answers(context): @@ -19,14 +19,14 @@ def load_submit_answers(context): context.buildingId = data['buildingId'] context.userId = data['userId'] context.questions = data['questions'] - print(context.surveyId) - print(context.buildingId) - print(context.userId) - print(context.questions) def before_tag(context, tag): - if tag == "fixture.load.fuelTypes": - use_fixture(load_fuel_types, context) + if tag in ['newyorkcity', 'oakland']: + context.city = tag + + if tag.startswith("fixture.load."): + context.question = tag.replace("fixture.load.", "") + use_fixture(load_question, context) def before_feature(context, feature): feature_name = feature.filename.split('/')[-1] diff --git a/bloclink/apps/bis/features/steps/submitAnswers.py b/bloclink/apps/bis/features/steps/submitAnswers.py index a9b3dc0..a83eaf6 100644 --- a/bloclink/apps/bis/features/steps/submitAnswers.py +++ b/bloclink/apps/bis/features/steps/submitAnswers.py @@ -3,7 +3,7 @@ import requests import json -@given('I input as answers') +@given('I input {answerId} as answers') def step_impl(context, answerId): context.inputs = { 'surveyId': context.surveyId, diff --git a/bloclink/apps/bis/features/steps/submitBuilding.py b/bloclink/apps/bis/features/steps/submitBuilding.py index cb8bcc6..c4e5266 100644 --- a/bloclink/apps/bis/features/steps/submitBuilding.py +++ b/bloclink/apps/bis/features/steps/submitBuilding.py @@ -11,11 +11,10 @@ def step_impl(context, address): def step_impl(context): context.response = requests.put(url=context.endpoints['submitBuilding'], json={'address': context.address}, headers={'Content-Type': 'PUT'}) -@then('it will to the next question') +@then('it will {go} to the next question') def step_impl(context, go): if go == True: assert str(context.response.status_code) == 200 else: assert str(context.response.status_code) != 200 - # assert context.success == str(json.loads(context.response.text)['success']) diff --git a/bloclink/apps/bis/features/submitAnswers.feature b/bloclink/apps/bis/features/submitAnswers.feature index 634af6a..af17af5 100644 --- a/bloclink/apps/bis/features/submitAnswers.feature +++ b/bloclink/apps/bis/features/submitAnswers.feature @@ -12,7 +12,7 @@ Feature: A building owner can submit answers Examples: Invalid answers | answerId | go | - | 29 | False | + | 29 | True | | -9 | False | | 99 | False | @@ -26,248 +26,174 @@ Feature: A building owner can submit answers | answerId | go | | 9 | True | - Examples: Survey not exist + Examples: Invalid answers | answerId | go | - | 9 | False | - | 9 | False | - | 9 | False | + | 39 | False | - @newyorkcity + @newyorkcity @fixture.load.heatingSystemAge Scenario Outline: Heating system age - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 3 | 14 | 1 | 152699 | 1594 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 3 | 14 | 0 | 152699 | 1594 | 400 | True | - | 3 | 14 | 100 | 152699 | 1594 | 400 | True | + | answerId | go | + | 14 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 3 | 14 | 1 | 0 | 1594 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 109 | False | - @newyorkcity + @newyorkcity @fixture.load.heatingSystemReplacementPlan Scenario Outline: Heating system replacement plan - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 4 | 18 | 1 | 152699 | 1594 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 4 | 18 | 0 | 152699 | 1594 | 400 | False | - | 4 | 18 | 100 | 152699 | 1594 | 400 | False | + | answerId | go | + | 18 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 4 | 18 | 1 | 0 | 1594 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 109 | False | - @newyorkcity + @newyorkcity @fixture.load.buildingType Scenario Outline: Building type - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 6 | 21 | 1 | 152699 | 1594 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 6 | 21 | 0 | 152699 | 1594 | 400 | False | - | 6 | 21 | 100 | 152699 | 1594 | 400 | False | + | answerId | go | + | 21 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 6 | 21 | 1 | 0 | 1594 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 199 | False | - @newyorkcity + @newyorkcity @fixture.load.utilityBills Scenario Outline: Utility bills - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 5,8 | 24,25 | 1 | 152699 | 1594 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 5,8 | 24,25 | 0 | 152699 | 1594 | 400 | False | - | 5,8 | 24,25 | 100 | 152699 | 1594 | 400 | False | + | answerId | go | + | 24,25 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 5,8 | 24,25 | 1 | 0 | 1594 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 199,200 | False | - @newyorkcity + @newyorkcity @fixture.load.comfortIssues Scenario Outline: Comfort issues - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 7 | 27,28,29 | 1 | 152699 | 1594 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 7 | 27,28,29 | 0 | 152699 | 1594 | 400 | False | - | 7 | 27,28,29 | 100 | 152699 | 1594 | 400 | False | + | answerId | go | + | 27,28,29 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 7 | 27,28,29 | 1 | 0 | 1594 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 199,200,201 | False | - @newyorkcity + @newyorkcity @fixture.load.financeInterest Scenario Outline: Finance interest - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 9 | 1 | 1 | 152699 | 1594 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 9 | 1 | 0 | 152699 | 1594 | 400 | False | - | 9 | 1 | 100 | 152699 | 1594 | 400 | False | + | answerId | go | + | 1 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 9 | 1 | 1 | 0 | 1594 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 99 | False | - @oakland + @oakland @fixture.load.buildingType Scenario Outline: Building type - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 12,13 | 34,40 | 2 | 1189746 | 1601 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 12,13 | 34,40 | 0 | 1189746 | 1601 | 400 | False | - | 12,13 | 34,40 | 100 | 1189746 | 1601 | 400 | False | + | answerId | go | + | 34,40 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 12,13 | 34,40 | 2 | 0 | 1601 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 99,100 | False | - @oakland + @oakland @fixture.load.buildingNeeds Scenario Outline: Building needs - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 14 | 76,77,78 | 2 | 1189746 | 1601 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 14 | 76,77,78 | 0 | 1189746 | 1601 | 400 | False | - | 14 | 76,77,78 | 100 | 1189746 | 1601 | 400 | False | + | answerId | go | + | 76,77,78 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 14 | 76,77,78 | 2 | 0 | 1601 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 199,200,201 | False | - @oakland - Scenario Outline: Building chanllenges - Given I input as answers + @oakland @fixture.load.buildingChallenges + Scenario Outline: Building challenges + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 15 | 87,88,89 | 2 | 1189746 | 1601 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 15 | 87,88,89 | 0 | 1189746 | 1601 | 400 | False | - | 15 | 87,88,89 | 100 | 1189746 | 1601 | 400 | False | + | answerId | go | + | 87,88,89 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 15 | 87,88,89 | 2 | 0 | 1601 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 199,200,201 | False | - @oakland + @oakland @fixture.load.heatingSystem Scenario Outline: Heating system - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 16 | 101 | 2 | 1189746 | 1601 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 16 | 101 | 0 | 1189746 | 1601 | 400 | False | - | 16 | 101 | 100 | 1189746 | 1601 | 400 | False | + | answerId | go | + | 101 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 16 | 101 | 2 | 0 | 1601 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 201 | False | - @oakland + @oakland @fixture.load.EnergyImprovementPastYears Scenario Outline: Energy improvements past years - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34 | 2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | 2 | 1189746 | 1601 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34 | 2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | 0 | 1189746 | 1601 | 400 | False | - | 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34 | 2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | 100 | 1189746 | 1601 | 400 | False | + | answerId | go | + | 2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34 | 2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | 2 | 0 | 1601 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10 | False | - @oakland + @oakland @fixture.load.EnergyImprovementNextYears Scenario Outline: Energy improvements next years - Given I input as answers + Given I input as answers When I click on continue button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid answers - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51 | 2,2,1,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | 2 | 1189746 | 1601 | 200 | True | - - Examples: Survey not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51 | 2,2,1,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | 0 | 1189746 | 1601 | 400 | False | - | 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51 | 2,2,1,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | 100 | 1189746 | 1601 | 400 | False | + | answerId | go | + | 2,2,1,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | True | - Examples: Building not exist - | questionId | answerId | surveyId | buildingId | userId | code | success | - | 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51 | 2,2,1,2,2,2,2,2,2,2,1,1,2,2,2,2,2 | 2 | 0 | 1601 | 400 | False | + Examples: Invalid answers + | answerId | go | + | 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10 | False | -- GitLab From 32458b3333417c7fff438ba7f6165b48da4c204f Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 3 Mar 2020 14:51:11 -0500 Subject: [PATCH 3/9] Refactor all other features --- .../apps/bis/features/data/submitAnswers.json | 27 ++++++++++++ .../apps/bis/features/data/submitContact.json | 6 +++ .../features/data/submitQuestionnaire.json | 6 +++ bloclink/apps/bis/features/environment.py | 24 ++++++++++- .../bis/features/steps/submitQuestionnaire.py | 17 +++++--- .../apps/bis/features/submitAnswers.feature | 28 ++++++------ .../apps/bis/features/submitBuilding.feature | 27 ++++++------ .../apps/bis/features/submitContact.feature | 43 ++++++++----------- .../bis/features/submitQuestionnaire.feature | 23 +++++----- 9 files changed, 126 insertions(+), 75 deletions(-) create mode 100644 bloclink/apps/bis/features/data/submitAnswers.json create mode 100644 bloclink/apps/bis/features/data/submitContact.json create mode 100644 bloclink/apps/bis/features/data/submitQuestionnaire.json diff --git a/bloclink/apps/bis/features/data/submitAnswers.json b/bloclink/apps/bis/features/data/submitAnswers.json new file mode 100644 index 0000000..2108a3c --- /dev/null +++ b/bloclink/apps/bis/features/data/submitAnswers.json @@ -0,0 +1,27 @@ +[ + { + "surveyId": 1, + "buildingId": 152699, + "userId": 1594, + "questions": { + "newyorkcity": { + "fuelTypes": "1", + "heatDistribution": "2", + "heatingSystemAge": "3", + "heatingSystemReplacementPlan": "4", + "buildingType": "6", + "utilityBills": "5,8", + "comfortIssues": "7", + "financeInterest": "9" + }, + "oakland": { + "buildingType": "12,13", + "buildingNeeds": "14", + "buildingChallenges": "15", + "heatingSystem": "16", + "EnergyImprovementPastYears": "18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34", + "EnergyImprovementNextYears": "35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51" + } + } + } +] diff --git a/bloclink/apps/bis/features/data/submitContact.json b/bloclink/apps/bis/features/data/submitContact.json new file mode 100644 index 0000000..6695124 --- /dev/null +++ b/bloclink/apps/bis/features/data/submitContact.json @@ -0,0 +1,6 @@ +[ + { + "buildingId": 152699, + "userId": 1594 + } +] diff --git a/bloclink/apps/bis/features/data/submitQuestionnaire.json b/bloclink/apps/bis/features/data/submitQuestionnaire.json new file mode 100644 index 0000000..6695124 --- /dev/null +++ b/bloclink/apps/bis/features/data/submitQuestionnaire.json @@ -0,0 +1,6 @@ +[ + { + "buildingId": 152699, + "userId": 1594 + } +] diff --git a/bloclink/apps/bis/features/environment.py b/bloclink/apps/bis/features/environment.py index 68ed013..96b91a8 100644 --- a/bloclink/apps/bis/features/environment.py +++ b/bloclink/apps/bis/features/environment.py @@ -20,12 +20,26 @@ def load_submit_answers(context): context.userId = data['userId'] context.questions = data['questions'] +@fixture +def load_submit_contact(context): + with open('features/data/submitContact.json', 'r') as outfile: + data = json.load(outfile)[0] + context.buildingId = data['buildingId'] + context.userId = data['userId'] + +@fixture +def load_submit_questionnaire(context): + with open('features/data/submitQuestionnaire.json', 'r') as outfile: + data = json.load(outfile)[0] + context.buildingId = data['buildingId'] + context.userId = data['userId'] + def before_tag(context, tag): if tag in ['newyorkcity', 'oakland']: context.city = tag - if tag.startswith("fixture.load."): - context.question = tag.replace("fixture.load.", "") + if tag.startswith("fixture.load.question."): + context.question = tag.replace("fixture.load.question.", "") use_fixture(load_question, context) def before_feature(context, feature): @@ -33,6 +47,12 @@ def before_feature(context, feature): if feature_name == 'submitAnswers.feature': use_fixture(load_submit_answers, context) + if feature_name == 'submitContact.feature': + use_fixture(load_submit_contact, context) + + if feature_name == 'submitQuestionnaire.feature': + use_fixture(load_submit_questionnaire, context) + def before_all(context): prefix = 'http://' if config('ENVIRONMENT') == 'local' else 'https://' basePath = prefix + config('DOMAIN') + '/buildings/bis/' diff --git a/bloclink/apps/bis/features/steps/submitQuestionnaire.py b/bloclink/apps/bis/features/steps/submitQuestionnaire.py index 3dddaec..1294d4b 100644 --- a/bloclink/apps/bis/features/steps/submitQuestionnaire.py +++ b/bloclink/apps/bis/features/steps/submitQuestionnaire.py @@ -3,19 +3,26 @@ import requests import json -@given('I have {firstName} {lastName} {email} {phone} {surveyId} {buildingId} {buildingQualified} {userId}') -def step_impl(context, firstName, lastName, email, phone, surveyId, buildingId, buildingQualified, userId): +@given('I have answered all the questions') +def step_impl(context, firstName, lastName, email, phone, surveyId, buildingQualified): context.inputs = { 'firstName': firstName, 'lastName': lastName, 'email': email, 'phone': phone, - 'surveyId': surveyId, - 'buildingId': buildingId, + 'surveyId': context.surveyId, + 'buildingId': context.buildingId, 'buildingQualified': bool(buildingQualified), - 'userId': userId, + 'userId': context.userId, } @when('I submit the questionnaire') def step_impl(context): context.response = requests.put(url=context.endpoints['submitQuestionnaire'], json=context.inputs, headers={'Content-Type': 'PUT'}) + +@then('it will {go} to thanks page') +def step_impl(context, go): + if go == True: + assert str(context.response.status_code) == 200 + else: + assert str(context.response.status_code) != 200 diff --git a/bloclink/apps/bis/features/submitAnswers.feature b/bloclink/apps/bis/features/submitAnswers.feature index af17af5..bdbe063 100644 --- a/bloclink/apps/bis/features/submitAnswers.feature +++ b/bloclink/apps/bis/features/submitAnswers.feature @@ -1,6 +1,6 @@ Feature: A building owner can submit answers - @newyorkcity @fixture.load.fuelTypes + @newyorkcity @fixture.load.question.fuelTypes Scenario Outline: Fuel types Given I input as answers When I click on continue button @@ -16,7 +16,7 @@ Feature: A building owner can submit answers | -9 | False | | 99 | False | - @newyorkcity @fixture.load.heatDistribution + @newyorkcity @fixture.load.question.heatDistribution Scenario Outline: Heat distribution Given I input as answers When I click on continue button @@ -30,7 +30,7 @@ Feature: A building owner can submit answers | answerId | go | | 39 | False | - @newyorkcity @fixture.load.heatingSystemAge + @newyorkcity @fixture.load.question.heatingSystemAge Scenario Outline: Heating system age Given I input as answers When I click on continue button @@ -44,7 +44,7 @@ Feature: A building owner can submit answers | answerId | go | | 109 | False | - @newyorkcity @fixture.load.heatingSystemReplacementPlan + @newyorkcity @fixture.load.question.heatingSystemReplacementPlan Scenario Outline: Heating system replacement plan Given I input as answers When I click on continue button @@ -58,7 +58,7 @@ Feature: A building owner can submit answers | answerId | go | | 109 | False | - @newyorkcity @fixture.load.buildingType + @newyorkcity @fixture.load.question.buildingType Scenario Outline: Building type Given I input as answers When I click on continue button @@ -72,7 +72,7 @@ Feature: A building owner can submit answers | answerId | go | | 199 | False | - @newyorkcity @fixture.load.utilityBills + @newyorkcity @fixture.load.question.utilityBills Scenario Outline: Utility bills Given I input as answers When I click on continue button @@ -86,7 +86,7 @@ Feature: A building owner can submit answers | answerId | go | | 199,200 | False | - @newyorkcity @fixture.load.comfortIssues + @newyorkcity @fixture.load.question.comfortIssues Scenario Outline: Comfort issues Given I input as answers When I click on continue button @@ -100,7 +100,7 @@ Feature: A building owner can submit answers | answerId | go | | 199,200,201 | False | - @newyorkcity @fixture.load.financeInterest + @newyorkcity @fixture.load.question.financeInterest Scenario Outline: Finance interest Given I input as answers When I click on continue button @@ -114,7 +114,7 @@ Feature: A building owner can submit answers | answerId | go | | 99 | False | - @oakland @fixture.load.buildingType + @oakland @fixture.load.question.buildingType Scenario Outline: Building type Given I input as answers When I click on continue button @@ -128,7 +128,7 @@ Feature: A building owner can submit answers | answerId | go | | 99,100 | False | - @oakland @fixture.load.buildingNeeds + @oakland @fixture.load.question.buildingNeeds Scenario Outline: Building needs Given I input as answers When I click on continue button @@ -142,7 +142,7 @@ Feature: A building owner can submit answers | answerId | go | | 199,200,201 | False | - @oakland @fixture.load.buildingChallenges + @oakland @fixture.load.question.buildingChallenges Scenario Outline: Building challenges Given I input as answers When I click on continue button @@ -156,7 +156,7 @@ Feature: A building owner can submit answers | answerId | go | | 199,200,201 | False | - @oakland @fixture.load.heatingSystem + @oakland @fixture.load.question.heatingSystem Scenario Outline: Heating system Given I input as answers When I click on continue button @@ -170,7 +170,7 @@ Feature: A building owner can submit answers | answerId | go | | 201 | False | - @oakland @fixture.load.EnergyImprovementPastYears + @oakland @fixture.load.question.EnergyImprovementPastYears Scenario Outline: Energy improvements past years Given I input as answers When I click on continue button @@ -184,7 +184,7 @@ Feature: A building owner can submit answers | answerId | go | | 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10 | False | - @oakland @fixture.load.EnergyImprovementNextYears + @oakland @fixture.load.question.EnergyImprovementNextYears Scenario Outline: Energy improvements next years Given I input as answers When I click on continue button diff --git a/bloclink/apps/bis/features/submitBuilding.feature b/bloclink/apps/bis/features/submitBuilding.feature index b7545e8..e112e73 100644 --- a/bloclink/apps/bis/features/submitBuilding.feature +++ b/bloclink/apps/bis/features/submitBuilding.feature @@ -3,24 +3,21 @@ Feature: Building search Scenario Outline: Search for a building Given I input a building
When I click on search button - Then result page should include code - And result page should include success as + Then it will to the next question Examples: Valid building - | address | code | success | - | 489 Hart Street, Brooklyn, New York 11221, United States | 200 | True | - | 81 Prospect Street, Staten Island, New York 10304, United States | 200 | True | - | Oakland California Temple, 4770 Lincoln Ave, Oakland, California 94602, United States | 200 | True | + | address | go | + | 489 Hart Street, Brooklyn, New York 11221, United States | True | + | 81 Prospect Street, Staten Island, New York 10304, United States | True | + | Oakland California Temple, 4770 Lincoln Ave, Oakland, California 94602, United States | True | Examples: Invalid building - | address | code | success | - | Staten Island, New York, New York, United States | 400 | False | - | New York, New York, United States | 400 | False | - | New York, New York 10453, United States | 400 | False | - | East New York, Brooklyn, New York, New York 11208, United States | 400 | False | + | address | go | + | Staten Island, New York, New York, United States | False | + | New York, New York, United States | False | + | New York, New York 10453, United States | False | + | East New York, Brooklyn, New York, New York 11208, United States | False | + | New Jersey Motor Vehicle Commission, 481 US Route 46 W, Wayne, New Jersey 07470, United States | False | + | 60 East Jamaica Avenue, Valley Stream, New York 11580, United States | False | - Examples: Uncovered building - | address | code | success | - | New Jersey Motor Vehicle Commission, 481 US Route 46 W, Wayne, New Jersey 07470, United States | 400 | False | - | 60 East Jamaica Avenue, Valley Stream, New York 11580, United States | 400 | False | diff --git a/bloclink/apps/bis/features/submitContact.feature b/bloclink/apps/bis/features/submitContact.feature index da4c020..26d6da6 100644 --- a/bloclink/apps/bis/features/submitContact.feature +++ b/bloclink/apps/bis/features/submitContact.feature @@ -1,32 +1,23 @@ Feature: A building owner can submit contact information + @fixture.load.contact Scenario Outline: Contact information form - Given I input - When I submit contact form - Then result page should include code - And result page should include success as + Given I input + When I click on continue button + Then it will to the next question Examples: Valid contact information - | firstName | lastName | email | phoneNumber | buildingId | userId | code | success | - | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | 152699 | 1594 | 200 | True | - | David | Beckham | David@beckham.com | +41-347-123-4567 | 152699 | 1594 | 200 | True | - | Tony | Ferguson | tony.ferguson@ufc.com | '' | 152699 | 1594 | 200 | True | + | firstName | lastName | email | phoneNumber | go | + | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | True | + | David | Beckham | David@beckham.com | +41-347-123-4567 | True | + | Tony | Ferguson | tony.ferguson@ufc.com | '' | True | - Examples: Incomplete contact information - | firstName | lastName | email | phoneNumber | buildingId | userId | code | success | - | Tony | '' | tony.ferguson@ufc.com | 347-123-4567 | 152699 | 1594 | 400 | False | - | '' | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | 152699 | 1594 | 400 | False | - | Tony | Ferguson | '' | 347-123-4567 | 152699 | 1594 | 400 | False | - - Examples: Invalid Email address - | firstName | lastName | email | phoneNumber | buildingId | userId | code | success | - | Tony | Ferguson | +0tony.ferguson@ufc.com | 347-123-4567 | 152699 | 1594 | 400 | False | - | Tony | Ferguson | tony.ferguson@ufc | 347-123-4567 | 152699 | 1594 | 400 | False | - - Examples: Invalid phone number - | firstName | lastName | email | phoneNumber | buildingId | userId | code | success | - | Tony | Ferguson | tony.ferguson@ufc.com | Phone# | 152699 | 1594 | 400 | False | - - Examples: Non-exist buildings - | firstName | lastName | email | phoneNumber | buildingId | userId | code | success | - | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | 0 | 1594 | 400 | False | + Examples: Invalid contact information + | firstName | lastName | email | phoneNumber | success | + | Tony | '' | tony.ferguson@ufc.com | 347-123-4567 | False | + | '' | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | False | + | Tony | Ferguson | '' | 347-123-4567 | False | + | Tony | Ferguson | +0tony.ferguson@ufc.com | 347-123-4567 | False | + | Tony | Ferguson | tony.ferguson@ufc | 347-123-4567 | False | + | Tony | Ferguson | tony.ferguson@ufc.com | Phone# | False | + | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | False | diff --git a/bloclink/apps/bis/features/submitQuestionnaire.feature b/bloclink/apps/bis/features/submitQuestionnaire.feature index 2900e5c..9a27854 100644 --- a/bloclink/apps/bis/features/submitQuestionnaire.feature +++ b/bloclink/apps/bis/features/submitQuestionnaire.feature @@ -1,21 +1,18 @@ Feature: A building owner can submit questionnaire + @newyorkcity Scenario Outline: Review and submit questionnaire - Given I have + Given I have answered all the questions When I submit the questionnaire - Then result page should include code - And result page should include success as + Then it will to thanks page Examples: Valid questionnaire - | firstName | lastName | email | phone | surveyId | buildingId | buildingQualified | userId | code | success | - | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | 1 | 152699 | True | 1594 | 200 | True | - | Tony | Ferguson | tony.ferguson@ufc.com | '' | 1 | 152699 | True | 1594 | 200 | True | + | firstName | lastName | email | phone | surveyId | buildingQualified | go | + | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | 1 | True | True | + | Tony | Ferguson | tony.ferguson@ufc.com | '' | 1 | True | True | - Examples: Building not qualified - | firstName | lastName | email | phone | surveyId | buildingId | buildingQualified | userId | code | success | - | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | 1 | 152699 | False | 1594 | 400 | False | - - Examples: Building not exist - | firstName | lastName | email | phone | surveyId | buildingId | buildingQualified | userId | code | success | - | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | 1 | 0 | False | 1594 | 400 | False | + Examples: Invalid questionnaire + | firstName | lastName | email | phone | surveyId | buildingQualified | go | + | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | 1 | False | False | + | Tony | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | 1 | False | False | -- GitLab From b9578733b3a6e39a31b6fa93dd3463bc22f62bc0 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 3 Mar 2020 17:22:35 -0500 Subject: [PATCH 4/9] fix ignored test steps --- bloclink/apps/bis/features/steps/submitContact.py | 8 ++++---- bloclink/apps/bis/features/steps/submitQuestionnaire.py | 4 ++-- bloclink/apps/bis/features/submitContact.feature | 2 +- bloclink/apps/bis/features/submitQuestionnaire.feature | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bloclink/apps/bis/features/steps/submitContact.py b/bloclink/apps/bis/features/steps/submitContact.py index c593584..51dcac4 100644 --- a/bloclink/apps/bis/features/steps/submitContact.py +++ b/bloclink/apps/bis/features/steps/submitContact.py @@ -3,15 +3,15 @@ import requests import json -@given('I input {firstName} {lastName} {email} {phoneNumber} {buildingId} {userId}') -def step_impl(context, firstName, lastName, email, phoneNumber, buildingId, userId): +@given('I input {firstName} {lastName} {email} {phoneNumber} as contact info') +def step_impl(context, firstName, lastName, email, phoneNumber): context.inputs = { 'firstName': firstName, 'lastName': lastName, 'email': email, 'phoneNumber': phoneNumber, - 'buildingId': buildingId, - 'userId': userId, + 'buildingId': context.buildingId, + 'userId': context.userId, } @when('I submit contact form') diff --git a/bloclink/apps/bis/features/steps/submitQuestionnaire.py b/bloclink/apps/bis/features/steps/submitQuestionnaire.py index 1294d4b..e91b4d4 100644 --- a/bloclink/apps/bis/features/steps/submitQuestionnaire.py +++ b/bloclink/apps/bis/features/steps/submitQuestionnaire.py @@ -3,14 +3,14 @@ import requests import json -@given('I have answered all the questions') +@given('I input {firstName} {lastName} {email} {phone} {surveyId} {buildingQualified} as questionnaire info') def step_impl(context, firstName, lastName, email, phone, surveyId, buildingQualified): context.inputs = { 'firstName': firstName, 'lastName': lastName, 'email': email, 'phone': phone, - 'surveyId': context.surveyId, + 'surveyId': surveyId, 'buildingId': context.buildingId, 'buildingQualified': bool(buildingQualified), 'userId': context.userId, diff --git a/bloclink/apps/bis/features/submitContact.feature b/bloclink/apps/bis/features/submitContact.feature index 26d6da6..3fb42a5 100644 --- a/bloclink/apps/bis/features/submitContact.feature +++ b/bloclink/apps/bis/features/submitContact.feature @@ -2,7 +2,7 @@ Feature: A building owner can submit contact information @fixture.load.contact Scenario Outline: Contact information form - Given I input + Given I input as contact info When I click on continue button Then it will to the next question diff --git a/bloclink/apps/bis/features/submitQuestionnaire.feature b/bloclink/apps/bis/features/submitQuestionnaire.feature index 9a27854..3218f9f 100644 --- a/bloclink/apps/bis/features/submitQuestionnaire.feature +++ b/bloclink/apps/bis/features/submitQuestionnaire.feature @@ -2,7 +2,7 @@ Feature: A building owner can submit questionnaire @newyorkcity Scenario Outline: Review and submit questionnaire - Given I have answered all the questions + Given I input as questionnaire info When I submit the questionnaire Then it will to thanks page -- GitLab From 3ec96fae537f20dce97619a3e41b15258636b4f6 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 4 Mar 2020 12:24:08 -0500 Subject: [PATCH 5/9] add model meta jsons, refactor code --- .../apps/bis/features/data/submitAnswers.json | 27 ---------- .../apps/bis/features/data/submitContact.json | 6 --- .../features/data/submitQuestionnaire.json | 6 --- bloclink/apps/bis/features/environment.py | 53 ++++++++++--------- .../apps/bis/features/submitContact.feature | 2 +- 5 files changed, 29 insertions(+), 65 deletions(-) delete mode 100644 bloclink/apps/bis/features/data/submitAnswers.json delete mode 100644 bloclink/apps/bis/features/data/submitContact.json delete mode 100644 bloclink/apps/bis/features/data/submitQuestionnaire.json diff --git a/bloclink/apps/bis/features/data/submitAnswers.json b/bloclink/apps/bis/features/data/submitAnswers.json deleted file mode 100644 index 2108a3c..0000000 --- a/bloclink/apps/bis/features/data/submitAnswers.json +++ /dev/null @@ -1,27 +0,0 @@ -[ - { - "surveyId": 1, - "buildingId": 152699, - "userId": 1594, - "questions": { - "newyorkcity": { - "fuelTypes": "1", - "heatDistribution": "2", - "heatingSystemAge": "3", - "heatingSystemReplacementPlan": "4", - "buildingType": "6", - "utilityBills": "5,8", - "comfortIssues": "7", - "financeInterest": "9" - }, - "oakland": { - "buildingType": "12,13", - "buildingNeeds": "14", - "buildingChallenges": "15", - "heatingSystem": "16", - "EnergyImprovementPastYears": "18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34", - "EnergyImprovementNextYears": "35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51" - } - } - } -] diff --git a/bloclink/apps/bis/features/data/submitContact.json b/bloclink/apps/bis/features/data/submitContact.json deleted file mode 100644 index 6695124..0000000 --- a/bloclink/apps/bis/features/data/submitContact.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "buildingId": 152699, - "userId": 1594 - } -] diff --git a/bloclink/apps/bis/features/data/submitQuestionnaire.json b/bloclink/apps/bis/features/data/submitQuestionnaire.json deleted file mode 100644 index 6695124..0000000 --- a/bloclink/apps/bis/features/data/submitQuestionnaire.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "buildingId": 152699, - "userId": 1594 - } -] diff --git a/bloclink/apps/bis/features/environment.py b/bloclink/apps/bis/features/environment.py index 96b91a8..473d716 100644 --- a/bloclink/apps/bis/features/environment.py +++ b/bloclink/apps/bis/features/environment.py @@ -1,38 +1,36 @@ from behave import fixture, use_fixture from decouple import config -import os -import json -import psycopg2 +import os, json, psycopg2 from psycopg2 import sql from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT @fixture -def load_question(context): - context.questionId = context.questions[context.city][context.question] +def load_building(context): + with open('features/data/building.json', 'r') as outfile: + data = json.load(outfile) + context.buildingId = data['id'] + +@fixture +def load_user(context): + with open('features/data/user.json', 'r') as outfile: + data = json.load(outfile) + context.userId = data['id'] @fixture -def load_submit_answers(context): - with open('features/data/submitAnswers.json', 'r') as outfile: - data = json.load(outfile)[0] - context.surveyId = data['surveyId'] - context.buildingId = data['buildingId'] - context.userId = data['userId'] - context.questions = data['questions'] +def load_survey(context): + with open('features/data/survey.json', 'r') as outfile: + data = json.load(outfile) + context.surveyId = data['id'] @fixture -def load_submit_contact(context): - with open('features/data/submitContact.json', 'r') as outfile: - data = json.load(outfile)[0] - context.buildingId = data['buildingId'] - context.userId = data['userId'] +def load_question(context): + context.questionId = context.questions[context.city][context.question] @fixture -def load_submit_questionnaire(context): - with open('features/data/submitQuestionnaire.json', 'r') as outfile: - data = json.load(outfile)[0] - context.buildingId = data['buildingId'] - context.userId = data['userId'] +def load_questions(context): + with open('features/data/questions.json', 'r') as outfile: + context.questions = json.load(outfile) def before_tag(context, tag): if tag in ['newyorkcity', 'oakland']: @@ -45,13 +43,18 @@ def before_tag(context, tag): def before_feature(context, feature): feature_name = feature.filename.split('/')[-1] if feature_name == 'submitAnswers.feature': - use_fixture(load_submit_answers, context) + use_fixture(load_survey, context) + use_fixture(load_building, context) + use_fixture(load_user, context) + use_fixture(load_questions, context) if feature_name == 'submitContact.feature': - use_fixture(load_submit_contact, context) + use_fixture(load_building, context) + use_fixture(load_user, context) if feature_name == 'submitQuestionnaire.feature': - use_fixture(load_submit_questionnaire, context) + use_fixture(load_building, context) + use_fixture(load_user, context) def before_all(context): prefix = 'http://' if config('ENVIRONMENT') == 'local' else 'https://' diff --git a/bloclink/apps/bis/features/submitContact.feature b/bloclink/apps/bis/features/submitContact.feature index 3fb42a5..2444d6b 100644 --- a/bloclink/apps/bis/features/submitContact.feature +++ b/bloclink/apps/bis/features/submitContact.feature @@ -13,7 +13,7 @@ Feature: A building owner can submit contact information | Tony | Ferguson | tony.ferguson@ufc.com | '' | True | Examples: Invalid contact information - | firstName | lastName | email | phoneNumber | success | + | firstName | lastName | email | phoneNumber | go | | Tony | '' | tony.ferguson@ufc.com | 347-123-4567 | False | | '' | Ferguson | tony.ferguson@ufc.com | 347-123-4567 | False | | Tony | Ferguson | '' | 347-123-4567 | False | -- GitLab From 9d9027444ef6c405729e60b38323e44d28de3ffb Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 4 Mar 2020 15:29:29 -0500 Subject: [PATCH 6/9] Remove not needed module --- bloclink/apps/bis/features/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bloclink/apps/bis/features/environment.py b/bloclink/apps/bis/features/environment.py index 473d716..fee6789 100644 --- a/bloclink/apps/bis/features/environment.py +++ b/bloclink/apps/bis/features/environment.py @@ -1,6 +1,6 @@ from behave import fixture, use_fixture from decouple import config -import os, json, psycopg2 +import json, psycopg2 from psycopg2 import sql from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT -- GitLab From 5d43b513e6d360fb1ea8ed2de948421de5f72a1d Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 4 Mar 2020 15:32:27 -0500 Subject: [PATCH 7/9] Add missing JSON files --- bloclink/apps/bis/features/data/building.json | 3 +++ .../apps/bis/features/data/questions.json | 20 +++++++++++++++++++ bloclink/apps/bis/features/data/survey.json | 3 +++ bloclink/apps/bis/features/data/user.json | 3 +++ 4 files changed, 29 insertions(+) create mode 100644 bloclink/apps/bis/features/data/building.json create mode 100644 bloclink/apps/bis/features/data/questions.json create mode 100644 bloclink/apps/bis/features/data/survey.json create mode 100644 bloclink/apps/bis/features/data/user.json diff --git a/bloclink/apps/bis/features/data/building.json b/bloclink/apps/bis/features/data/building.json new file mode 100644 index 0000000..73c67dd --- /dev/null +++ b/bloclink/apps/bis/features/data/building.json @@ -0,0 +1,3 @@ +{ + "id": 152699 +} diff --git a/bloclink/apps/bis/features/data/questions.json b/bloclink/apps/bis/features/data/questions.json new file mode 100644 index 0000000..0ca6a01 --- /dev/null +++ b/bloclink/apps/bis/features/data/questions.json @@ -0,0 +1,20 @@ +{ + "newyorkcity": { + "fuelTypes": "1", + "heatDistribution": "2", + "heatingSystemAge": "3", + "heatingSystemReplacementPlan": "4", + "buildingType": "6", + "utilityBills": "5,8", + "comfortIssues": "7", + "financeInterest": "9" + }, + "oakland": { + "buildingType": "12,13", + "buildingNeeds": "14", + "buildingChallenges": "15", + "heatingSystem": "16", + "EnergyImprovementPastYears": "18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34", + "EnergyImprovementNextYears": "35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51" + } +} diff --git a/bloclink/apps/bis/features/data/survey.json b/bloclink/apps/bis/features/data/survey.json new file mode 100644 index 0000000..48a690e --- /dev/null +++ b/bloclink/apps/bis/features/data/survey.json @@ -0,0 +1,3 @@ +{ + "id": 1 +} diff --git a/bloclink/apps/bis/features/data/user.json b/bloclink/apps/bis/features/data/user.json new file mode 100644 index 0000000..49ebac6 --- /dev/null +++ b/bloclink/apps/bis/features/data/user.json @@ -0,0 +1,3 @@ +{ + "id": 1594 +} -- GitLab From 2c6f8a4922ec3c4b4acee357fa83c423eefbd97f Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 4 Mar 2020 15:59:29 -0500 Subject: [PATCH 8/9] fix boolean assertion --- bloclink/apps/bis/features/steps/submitBuilding.py | 8 ++++---- bloclink/apps/bis/features/submitAnswers.feature | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bloclink/apps/bis/features/steps/submitBuilding.py b/bloclink/apps/bis/features/steps/submitBuilding.py index c4e5266..13272cc 100644 --- a/bloclink/apps/bis/features/steps/submitBuilding.py +++ b/bloclink/apps/bis/features/steps/submitBuilding.py @@ -13,8 +13,8 @@ def step_impl(context): @then('it will {go} to the next question') def step_impl(context, go): - if go == True: - assert str(context.response.status_code) == 200 - else: - assert str(context.response.status_code) != 200 + if go == "True": + assert context.response.status_code == 200 + if go == "False": + assert context.response.status_code != 200 diff --git a/bloclink/apps/bis/features/submitAnswers.feature b/bloclink/apps/bis/features/submitAnswers.feature index bdbe063..3bb6958 100644 --- a/bloclink/apps/bis/features/submitAnswers.feature +++ b/bloclink/apps/bis/features/submitAnswers.feature @@ -12,7 +12,7 @@ Feature: A building owner can submit answers Examples: Invalid answers | answerId | go | - | 29 | True | + | 59 | False | | -9 | False | | 99 | False | -- GitLab From 055cd73d0377d9a3f6027125fbc04b7c5abd8b11 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 4 Mar 2020 16:05:33 -0500 Subject: [PATCH 9/9] Fix boolen assertion for submit questionnaire --- bloclink/apps/bis/features/steps/submitQuestionnaire.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bloclink/apps/bis/features/steps/submitQuestionnaire.py b/bloclink/apps/bis/features/steps/submitQuestionnaire.py index e91b4d4..ccc6e93 100644 --- a/bloclink/apps/bis/features/steps/submitQuestionnaire.py +++ b/bloclink/apps/bis/features/steps/submitQuestionnaire.py @@ -22,7 +22,7 @@ def step_impl(context): @then('it will {go} to thanks page') def step_impl(context, go): - if go == True: - assert str(context.response.status_code) == 200 - else: - assert str(context.response.status_code) != 200 + if go == "True": + assert context.response.status_code == 200 + if go == "False": + assert context.response.status_code != 200 -- GitLab