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
1 parent
387bfed
commit bb4dbb4
Showing
2 changed files
with
48 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,47 @@ | ||
# -*- coding: utf-8 -*- | ||
import codecs | ||
import Testing.ZopeTestCase | ||
import Testing.testbrowser | ||
import Zope2.App | ||
|
||
class SortingTests(Testing.ZopeTestCase.FunctionalTestCase): | ||
"""Browser testing ..Image.File""" | ||
|
||
def setUp(self): | ||
super(SortingTests, self).setUp() | ||
|
||
Zope2.App.zcml.load_site(force=True) | ||
|
||
uf = self.app.acl_users | ||
uf.userFolderAddUser('manager', 'manager_pass', ['Manager'], []) | ||
self.app.manage_addFolder('sortingTest') | ||
self.app.sortingTest.manage_addFile('File1') | ||
self.app.sortingTest.manage_addFile('File2') | ||
self.app.sortingTest.File1.update_data(u'hällo'.encode('utf-8')) | ||
|
||
self.browser = Testing.testbrowser.Browser() | ||
self.browser.addHeader( | ||
'Authorization', | ||
'basic {}'.format(codecs.encode( | ||
b'manager:manager_pass', 'base64').decode())) | ||
|
||
def test_sortby(self): | ||
base_url = 'http://localhost/sortingTest/manage_main?skey=%s&rkey=%s' | ||
|
||
def do_assert(one_before_two): | ||
one_before_two_found = ( | ||
self.browser.contents.find('File2') > self.browser.contents.find('File1') | ||
) | ||
self.assertTrue(one_before_two == one_before_two_found) | ||
|
||
self.browser.open(base_url % ('id', 'asc')) | ||
do_assert(one_before_two = True) | ||
|
||
self.browser.open(base_url % ('id', 'desc')) | ||
do_assert(one_before_two = False) | ||
|
||
self.browser.open(base_url % ('get_size', 'asc')) | ||
do_assert(one_before_two = False) | ||
|
||
self.browser.open(base_url % ('get_size', 'desc')) | ||
do_assert(one_before_two = True) |