-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #741 from CDLUC3/develop
Merge Develop to main for Python 311 upgrade
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
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,33 @@ | ||
# Copyright©2021, Regents of the University of California | ||
# http://creativecommons.org/licenses/BSD | ||
|
||
import pytest | ||
|
||
from django.test import RequestFactory | ||
import impl.api as api | ||
|
||
@pytest.fixture | ||
def factory(): | ||
return RequestFactory() | ||
|
||
@pytest.mark.parametrize("val,expected",[ | ||
('text/plain', True), | ||
('text/plain; charset=utf-8', True), | ||
('text/plain; charset=UTF-8', True), | ||
('TEXT/PLAIN; charset=utf-8', False), | ||
('text/plain; charset=US-ASCII', False), | ||
('; charset=utf-8', True), # mimetype='' | ||
('; charset=US-ASCII', False), # mimetype='' | ||
('charset=utf-8', False), | ||
('charset=US-ASCII', False), | ||
('text/html', False), | ||
('text/xml; charset=utf-8', False), | ||
('application/json', False), | ||
('application/javascript', False), | ||
('application/x-www-form-urlencoded', False), | ||
]) | ||
def test_content_type_1(factory, val, expected): | ||
request = factory.post('/shoulder/ark:/99999/fk4', content_type=val) | ||
ret = api.is_text_plain_utf8(request) | ||
assert ret == expected | ||
|
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,55 @@ | ||
import pytest | ||
import re | ||
|
||
import impl.form_objects as form_objects | ||
|
||
|
||
@pytest.mark.parametrize("string,expected",[ | ||
('2000', '2000'), | ||
('200', None), | ||
('2', None), | ||
('x', None), | ||
('yyyy', None), | ||
('', None), | ||
(':unac', ':unac'), | ||
(':unal', ':unal'), | ||
(':unap', ':unap'), | ||
(':unas', ':unas'), | ||
(':unav', ':unav'), | ||
(':unkn', ':unkn'), | ||
(':none', ':none'), | ||
(':tba', ':tba'), | ||
(':tba', ':tba'), | ||
(':tba', ':tba'), | ||
]) | ||
def test_regex_year(string, expected): | ||
pattern = form_objects.REGEX_4DIGITYEAR | ||
match = re.search(pattern, string) | ||
if match: | ||
assert match.group() == expected | ||
|
||
# REGEX_GEOPOINT = '-?(\d+(\.\d*)?|\.\d+)$' | ||
@pytest.mark.parametrize("string,expected",[ | ||
('-123.456', '-123.456'), | ||
('123.456', '123.456'), | ||
('1.', '1.'), | ||
('-1.', '-1.'), | ||
('12.', '12.'), | ||
('.1', '.1'), | ||
('-.1', '-.1'), | ||
('.456', '.456'), | ||
('-.456', '-.456'), | ||
('.', None), | ||
('x', None), | ||
('yyyy', None), | ||
('', None), | ||
]) | ||
def test_regex_geopoint(string, expected): | ||
pattern = form_objects.REGEX_GEOPOINT | ||
match = re.search(pattern, string) | ||
if match: | ||
assert match.group() == expected | ||
|
||
|
||
|
||
|