-
Notifications
You must be signed in to change notification settings - Fork 18
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
10 changed files
with
193 additions
and
116 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 |
---|---|---|
|
@@ -2,5 +2,5 @@ nose | |
mock | ||
tox | ||
wheel | ||
invoke | ||
invoke>=0.12.0,<0.13.0 | ||
sphinx |
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
__version__ = "0.3.0" | ||
__version__ = "0.4.0" | ||
|
||
from .storedobject import StoredObject | ||
from .ext.odmflask import FlaskStoredObject | ||
|
||
from .query.querydialect import DefaultQueryDialect as Q |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Flask | ||
blinker | ||
pymongo | ||
python-dateutil | ||
Werkzeug==0.11.11 |
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,42 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os.path | ||
import json | ||
|
||
from modularodm import StoredObject | ||
from modularodm.exceptions import ValidationError | ||
from modularodm.fields import StringField, IntegerField | ||
from modularodm.validators import URLValidator | ||
|
||
from tests.base import ModularOdmTestCase | ||
|
||
class UrlValueValidatorTestCase(ModularOdmTestCase): | ||
|
||
def test_url(self): | ||
basepath = os.path.dirname(__file__) | ||
url_data_path = os.path.join(basepath, 'urlValidatorTest.json') | ||
with open(url_data_path) as url_test_data: | ||
data = json.load(url_test_data) | ||
|
||
class Foo(StoredObject): | ||
_id = IntegerField() | ||
url_field = StringField( | ||
list=False, | ||
validate=[URLValidator()] | ||
) | ||
|
||
Foo.set_storage(self.make_storage()) | ||
test_object = Foo() | ||
|
||
for urlTrue in data['testsPositive']: | ||
test_object.url_field = urlTrue | ||
test_object.save() | ||
|
||
for urlFalse in data['testsNegative']: | ||
test_object.url_field = urlFalse | ||
try: | ||
with self.assertRaises(ValidationError): | ||
test_object.save() | ||
except AssertionError as e: | ||
e.args += (' for ', urlFalse) | ||
raise |
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,71 @@ | ||
{ | ||
"_comment": "These tests adapted from https://mathiasbynens.be/demo/url-regex", | ||
"testsPositive": { | ||
"definitelyawebsite.com":"should accept simple valid website", | ||
"https://Definitelyawebsite.com":"should accept valid website with protocol", | ||
"http://foo.com/blah_blah":"should accept valid website with path", | ||
"http://foo.com/blah_blah:5000/pathhere":"should accept valid website with port and path", | ||
"http://foo.com/blah_blah_(wikipedia)":"should accept valid website with parentheses in path", | ||
"https://userid@example.com/":"should accept valid user website", | ||
"http://userid@example.com:8080":"should accept valid user website with port", | ||
"http://userid:password@example.com/":"should accept valid user website with password", | ||
"http://userid:password@example.com:8080/":"should accept valid user and password website with path", | ||
"http://142.42.1.1":"should accept valid ipv4 website test 1", | ||
"http://10.1.1.0":"should accept valid ipv4 website test 2", | ||
"http://10.1.1.255":"should accept valid ipv4 website test 3", | ||
"http://224.1.1.1":"should accept valid ipv4 website test 4", | ||
"http://142.42.1.1:8080/":"should accept valid ipv4 website with port", | ||
"http://Bücher.de":"should accept valid website with unicode in domain", | ||
"http://heynow.ws/䨹":"should accept valid website with unicode in path", | ||
"http://localhost:5000/meetings":"should accept valid localhost website", | ||
"http://⌘.ws":"should accept valid website with only unicode in path", | ||
"http://⌘.ws/":"should accept valid website with only unicode in path and a / after domain", | ||
"http://foo.com/blah_(wikipedia)#cite-1":"should accept valid website with hashtag following parentheses in path", | ||
"http://foo.com/blah_(wikipedia)_blah#cite-1":"should accept valid website with hashtag in path", | ||
"http://foo.com/unicode_(✪)_in_parens":"should accept valid website with unicode in parentheses in path", | ||
"http://foo.com/(something)?after=parens":"should accept valid website with something after path", | ||
"http://staging.damowmow.com/":"should accept valid website with sub-domain", | ||
"http://☺.damowmow.com/":"should accept valid website with unicode in sub-domain", | ||
"http://code.google.com/events/#&product=browser":"should accept valid website with variables", | ||
"ftp://foo.bar/baz":"should acccept valid website with ftps", | ||
"http://foo.bar/?q=Test%20URL-encoded%20stuff":"should accept valid website with encoded stuff in path", | ||
"http://مثال.إختبار":"should accept valid unicode heavy website test 1", | ||
"http://例子.测试":"should accept valid unicode heavy website test 2", | ||
"http://उदाहरण.परीक्षा":"should accept valid unicode heavy website test 3", | ||
"http://-.~_!$&()*+,;=:%40:80%2f::::::@example.com":"should accept valid website with user but crazy username", | ||
"http://1337.net":"should accept valid website with just numbers in domain", | ||
"definitelyawebsite.com?real=yes&page=definitely":"should accept valid website with query", | ||
"http://a.b-c.de":"should accept valid website with dash", | ||
"http://website.com:3000/?q=400":"should accept valid website with port and query", | ||
"http://asd/asd@asd.com/":"should accept valid website with unusual username" | ||
}, | ||
"testsNegative": { | ||
"notevenclose": "should deny simple invalid website", | ||
"http://": "should deny invalid website with only http://", | ||
"http://.": "should deny invalid website with only http://.", | ||
"http://..": "should deny invalid website with only http://..", | ||
"http://../": "should deny invalid website with only http://../", | ||
"http://?": "should deny invalid website with only http://?", | ||
"http://??": "should deny invalid website with only http://??", | ||
"http://??/": "should deny invalid website with only http://??/", | ||
"http://#": "should deny invalid website with only http://#", | ||
"http://##": "should deny invalid website with only http://##", | ||
"http://##/": "should deny invalid website with only http://##/", | ||
"http://foo.bar?q=Spaces should be encoded": "should deny invalid website with spaces in path", | ||
"//": "should deny invalid website with only //", | ||
"//a": "should deny invalid website with only //a", | ||
"///a": "should deny invalid website with only ///a", | ||
"///": "should deny invalid website with only ///", | ||
"http:///a": "should deny invalid website with three / in protocol", | ||
"rdar://1234": "should deny invalid website with invalid protocol", | ||
"h://test": "should deny invalid website with missing letters from protocol", | ||
"http:// shouldfail.com": "should deny invalid website with space in beginning of domain", | ||
"http://should fail": "should deny invalid website with space in middle of domain", | ||
"http://-error-.invalid/": "should deny invalid website with dash at beginning and end of domain", | ||
"http://1.1.1.1.1": "should deny invalid ipv4 website with 5 numbers", | ||
"http://567.100.100.100": "should deny invalid ipv4 website with a number out of range", | ||
"http://-a.b.co": "should deny invalid website with dash at beginning of sub-domain", | ||
"http://.www.foo.bar/": "should deny invalid website with dot before sub-domain", | ||
"httsp://userid@example.com/": "should deny invalid website with username and invalid scheme" | ||
} | ||
} |