-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
from typer import BadParameter | ||
|
||
from data_safe_haven.functions.typer_validators import typer_validate_aad_guid | ||
|
||
|
||
class TestTyperValidateAadGuid: | ||
@pytest.mark.parametrize( | ||
"guid", | ||
[ | ||
"d5c5c439-1115-4cb6-ab50-b8e547b6c8dd", | ||
"10de18e7-b238-6f1e-a4ad-772708929203", | ||
] | ||
) | ||
def test_typer_validate_aad_guid(self, guid): | ||
assert typer_validate_aad_guid(guid) == guid | ||
|
||
@pytest.mark.parametrize( | ||
"guid", | ||
[ | ||
"10de18e7_b238_6f1e_a4ad_772708929203", | ||
"not a guid", | ||
] | ||
) | ||
def test_typer_validate_aad_guid_fail(self, guid): | ||
with pytest.raises(BadParameter) as exc: | ||
typer_validate_aad_guid(guid) | ||
assert "Expected GUID" in exc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
|
||
from data_safe_haven.functions.validators import validate_aad_guid | ||
|
||
|
||
class TestValidateAadGuid: | ||
@pytest.mark.parametrize( | ||
"guid", | ||
[ | ||
"d5c5c439-1115-4cb6-ab50-b8e547b6c8dd", | ||
"10de18e7-b238-6f1e-a4ad-772708929203", | ||
] | ||
) | ||
def test_validate_aad_guid(self, guid): | ||
assert validate_aad_guid(guid) == guid | ||
|
||
@pytest.mark.parametrize( | ||
"guid", | ||
[ | ||
"10de18e7_b238_6f1e_a4ad_772708929203", | ||
"not a guid", | ||
] | ||
) | ||
def test_validate_aad_guid_fail(self, guid): | ||
with pytest.raises(ValueError) as exc: | ||
validate_aad_guid(guid) | ||
assert "Expected GUID" in exc |