forked from USEPA/haztrak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validate MTN function transfer from manifest app version 1
- Loading branch information
1 parent
3edead0
commit 1fc953a
Showing
3 changed files
with
39 additions
and
14 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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
import re | ||
from unittest.mock import MagicMock, patch | ||
|
||
import pytest | ||
from django.core.exceptions import ValidationError | ||
|
||
from apps.manif.models import draft_mtn, validate_mtn | ||
|
||
|
||
class TestManifestModel: | ||
def test_draft_mtn_follow_rcrainfo_pattern_with_dft_suffix(self, mocker): | ||
mock = MagicMock() | ||
mock.count.return_value = 5 | ||
with patch("apps.manif.models.Manifest2.objects.all", return_value=mock): | ||
result = draft_mtn() | ||
assert isinstance(result, str) | ||
assert re.match(r"\d{9}DFT", result) | ||
|
||
@pytest.mark.parametrize("mtn", ["123456789ELC", "111111111DFT", "100200300JJK"]) | ||
def test_mtn_validation_raises_no_error(self, mtn): | ||
assert validate_mtn(mtn) is None | ||
|
||
@pytest.mark.parametrize("mtn", ["foo_bar", "111111DFT", "123456789"]) | ||
def test_mtn_validation_raises_error(self, mtn): | ||
with pytest.raises(ValidationError): | ||
assert validate_mtn(mtn) is None |