Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
weboob
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
177
Issues
177
List
Boards
Labels
Milestones
Merge Requests
49
Merge Requests
49
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
weboob
weboob
Commits
0a3300c8
Commit
0a3300c8
authored
Oct 19, 2014
by
Laurent Bachelier
🐧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
browser tests: Fixes
pyflakes/pep8, test name in setup.cfg, remove useless comments
parent
8a6c6571
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
27 deletions
+14
-27
setup.cfg
setup.cfg
+1
-1
weboob/browser/tests_class_Form.py
weboob/browser/tests_class_Form.py
+7
-6
weboob/browser/tests_class_URL.py
weboob/browser/tests_class_URL.py
+6
-20
No files found.
setup.cfg
View file @
0a3300c8
...
...
@@ -15,7 +15,7 @@ tests = weboob.tools.capabilities.bank.transactions,
weboob.browser.pages,
weboob.browser.filters.standard,
weboob.browser.tests_class_URL,
weboob.browser
_
tests_class_Form
weboob.browser
.
tests_class_Form
[isort]
known_first_party=weboob
...
...
weboob/browser/tests_class_Form.py
View file @
0a3300c8
...
...
@@ -15,12 +15,14 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from
unittest
import
TestCase
from
weboob.browser
import
URL
from
weboob.browser.pages
import
Form
,
FormSubmitWarning
,
HTMLPage
import
collections
import
lxml.html
import
warnings
from
unittest
import
TestCase
import
lxml.html
from
weboob.browser
import
URL
from
weboob.browser.pages
import
Form
,
FormSubmitWarning
# Mock that allows to represent a Page
...
...
@@ -48,7 +50,7 @@ class FormTest(TestCase):
</select>
<input type='submit' name='submitForm' />
</form>"""
)
self
.
elMoreSubmit
=
lxml
.
html
.
fromstring
(
self
.
elMoreSubmit
=
lxml
.
html
.
fromstring
(
"""<form method='GET'>
<input type ='text' name='nom' value='Dupont'/>
<input type ='text' name='prenom' value=''/>
...
...
@@ -103,4 +105,3 @@ class FormTest(TestCase):
assert
len
(
w
)
==
1
assert
issubclass
(
w
[
-
1
]
.
category
,
FormSubmitWarning
)
assert
warningMsg
in
str
(
w
[
-
1
]
.
message
)
weboob/browser/tests_class_URL.py
View file @
0a3300c8
...
...
@@ -16,7 +16,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from
unittest
import
TestCase
from
weboob.browser
import
URL
,
PagesBrowser
from
weboob.browser
import
PagesBrowser
,
URL
from
weboob.browser.pages
import
Page
from
weboob.browser.url
import
UrlNotResolvable
...
...
@@ -27,7 +28,7 @@ class MyMockBrowserWithoutBrowser():
# Mock that allows to represent a Page
class
m
yMockPage
(
Page
):
class
M
yMockPage
(
Page
):
pass
...
...
@@ -46,8 +47,8 @@ class MyMockBrowser(PagesBrowser):
urlParams
=
URL
(
"http://test.com
\
?id=(?P<id>
\
d+)&name=(?P<name>.+)"
)
# URL used by method is_here
urlIsHere
=
URL
(
'http://weboob.org/(?P<param>)'
,
m
yMockPage
)
urlIsHereDifKlass
=
URL
(
'http://free.fr'
,
m
yMockPage
)
urlIsHere
=
URL
(
'http://weboob.org/(?P<param>)'
,
M
yMockPage
)
urlIsHereDifKlass
=
URL
(
'http://free.fr'
,
M
yMockPage
)
# Class that tests different methods from the class URL
...
...
@@ -58,8 +59,6 @@ class URLTest(TestCase):
self
.
myBrowser
=
MyMockBrowser
()
self
.
myBrowserWithoutBrowser
=
MyMockBrowserWithoutBrowser
()
# TESTS FOR MATCH METHOD
# Check that an assert is sent if both base and browser are none
def
test_match_base_none_browser_none
(
self
):
self
.
assertRaises
(
AssertionError
,
...
...
@@ -79,41 +78,31 @@ class URLTest(TestCase):
# Check that none is returned when none of the defined urls is a regex for
# the given url
def
test_match_url_pasregex_baseurl
(
self
):
# Test
res
=
self
.
myBrowser
.
urlNotRegex
.
match
(
"http://weboob.org/news"
)
# Assertions
self
.
assertIsNone
(
res
)
# Check that true is returned when one of the defined urls is a regex
# for the given url
def
test_match_url_regex_baseurl
(
self
):
# Test
res
=
self
.
myBrowser
.
urlRegex
.
match
(
"http://weboob2.org/news"
)
# Assertions
self
.
assertTrue
(
res
)
# Successful test with relatives url
def
test_match_url_without_http
(
self
):
# Test
res
=
self
.
myBrowser
.
urlRegWithoutHttp
.
match
(
"http://weboob.org/news"
)
# Assertions
self
.
assertTrue
(
res
)
# Unsuccessful test with relatives url
def
test_match_url_without_http_fail
(
self
):
# Test
browser
=
self
.
myBrowser
res
=
browser
.
urlNotRegWithoutHttp
.
match
(
"http://weboob.org/news"
)
# Assertions
self
.
assertIsNone
(
res
)
# TESTS FOR BUILD METHOD
# Checks that build returns the right url when it needs to add
# the value of a parameter
def
test_build_nominal_case
(
self
):
res
=
self
.
myBrowser
.
urlValue
.
build
(
id
=
2
)
self
.
assertEquals
(
res
,
"http://test.com/2"
)
self
.
assertEquals
(
res
,
"http://test.com/2"
)
# Checks that build returns the right url when it needs to add
# identifiers and values of some parameters
...
...
@@ -133,11 +122,8 @@ class URLTest(TestCase):
self
.
assertRaises
(
UrlNotResolvable
,
self
.
myBrowser
.
urlParams
.
build
,
id
=
2
,
name
=
"weboob"
,
title
=
"test"
)
# TESTS FOR IS_HERE METHOD
# Check that an assert is sent if both klass is none
def
test_ishere_klass_none
(
self
):
self
.
assertRaisesRegexp
(
AssertionError
,
"You can use this method"
+
" only if there is a Page class handler."
,
self
.
myBrowser
.
urlRegex
.
is_here
,
id
=
2
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment