Skip to content

Commit

Permalink
Merge pull request #4654 from opensafely-core/iaindillingham/parametr…
Browse files Browse the repository at this point in the history
…ize-test

Parametrize `test_workspacecreateform_success`
  • Loading branch information
iaindillingham authored Oct 11, 2024
2 parents 6162c51 + ada412b commit 87d9486
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions tests/unit/jobserver/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,17 @@ def test_jobrequestcreateform_with_bad_codelists(
)


def test_workspacecreateform_success():
project = ProjectFactory()
data = {
"name": "test",
"repo": "http://example.com/derp/test-repo",
"branch": "test-branch",
"purpose": "test",
}
repos_with_branches = [
{
"name": "test-repo",
"url": "http://example.com/derp/test-repo",
"branches": ["test-branch"],
}
]
form = WorkspaceCreateForm(project, repos_with_branches, data)

assert form.is_valid()


def test_workspacecreateform_success_with_upper_case_names():
@pytest.mark.parametrize(
"name,cleaned_name",
[
pytest.param("test", "test", id="lower_case_name"),
pytest.param("TeSt", "test", id="mixed_case_name"),
],
)
def test_workspacecreateform_success(name, cleaned_name):
project = ProjectFactory()
data = {
"name": "TeSt",
"name": name,
"repo": "http://example.com/derp/test-repo",
"branch": "test-branch",
"purpose": "test",
Expand All @@ -134,7 +121,7 @@ def test_workspacecreateform_success_with_upper_case_names():
form = WorkspaceCreateForm(project, repos_with_branches, data)

assert form.is_valid()
assert form.cleaned_data["name"] == "test", form.cleaned_data["name"]
assert form.cleaned_data["name"] == cleaned_name


def test_workspacecreateform_unknown_branch():
Expand Down

0 comments on commit 87d9486

Please sign in to comment.