Merge pull request #343 from dod-ccpo/more-tests-for-workspaces
Add more tests for workspaces routes
This commit is contained in:
commit
388ff899a2
@ -2,7 +2,7 @@ import re
|
|||||||
import pendulum
|
import pendulum
|
||||||
from wtforms.fields.html5 import DateField, EmailField
|
from wtforms.fields.html5 import DateField, EmailField
|
||||||
from wtforms.fields import StringField, FileField
|
from wtforms.fields import StringField, FileField
|
||||||
from wtforms.validators import InputRequired, Required, Email, Regexp
|
from wtforms.validators import InputRequired, Email, Regexp
|
||||||
from flask_wtf.file import FileAllowed
|
from flask_wtf.file import FileAllowed
|
||||||
|
|
||||||
from atst.domain.exceptions import NotFoundError
|
from atst.domain.exceptions import NotFoundError
|
||||||
@ -99,47 +99,47 @@ class BaseFinancialForm(ValidatedForm):
|
|||||||
task_order_number = StringField(
|
task_order_number = StringField(
|
||||||
"Task Order Number associated with this request",
|
"Task Order Number associated with this request",
|
||||||
description="Include the original Task Order number (including the 000X at the end). Do not include any modification numbers. Note that there may be a lag between approving a task order and when it becomes available in our system.",
|
description="Include the original Task Order number (including the 000X at the end). Do not include any modification numbers. Note that there may be a lag between approving a task order and when it becomes available in our system.",
|
||||||
validators=[Required()],
|
validators=[InputRequired()],
|
||||||
)
|
)
|
||||||
|
|
||||||
uii_ids = NewlineListField(
|
uii_ids = NewlineListField(
|
||||||
"Unique Item Identifier (UII)s related to your application(s) if you already have them.",
|
"Unique Item Identifier (UII)s related to your application(s) if you already have them.",
|
||||||
description="If you have more than one UII, place each one on a new line.",
|
description="If you have more than one UII, place each one on a new line.",
|
||||||
validators=[Required()],
|
validators=[InputRequired()],
|
||||||
)
|
)
|
||||||
|
|
||||||
pe_id = StringField(
|
pe_id = StringField(
|
||||||
"Program Element Number",
|
"Program Element Number",
|
||||||
description="PE numbers help the Department of Defense identify which offices' budgets are contributing towards this resource use. <br/><em>It should be 7 digits followed by 1-3 letters, and should have a zero as the first and third digits.</em>",
|
description="PE numbers help the Department of Defense identify which offices' budgets are contributing towards this resource use. <br/><em>It should be 7 digits followed by 1-3 letters, and should have a zero as the first and third digits.</em>",
|
||||||
validators=[Required()],
|
validators=[InputRequired()],
|
||||||
)
|
)
|
||||||
|
|
||||||
treasury_code = StringField(
|
treasury_code = StringField(
|
||||||
"Program Treasury Code",
|
"Program Treasury Code",
|
||||||
description="Program Treasury Code (or Appropriations Code) identifies resource types. <br/> <em>It should be a four digit or six digit number, optionally prefixed by one or more zeros.</em>",
|
description="Program Treasury Code (or Appropriations Code) identifies resource types. <br/> <em>It should be a four digit or six digit number, optionally prefixed by one or more zeros.</em>",
|
||||||
validators=[Required(), Regexp(TREASURY_CODE_REGEX)],
|
validators=[InputRequired(), Regexp(TREASURY_CODE_REGEX)],
|
||||||
)
|
)
|
||||||
|
|
||||||
ba_code = StringField(
|
ba_code = StringField(
|
||||||
"Program Budget Activity (BA) Code",
|
"Program Budget Activity (BA) Code",
|
||||||
description="BA Code is used to identify the purposes, projects, or types of activities financed by the appropriation fund. <br/><em>It should be two digits, followed by an optional letter.</em>",
|
description="BA Code is used to identify the purposes, projects, or types of activities financed by the appropriation fund. <br/><em>It should be two digits, followed by an optional letter.</em>",
|
||||||
validators=[Required(), Regexp(BA_CODE_REGEX)],
|
validators=[InputRequired(), Regexp(BA_CODE_REGEX)],
|
||||||
)
|
)
|
||||||
|
|
||||||
fname_co = StringField("KO First Name", validators=[Required()])
|
fname_co = StringField("KO First Name", validators=[InputRequired()])
|
||||||
lname_co = StringField("KO Last Name", validators=[Required()])
|
lname_co = StringField("KO Last Name", validators=[InputRequired()])
|
||||||
|
|
||||||
email_co = EmailField("KO Email", validators=[Required(), Email()])
|
email_co = EmailField("KO Email", validators=[InputRequired(), Email()])
|
||||||
|
|
||||||
office_co = StringField("KO Office", validators=[Required()])
|
office_co = StringField("KO Office", validators=[InputRequired()])
|
||||||
|
|
||||||
fname_cor = StringField("COR First Name", validators=[Required()])
|
fname_cor = StringField("COR First Name", validators=[InputRequired()])
|
||||||
|
|
||||||
lname_cor = StringField("COR Last Name", validators=[Required()])
|
lname_cor = StringField("COR Last Name", validators=[InputRequired()])
|
||||||
|
|
||||||
email_cor = EmailField("COR Email", validators=[Required(), Email()])
|
email_cor = EmailField("COR Email", validators=[InputRequired(), Email()])
|
||||||
|
|
||||||
office_cor = StringField("COR Office", validators=[Required()])
|
office_cor = StringField("COR Office", validators=[InputRequired()])
|
||||||
|
|
||||||
|
|
||||||
class FinancialForm(BaseFinancialForm):
|
class FinancialForm(BaseFinancialForm):
|
||||||
@ -156,13 +156,13 @@ class FinancialForm(BaseFinancialForm):
|
|||||||
class ExtendedFinancialForm(BaseFinancialForm):
|
class ExtendedFinancialForm(BaseFinancialForm):
|
||||||
def validate(self, *args, **kwargs):
|
def validate(self, *args, **kwargs):
|
||||||
if self.funding_type.data == "OTHER":
|
if self.funding_type.data == "OTHER":
|
||||||
self.funding_type_other.validators.append(Required())
|
self.funding_type_other.validators.append(InputRequired())
|
||||||
return super().validate(*args, **kwargs)
|
return super().validate(*args, **kwargs)
|
||||||
|
|
||||||
funding_type = SelectField(
|
funding_type = SelectField(
|
||||||
description="What is the source of funding?",
|
description="What is the source of funding?",
|
||||||
choices=FUNDING_TYPES,
|
choices=FUNDING_TYPES,
|
||||||
validators=[Required()],
|
validators=[InputRequired()],
|
||||||
render_kw={"required": False},
|
render_kw={"required": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ class ExtendedFinancialForm(BaseFinancialForm):
|
|||||||
"Task Order Expiration Date",
|
"Task Order Expiration Date",
|
||||||
description="Please enter the expiration date for the Task Order",
|
description="Please enter the expiration date for the Task Order",
|
||||||
validators=[
|
validators=[
|
||||||
Required(),
|
InputRequired(),
|
||||||
DateRange(
|
DateRange(
|
||||||
lower_bound=pendulum.duration(days=0),
|
lower_bound=pendulum.duration(days=0),
|
||||||
upper_bound=pendulum.duration(years=100),
|
upper_bound=pendulum.duration(years=100),
|
||||||
@ -228,6 +228,6 @@ class ExtendedFinancialForm(BaseFinancialForm):
|
|||||||
"Upload a copy of your Task Order",
|
"Upload a copy of your Task Order",
|
||||||
validators=[
|
validators=[
|
||||||
FileAllowed(["pdf"], "Only PDF documents can be uploaded."),
|
FileAllowed(["pdf"], "Only PDF documents can be uploaded."),
|
||||||
Required(),
|
InputRequired(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from flask_wtf import Form
|
from flask_wtf import FlaskForm
|
||||||
from wtforms.fields import StringField
|
from wtforms.fields import StringField
|
||||||
from wtforms.fields.html5 import EmailField
|
from wtforms.fields.html5 import EmailField
|
||||||
from wtforms.validators import Required, Email, Length
|
from wtforms.validators import Required, Email, Length
|
||||||
@ -9,7 +9,7 @@ from atst.forms.fields import SelectField
|
|||||||
from .data import WORKSPACE_ROLES
|
from .data import WORKSPACE_ROLES
|
||||||
|
|
||||||
|
|
||||||
class NewMemberForm(Form):
|
class NewMemberForm(FlaskForm):
|
||||||
|
|
||||||
first_name = StringField(label="First Name", validators=[Required()])
|
first_name = StringField(label="First Name", validators=[Required()])
|
||||||
last_name = StringField(label="Last Name", validators=[Required()])
|
last_name = StringField(label="Last Name", validators=[Required()])
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
from flask_wtf import Form
|
from flask_wtf import FlaskForm
|
||||||
from wtforms.fields import StringField, TextAreaField, FieldList
|
from wtforms.fields import StringField, TextAreaField, FieldList
|
||||||
from wtforms.validators import Required
|
from wtforms.validators import Required
|
||||||
from atst.forms.validators import ListItemRequired, ListItemsUnique
|
from atst.forms.validators import ListItemRequired, ListItemsUnique
|
||||||
|
|
||||||
|
|
||||||
class NewProjectForm(Form):
|
class NewProjectForm(FlaskForm):
|
||||||
|
|
||||||
EMPTY_ENVIRONMENT_NAMES = ["", None]
|
EMPTY_ENVIRONMENT_NAMES = ["", None]
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ class NewProjectForm(Form):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
_data = super(Form, self).data
|
_data = super(FlaskForm, self).data
|
||||||
_data["environment_names"] = [
|
_data["environment_names"] = [
|
||||||
n
|
n
|
||||||
for n in _data["environment_names"]
|
for n in _data["environment_names"]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import pendulum
|
import pendulum
|
||||||
from wtforms.fields.html5 import DateField, EmailField, IntegerField, TelField
|
from wtforms.fields.html5 import DateField, EmailField, IntegerField, TelField
|
||||||
from wtforms.fields import BooleanField, RadioField, StringField, TextAreaField
|
from wtforms.fields import BooleanField, RadioField, StringField, TextAreaField
|
||||||
from wtforms.validators import Email, Length, Optional, Required, DataRequired
|
from wtforms.validators import Email, Length, Optional, InputRequired, DataRequired
|
||||||
|
|
||||||
from .fields import SelectField
|
from .fields import SelectField
|
||||||
from .forms import ValidatedForm
|
from .forms import ValidatedForm
|
||||||
@ -35,8 +35,8 @@ class DetailsOfUseForm(ValidatedForm):
|
|||||||
annual_spend = 0
|
annual_spend = 0
|
||||||
|
|
||||||
if annual_spend > Requests.AUTO_APPROVE_THRESHOLD:
|
if annual_spend > Requests.AUTO_APPROVE_THRESHOLD:
|
||||||
self.number_user_sessions.validators.append(Required())
|
self.number_user_sessions.validators.append(InputRequired())
|
||||||
self.average_daily_traffic.validators.append(Required())
|
self.average_daily_traffic.validators.append(InputRequired())
|
||||||
|
|
||||||
return super(DetailsOfUseForm, self).validate(*args, **kwargs)
|
return super(DetailsOfUseForm, self).validate(*args, **kwargs)
|
||||||
|
|
||||||
@ -45,13 +45,13 @@ class DetailsOfUseForm(ValidatedForm):
|
|||||||
"DoD Component",
|
"DoD Component",
|
||||||
description="Identify the DoD component that is requesting access to the JEDI Cloud",
|
description="Identify the DoD component that is requesting access to the JEDI Cloud",
|
||||||
choices=SERVICE_BRANCHES,
|
choices=SERVICE_BRANCHES,
|
||||||
validators=[Required()],
|
validators=[InputRequired()],
|
||||||
)
|
)
|
||||||
|
|
||||||
jedi_usage = TextAreaField(
|
jedi_usage = TextAreaField(
|
||||||
"JEDI Usage",
|
"JEDI Usage",
|
||||||
description="Your answer will help us provide tangible examples to DoD leadership how and why commercial cloud resources are accelerating the Department's missions",
|
description="Your answer will help us provide tangible examples to DoD leadership how and why commercial cloud resources are accelerating the Department's missions",
|
||||||
validators=[Required()],
|
validators=[InputRequired()],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Details of Use: Cloud Readiness
|
# Details of Use: Cloud Readiness
|
||||||
@ -94,13 +94,13 @@ class DetailsOfUseForm(ValidatedForm):
|
|||||||
data_transfers = SelectField(
|
data_transfers = SelectField(
|
||||||
description="How much data is being transferred to the cloud?",
|
description="How much data is being transferred to the cloud?",
|
||||||
choices=DATA_TRANSFER_AMOUNTS,
|
choices=DATA_TRANSFER_AMOUNTS,
|
||||||
validators=[Required()],
|
validators=[DataRequired()],
|
||||||
)
|
)
|
||||||
|
|
||||||
expected_completion_date = SelectField(
|
expected_completion_date = SelectField(
|
||||||
description="When do you expect to complete your migration to the JEDI Cloud?",
|
description="When do you expect to complete your migration to the JEDI Cloud?",
|
||||||
choices=COMPLETION_DATE_RANGES,
|
choices=COMPLETION_DATE_RANGES,
|
||||||
validators=[Required()],
|
validators=[DataRequired()],
|
||||||
)
|
)
|
||||||
|
|
||||||
cloud_native = RadioField(
|
cloud_native = RadioField(
|
||||||
@ -137,7 +137,7 @@ class DetailsOfUseForm(ValidatedForm):
|
|||||||
start_date = DateField(
|
start_date = DateField(
|
||||||
description="When do you expect to start using the JEDI Cloud (not for billing purposes)?",
|
description="When do you expect to start using the JEDI Cloud (not for billing purposes)?",
|
||||||
validators=[
|
validators=[
|
||||||
DataRequired(),
|
InputRequired(),
|
||||||
DateRange(
|
DateRange(
|
||||||
lower_bound=pendulum.duration(days=1),
|
lower_bound=pendulum.duration(days=1),
|
||||||
upper_bound=None,
|
upper_bound=None,
|
||||||
@ -151,7 +151,7 @@ class DetailsOfUseForm(ValidatedForm):
|
|||||||
"Name Your Request",
|
"Name Your Request",
|
||||||
description="This name serves as a reference for your initial request and the associated workspace that will be created once this request is approved. You may edit this name later.",
|
description="This name serves as a reference for your initial request and the associated workspace that will be created once this request is approved. You may edit this name later.",
|
||||||
validators=[
|
validators=[
|
||||||
Required(),
|
InputRequired(),
|
||||||
Length(
|
Length(
|
||||||
min=4,
|
min=4,
|
||||||
max=100,
|
max=100,
|
||||||
@ -162,16 +162,16 @@ class DetailsOfUseForm(ValidatedForm):
|
|||||||
|
|
||||||
|
|
||||||
class InformationAboutYouForm(ValidatedForm):
|
class InformationAboutYouForm(ValidatedForm):
|
||||||
fname_request = StringField("First Name", validators=[Required(), Alphabet()])
|
fname_request = StringField("First Name", validators=[InputRequired(), Alphabet()])
|
||||||
|
|
||||||
lname_request = StringField("Last Name", validators=[Required(), Alphabet()])
|
lname_request = StringField("Last Name", validators=[InputRequired(), Alphabet()])
|
||||||
|
|
||||||
email_request = EmailField("E-mail Address", validators=[Required(), Email()])
|
email_request = EmailField("E-mail Address", validators=[InputRequired(), Email()])
|
||||||
|
|
||||||
phone_number = TelField(
|
phone_number = TelField(
|
||||||
"Phone Number",
|
"Phone Number",
|
||||||
description="Enter a 10-digit phone number",
|
description="Enter a 10-digit phone number",
|
||||||
validators=[Required(), PhoneNumber()],
|
validators=[InputRequired(), PhoneNumber()],
|
||||||
)
|
)
|
||||||
|
|
||||||
service_branch = SelectField(
|
service_branch = SelectField(
|
||||||
@ -187,7 +187,7 @@ class InformationAboutYouForm(ValidatedForm):
|
|||||||
("Foreign National", "Foreign National"),
|
("Foreign National", "Foreign National"),
|
||||||
("Other", "Other"),
|
("Other", "Other"),
|
||||||
],
|
],
|
||||||
validators=[Required()],
|
validators=[InputRequired()],
|
||||||
)
|
)
|
||||||
|
|
||||||
designation = RadioField(
|
designation = RadioField(
|
||||||
@ -198,14 +198,14 @@ class InformationAboutYouForm(ValidatedForm):
|
|||||||
("civilian", "Civilian"),
|
("civilian", "Civilian"),
|
||||||
("contractor", "Contractor"),
|
("contractor", "Contractor"),
|
||||||
],
|
],
|
||||||
validators=[Required()],
|
validators=[InputRequired()],
|
||||||
)
|
)
|
||||||
|
|
||||||
date_latest_training = DateField(
|
date_latest_training = DateField(
|
||||||
"Latest Information Assurance (IA) Training Completion Date",
|
"Latest Information Assurance (IA) Training Completion Date",
|
||||||
description='To complete the training, you can find it in <a class="icon-link" href="https://iatraining.disa.mil/eta/disa_cac2018/launchPage.htm" target="_blank">Information Assurance Cyber Awareness Challange</a> website.',
|
description='To complete the training, you can find it in <a class="icon-link" href="https://iatraining.disa.mil/eta/disa_cac2018/launchPage.htm" target="_blank">Information Assurance Cyber Awareness Challange</a> website.',
|
||||||
validators=[
|
validators=[
|
||||||
Required(),
|
InputRequired(),
|
||||||
DateRange(
|
DateRange(
|
||||||
lower_bound=pendulum.duration(years=1),
|
lower_bound=pendulum.duration(years=1),
|
||||||
upper_bound=pendulum.duration(days=0),
|
upper_bound=pendulum.duration(days=0),
|
||||||
@ -234,14 +234,14 @@ class WorkspaceOwnerForm(ValidatedForm):
|
|||||||
false_values=(False, "false", "False", "no", ""),
|
false_values=(False, "false", "False", "no", ""),
|
||||||
)
|
)
|
||||||
|
|
||||||
fname_poc = StringField("First Name", validators=[Required()])
|
fname_poc = StringField("First Name", validators=[InputRequired()])
|
||||||
|
|
||||||
lname_poc = StringField("Last Name", validators=[Required()])
|
lname_poc = StringField("Last Name", validators=[InputRequired()])
|
||||||
|
|
||||||
email_poc = EmailField("Email Address", validators=[Required(), Email()])
|
email_poc = EmailField("Email Address", validators=[InputRequired(), Email()])
|
||||||
|
|
||||||
dodid_poc = StringField(
|
dodid_poc = StringField(
|
||||||
"DoD ID", validators=[Required(), Length(min=10), IsNumber()]
|
"DoD ID", validators=[InputRequired(), Length(min=10), IsNumber()]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
{% block workspace_content %}
|
{% block workspace_content %}
|
||||||
|
|
||||||
|
{% if g.dev %}
|
||||||
|
{{ Alert("In Progress", message="This page is a work in progress. You won't be able to edit environments on this project just yet.", level="warning") }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% set modalName = "updateProjectConfirmation" %}
|
{% set modalName = "updateProjectConfirmation" %}
|
||||||
{% include "fragments/edit_project_form.html" %}
|
{% include "fragments/edit_project_form.html" %}
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ def test_funding_type_other_required_if_funding_type_is_other():
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_treasury_code_validation(input_, expected):
|
def test_treasury_code_validation(input_, expected):
|
||||||
form_data = {"treasury_code": input_}
|
form_data = ImmutableMultiDict([("treasury_code", input_)])
|
||||||
form = FinancialForm(data=form_data)
|
form = FinancialForm(form_data)
|
||||||
form.validate()
|
form.validate()
|
||||||
is_valid = "treasury_code" not in form.errors
|
is_valid = "treasury_code" not in form.errors
|
||||||
|
|
||||||
@ -74,8 +74,8 @@ def test_treasury_code_validation(input_, expected):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_ba_code_validation(input_, expected):
|
def test_ba_code_validation(input_, expected):
|
||||||
form_data = {"ba_code": input_}
|
form_data = ImmutableMultiDict([("ba_code", input_)])
|
||||||
form = FinancialForm(data=form_data)
|
form = FinancialForm(form_data)
|
||||||
form.validate()
|
form.validate()
|
||||||
is_valid = "ba_code" not in form.errors
|
is_valid = "ba_code" not in form.errors
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
from werkzeug.datastructures import ImmutableMultiDict
|
||||||
|
|
||||||
from atst.forms.new_request import DetailsOfUseForm
|
from atst.forms.new_request import DetailsOfUseForm
|
||||||
|
|
||||||
@ -26,9 +27,13 @@ class TestDetailsOfUseForm:
|
|||||||
"expected_completion_date": "Less than 1 month",
|
"expected_completion_date": "Less than 1 month",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _make_form(self, data):
|
||||||
|
form_data = ImmutableMultiDict(data.items())
|
||||||
|
return DetailsOfUseForm(form_data)
|
||||||
|
|
||||||
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 = DetailsOfUseForm(data={**self.form_data, **extra_data})
|
request_form = self._make_form({**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"]}
|
||||||
|
|
||||||
@ -38,7 +43,7 @@ class TestDetailsOfUseForm:
|
|||||||
"data_transfers": "",
|
"data_transfers": "",
|
||||||
"expected_completion_date": "",
|
"expected_completion_date": "",
|
||||||
}
|
}
|
||||||
request_form = DetailsOfUseForm(data={**self.form_data, **extra_data})
|
request_form = self._make_form({**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"],
|
||||||
@ -53,7 +58,7 @@ class TestDetailsOfUseForm:
|
|||||||
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 = DetailsOfUseForm(data=data)
|
request_form = self._make_form(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"]
|
||||||
@ -64,7 +69,7 @@ class TestDetailsOfUseForm:
|
|||||||
data["technical_support_team"] = "no"
|
data["technical_support_team"] = "no"
|
||||||
del data["organization_providing_assistance"]
|
del data["organization_providing_assistance"]
|
||||||
|
|
||||||
request_form = DetailsOfUseForm(data=data)
|
request_form = self._make_form(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):
|
||||||
@ -73,26 +78,26 @@ class TestDetailsOfUseForm:
|
|||||||
del data["number_user_sessions"]
|
del data["number_user_sessions"]
|
||||||
del data["average_daily_traffic"]
|
del data["average_daily_traffic"]
|
||||||
|
|
||||||
request_form = DetailsOfUseForm(data=data)
|
request_form = self._make_form(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_low_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"] = "10"
|
||||||
del data["number_user_sessions"]
|
del data["number_user_sessions"]
|
||||||
del data["average_daily_traffic"]
|
del data["average_daily_traffic"]
|
||||||
|
|
||||||
request_form = DetailsOfUseForm(data=data)
|
request_form = self._make_form(data)
|
||||||
assert request_form.validate()
|
assert request_form.validate()
|
||||||
|
|
||||||
def test_start_date_must_be_in_the_future(self):
|
def test_start_date_must_be_in_the_future(self):
|
||||||
data = {**self.form_data, **self.migration_data}
|
data = {**self.form_data, **self.migration_data}
|
||||||
data["start_date"] = "01/01/2018"
|
data["start_date"] = "01/01/2018"
|
||||||
|
|
||||||
request_form = DetailsOfUseForm(data=data)
|
request_form = self._make_form(data)
|
||||||
assert not request_form.validate()
|
assert not request_form.validate()
|
||||||
assert "Must be a date in the future." in request_form.errors["start_date"]
|
assert "Must be a date in the future." in request_form.errors["start_date"]
|
||||||
|
@ -73,6 +73,59 @@ def test_update_workspace_name(client, user_session):
|
|||||||
assert workspace.name == "a cool new name"
|
assert workspace.name == "a cool new name"
|
||||||
|
|
||||||
|
|
||||||
|
def test_view_edit_project(client, user_session):
|
||||||
|
owner = UserFactory.create()
|
||||||
|
workspace = WorkspaceFactory.create()
|
||||||
|
Workspaces._create_workspace_role(owner, workspace, "admin")
|
||||||
|
project = Projects.create(
|
||||||
|
owner,
|
||||||
|
workspace,
|
||||||
|
"Snazzy Project",
|
||||||
|
"A new project for me and my friends",
|
||||||
|
{"env1", "env2"},
|
||||||
|
)
|
||||||
|
user_session(owner)
|
||||||
|
response = client.get(
|
||||||
|
"/workspaces/{}/projects/{}/edit".format(workspace.id, project.id)
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_member(client, user_session):
|
||||||
|
owner = UserFactory.create()
|
||||||
|
user = UserFactory.create()
|
||||||
|
workspace = WorkspaceFactory.create()
|
||||||
|
Workspaces._create_workspace_role(owner, workspace, "admin")
|
||||||
|
user_session(owner)
|
||||||
|
response = client.post(
|
||||||
|
url_for("workspaces.create_member", workspace_id=workspace.id),
|
||||||
|
data={
|
||||||
|
"dod_id": user.dod_id,
|
||||||
|
"first_name": "Wilbur",
|
||||||
|
"last_name": "Zuckerman",
|
||||||
|
"email": "some_pig@zuckermans.com",
|
||||||
|
"workspace_role": "developer",
|
||||||
|
},
|
||||||
|
follow_redirects=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert user.has_workspaces
|
||||||
|
|
||||||
|
|
||||||
|
def test_permissions_for_view_member(client, user_session):
|
||||||
|
user = UserFactory.create()
|
||||||
|
workspace = WorkspaceFactory.create()
|
||||||
|
Workspaces._create_workspace_role(user, workspace, "developer")
|
||||||
|
member = WorkspaceUsers.add(user, workspace.id, "developer")
|
||||||
|
user_session(user)
|
||||||
|
response = client.post(
|
||||||
|
url_for("workspaces.view_member", workspace_id=workspace.id, member_id=user.id),
|
||||||
|
follow_redirects=True,
|
||||||
|
)
|
||||||
|
assert response.status_code == 404
|
||||||
|
|
||||||
|
|
||||||
def test_update_member_workspace_role(client, user_session):
|
def test_update_member_workspace_role(client, user_session):
|
||||||
owner = UserFactory.create()
|
owner = UserFactory.create()
|
||||||
workspace = WorkspaceFactory.create()
|
workspace = WorkspaceFactory.create()
|
||||||
@ -91,6 +144,24 @@ def test_update_member_workspace_role(client, user_session):
|
|||||||
assert member.role == "security_auditor"
|
assert member.role == "security_auditor"
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_member_workspace_role_with_no_data(client, user_session):
|
||||||
|
owner = UserFactory.create()
|
||||||
|
workspace = WorkspaceFactory.create()
|
||||||
|
Workspaces._create_workspace_role(owner, workspace, "admin")
|
||||||
|
user = UserFactory.create()
|
||||||
|
member = WorkspaceUsers.add(user, workspace.id, "developer")
|
||||||
|
user_session(owner)
|
||||||
|
response = client.post(
|
||||||
|
url_for(
|
||||||
|
"workspaces.update_member", workspace_id=workspace.id, member_id=user.id
|
||||||
|
),
|
||||||
|
data={},
|
||||||
|
follow_redirects=True,
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert member.role == "developer"
|
||||||
|
|
||||||
|
|
||||||
def test_update_member_environment_role(client, user_session):
|
def test_update_member_environment_role(client, user_session):
|
||||||
owner = UserFactory.create()
|
owner = UserFactory.create()
|
||||||
workspace = WorkspaceFactory.create()
|
workspace = WorkspaceFactory.create()
|
||||||
@ -124,3 +195,32 @@ def test_update_member_environment_role(client, user_session):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert EnvironmentRoles.get(user.id, env1_id).role == "security_auditor"
|
assert EnvironmentRoles.get(user.id, env1_id).role == "security_auditor"
|
||||||
assert EnvironmentRoles.get(user.id, env2_id).role == "devops"
|
assert EnvironmentRoles.get(user.id, env2_id).role == "devops"
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_member_environment_role_with_no_data(client, user_session):
|
||||||
|
owner = UserFactory.create()
|
||||||
|
workspace = WorkspaceFactory.create()
|
||||||
|
Workspaces._create_workspace_role(owner, workspace, "admin")
|
||||||
|
|
||||||
|
user = UserFactory.create()
|
||||||
|
member = WorkspaceUsers.add(user, workspace.id, "developer")
|
||||||
|
project = Projects.create(
|
||||||
|
owner,
|
||||||
|
workspace,
|
||||||
|
"Snazzy Project",
|
||||||
|
"A new project for me and my friends",
|
||||||
|
{"env1"},
|
||||||
|
)
|
||||||
|
env1_id = project.environments[0].id
|
||||||
|
for env in project.environments:
|
||||||
|
Environments.add_member(env, user, "developer")
|
||||||
|
user_session(owner)
|
||||||
|
response = client.post(
|
||||||
|
url_for(
|
||||||
|
"workspaces.update_member", workspace_id=workspace.id, member_id=user.id
|
||||||
|
),
|
||||||
|
data={"env_" + str(env1_id): None, "env_" + str(env1_id): ""},
|
||||||
|
follow_redirects=True,
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert EnvironmentRoles.get(user.id, env1_id).role == "developer"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user