Fix tests, linting errors
This commit is contained in:
parent
e148606613
commit
06c44f86c9
@ -1,7 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
from wtforms.fields.html5 import EmailField
|
from wtforms.fields.html5 import EmailField
|
||||||
from wtforms.fields import StringField
|
from wtforms.fields import StringField
|
||||||
from wtforms.validators import Required, Email, InputRequired, Regexp, DataRequired
|
from wtforms.validators import Required, Email, Regexp
|
||||||
|
|
||||||
from atst.domain.exceptions import NotFoundError
|
from atst.domain.exceptions import NotFoundError
|
||||||
from atst.domain.pe_numbers import PENumbers
|
from atst.domain.pe_numbers import PENumbers
|
||||||
|
@ -77,10 +77,10 @@ class RequestForm(ValidatedForm):
|
|||||||
organization_providing_assistance = RadioField( # this needs to be updated to use checkboxes instead of radio
|
organization_providing_assistance = RadioField( # this needs to be updated to use checkboxes instead of radio
|
||||||
description="If you are receiving migration assistance, what is the type of organization providing assistance?",
|
description="If you are receiving migration assistance, what is the type of organization providing assistance?",
|
||||||
choices=[
|
choices=[
|
||||||
("in_house_staff", "In-house staff"),
|
("In-house staff", "In-house staff"),
|
||||||
("contractor", "Contractor"),
|
("Contractor", "Contractor"),
|
||||||
("other_dod_organization", "Other DoD organization"),
|
("Other DoD Organization", "Other DoD Organization"),
|
||||||
("none", "None"),
|
("None", "None"),
|
||||||
],
|
],
|
||||||
default="",
|
default="",
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,6 @@ from atst.models.request_status_event import RequestStatusEvent
|
|||||||
from atst.domain.roles import Roles
|
from atst.domain.roles import Roles
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RoleFactory(factory.alchemy.SQLAlchemyModelFactory):
|
class RoleFactory(factory.alchemy.SQLAlchemyModelFactory):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Role
|
model = Role
|
||||||
@ -34,7 +33,6 @@ class UserFactory(factory.alchemy.SQLAlchemyModelFactory):
|
|||||||
|
|
||||||
|
|
||||||
class RequestStatusEventFactory(factory.alchemy.SQLAlchemyModelFactory):
|
class RequestStatusEventFactory(factory.alchemy.SQLAlchemyModelFactory):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = RequestStatusEvent
|
model = RequestStatusEvent
|
||||||
|
|
||||||
@ -61,7 +59,7 @@ class RequestFactory(factory.alchemy.SQLAlchemyModelFactory):
|
|||||||
"dodid_poc": user.dod_id,
|
"dodid_poc": user.dod_id,
|
||||||
"email_poc": user.email,
|
"email_poc": user.email,
|
||||||
"fname_poc": user.first_name,
|
"fname_poc": user.first_name,
|
||||||
"lname_poc": user.last_name
|
"lname_poc": user.last_name,
|
||||||
},
|
},
|
||||||
"details_of_use": {
|
"details_of_use": {
|
||||||
"jedi_usage": "adf",
|
"jedi_usage": "adf",
|
||||||
@ -69,7 +67,8 @@ class RequestFactory(factory.alchemy.SQLAlchemyModelFactory):
|
|||||||
"cloud_native": "yes",
|
"cloud_native": "yes",
|
||||||
"dollar_value": dollar_value,
|
"dollar_value": dollar_value,
|
||||||
"dod_component": "Army and Air Force Exchange Service",
|
"dod_component": "Army and Air Force Exchange Service",
|
||||||
"data_transfers": "less_than_100gb",
|
"data_transfers": "Less than 100GB",
|
||||||
|
"expected_completion_date": "Less than 1 month",
|
||||||
"jedi_migration": "yes",
|
"jedi_migration": "yes",
|
||||||
"num_software_systems": 1,
|
"num_software_systems": 1,
|
||||||
"number_user_sessions": 2,
|
"number_user_sessions": 2,
|
||||||
@ -78,9 +77,8 @@ class RequestFactory(factory.alchemy.SQLAlchemyModelFactory):
|
|||||||
"technical_support_team": "yes",
|
"technical_support_team": "yes",
|
||||||
"estimated_monthly_spend": 100,
|
"estimated_monthly_spend": 100,
|
||||||
"average_daily_traffic_gb": 4,
|
"average_daily_traffic_gb": 4,
|
||||||
"expected_completion_date": "less_than_1_month",
|
|
||||||
"rationalization_software_systems": "yes",
|
"rationalization_software_systems": "yes",
|
||||||
"organization_providing_assistance": "in_house_staff"
|
"organization_providing_assistance": "In-house staff",
|
||||||
},
|
},
|
||||||
"information_about_you": {
|
"information_about_you": {
|
||||||
"citizenship": "United States",
|
"citizenship": "United States",
|
||||||
@ -90,8 +88,8 @@ class RequestFactory(factory.alchemy.SQLAlchemyModelFactory):
|
|||||||
"fname_request": user.first_name,
|
"fname_request": user.first_name,
|
||||||
"lname_request": user.last_name,
|
"lname_request": user.last_name,
|
||||||
"service_branch": "Air Force, Department of the",
|
"service_branch": "Air Force, Department of the",
|
||||||
"date_latest_training": "2018-08-06"
|
"date_latest_training": "2018-08-06",
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,80 +6,80 @@ from atst.forms.request import RequestForm
|
|||||||
class TestRequestForm:
|
class TestRequestForm:
|
||||||
|
|
||||||
form_data = {
|
form_data = {
|
||||||
'dod_component': 'Army and Air Force Exchange Service',
|
"dod_component": "Army and Air Force Exchange Service",
|
||||||
'jedi_usage': 'cloud-ify all the things',
|
"jedi_usage": "cloud-ify all the things",
|
||||||
'num_software_systems': '12',
|
"num_software_systems": "12",
|
||||||
'estimated_monthly_spend': '1000000',
|
"estimated_monthly_spend": "1000000",
|
||||||
'dollar_value': '42',
|
"dollar_value": "42",
|
||||||
'number_user_sessions': '6',
|
"number_user_sessions": "6",
|
||||||
'average_daily_traffic': '0',
|
"average_daily_traffic": "0",
|
||||||
'start_date': '12/12/2012',
|
"start_date": "12/12/2012",
|
||||||
}
|
}
|
||||||
migration_data = {
|
migration_data = {
|
||||||
'jedi_migration': 'yes',
|
"jedi_migration": "yes",
|
||||||
'rationalization_software_systems': 'yes',
|
"rationalization_software_systems": "yes",
|
||||||
'technical_support_team': 'yes',
|
"technical_support_team": "yes",
|
||||||
'organization_providing_assistance': 'in_house_staff',
|
"organization_providing_assistance": "In-house staff",
|
||||||
'engineering_assessment': 'yes',
|
"engineering_assessment": "yes",
|
||||||
'data_transfers': 'less_than_100gb',
|
"data_transfers": "Less than 100GB",
|
||||||
'expected_completion_date': 'less_than_1_month'
|
"expected_completion_date": "Less than 1 month",
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_require_cloud_native_when_not_migrating(self):
|
def test_require_cloud_native_when_not_migrating(self):
|
||||||
extra_data = { 'jedi_migration': 'no' }
|
extra_data = {"jedi_migration": "no"}
|
||||||
request_form = RequestForm(data={ **self.form_data, **extra_data })
|
request_form = RequestForm(data={**self.form_data, **extra_data})
|
||||||
assert not request_form.validate()
|
assert not request_form.validate()
|
||||||
assert request_form.errors == { 'cloud_native': ['Not a valid choice'] }
|
assert request_form.errors == {"cloud_native": ["Not a valid choice"]}
|
||||||
|
|
||||||
def test_require_migration_questions_when_migrating(self):
|
def test_require_migration_questions_when_migrating(self):
|
||||||
extra_data = { 'jedi_migration': 'yes' }
|
extra_data = {"jedi_migration": "yes"}
|
||||||
request_form = RequestForm(data={ **self.form_data, **extra_data })
|
request_form = RequestForm(data={**self.form_data, **extra_data})
|
||||||
assert not request_form.validate()
|
assert not request_form.validate()
|
||||||
assert request_form.errors == {
|
assert request_form.errors == {
|
||||||
'rationalization_software_systems': ['Not a valid choice'],
|
"rationalization_software_systems": ["Not a valid choice"],
|
||||||
'technical_support_team': ['Not a valid choice'],
|
"technical_support_team": ["Not a valid choice"],
|
||||||
'organization_providing_assistance': ['Not a valid choice'],
|
"organization_providing_assistance": ["Not a valid choice"],
|
||||||
'engineering_assessment': ['Not a valid choice'],
|
"engineering_assessment": ["Not a valid choice"],
|
||||||
'data_transfers': ['Not a valid choice'],
|
"data_transfers": ["Not a valid choice"],
|
||||||
'expected_completion_date': ['Not a valid choice']
|
"expected_completion_date": ["Not a valid choice"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_require_organization_when_technical_support_team(self):
|
def test_require_organization_when_technical_support_team(self):
|
||||||
data = { **self.form_data, **self.migration_data }
|
data = {**self.form_data, **self.migration_data}
|
||||||
del data['organization_providing_assistance']
|
del data["organization_providing_assistance"]
|
||||||
|
|
||||||
request_form = RequestForm(data=data)
|
request_form = RequestForm(data=data)
|
||||||
assert not request_form.validate()
|
assert not request_form.validate()
|
||||||
assert request_form.errors == {
|
assert request_form.errors == {
|
||||||
'organization_providing_assistance': ['Not a valid choice'],
|
"organization_providing_assistance": ["Not a valid choice"]
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_valid_form_data(self):
|
def test_valid_form_data(self):
|
||||||
data = { **self.form_data, **self.migration_data }
|
data = {**self.form_data, **self.migration_data}
|
||||||
data['technical_support_team'] = 'no'
|
data["technical_support_team"] = "no"
|
||||||
del data['organization_providing_assistance']
|
del data["organization_providing_assistance"]
|
||||||
|
|
||||||
request_form = RequestForm(data=data)
|
request_form = RequestForm(data=data)
|
||||||
assert request_form.validate()
|
assert request_form.validate()
|
||||||
|
|
||||||
def test_sessions_required_for_large_projects(self):
|
def test_sessions_required_for_large_projects(self):
|
||||||
data = { **self.form_data, **self.migration_data }
|
data = {**self.form_data, **self.migration_data}
|
||||||
data['estimated_monthly_spend'] = '9999999'
|
data["estimated_monthly_spend"] = "9999999"
|
||||||
del data['number_user_sessions']
|
del data["number_user_sessions"]
|
||||||
del data['average_daily_traffic']
|
del data["average_daily_traffic"]
|
||||||
|
|
||||||
request_form = RequestForm(data=data)
|
request_form = RequestForm(data=data)
|
||||||
assert not request_form.validate()
|
assert not request_form.validate()
|
||||||
assert request_form.errors == {
|
assert request_form.errors == {
|
||||||
'number_user_sessions': ['This field is required.'],
|
"number_user_sessions": ["This field is required."],
|
||||||
'average_daily_traffic': ['This field is required.'],
|
"average_daily_traffic": ["This field is required."],
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_sessions_not_required_invalid_monthly_spend(self):
|
def test_sessions_not_required_invalid_monthly_spend(self):
|
||||||
data = { **self.form_data, **self.migration_data }
|
data = {**self.form_data, **self.migration_data}
|
||||||
data['estimated_monthly_spend'] = 'foo'
|
data["estimated_monthly_spend"] = "foo"
|
||||||
del data['number_user_sessions']
|
del data["number_user_sessions"]
|
||||||
del data['average_daily_traffic']
|
del data["average_daily_traffic"]
|
||||||
|
|
||||||
request_form = RequestForm(data=data)
|
request_form = RequestForm(data=data)
|
||||||
assert request_form.validate()
|
assert request_form.validate()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user