<s> from datetime import datetime , timedelta <EOL> import unittest <EOL> from trac . core import Component , TracError , implements <EOL> from trac . perm import IPermissionPolicy <EOL> from trac . resource import Resource <EOL> from trac . test import MockRequest <EOL> from trac . util . datefmt import utc <EOL> from trac . versioncontrol . api import ( <EOL> Changeset , DbRepositoryProvider , IRepositoryConnector , Node , <EOL> NoSuchChangeset , Repository ) <EOL> from trac . versioncontrol . web_ui . log import LogModule <EOL> from trac . web . api import parse_arg_list <EOL> from trac . web . chrome import web_context <EOL> from trac . web . tests . api import RequestHandlerPermissionsTestCaseBase <EOL> from trac . wiki . formatter import format_to_oneliner <EOL> mock_repotype = '<STR_LIT>' + __name__ <EOL> class MockRepositoryConnector ( Component ) : <EOL> implements ( IRepositoryConnector ) <EOL> def get_supported_types ( self ) : <EOL> yield mock_repotype , <NUM_LIT:8> <EOL> def get_repository ( self , repos_type , repos_dir , params ) : <EOL> return MockRepository ( '<STR_LIT>' + repos_dir , params , self . log ) <EOL> class TestLogModulePermissionPolicy ( Component ) : <EOL> implements ( IPermissionPolicy ) <EOL> def check_permission ( self , action , username , resource , perm ) : <EOL> if action == '<STR_LIT>' and resource . realm == '<STR_LIT>' : <EOL> return username != '<STR_LIT>' <EOL> class MockRepository ( Repository ) : <EOL> has_linear_changesets = True <EOL> def get_youngest_rev ( self ) : <EOL> return <NUM_LIT:100> <EOL> def normalize_path ( self , path ) : <EOL> return path . strip ( '<STR_LIT:/>' ) if path else '<STR_LIT>' <EOL> def normalize_rev ( self , rev ) : <EOL> if rev is None or rev == '<STR_LIT>' : <EOL> return self . youngest_rev <EOL> try : <EOL> nrev = int ( rev ) <EOL> except : <EOL> raise NoSuchChangeset ( rev ) <EOL> else : <EOL> if not ( <NUM_LIT:1> <= nrev <= self . youngest_rev ) or nrev % <NUM_LIT:3> != <NUM_LIT:1> : <EOL> raise NoSuchChangeset ( rev ) <EOL> return nrev <EOL> def get_node ( self , path , rev ) : <EOL> assert rev % <NUM_LIT:3> == <NUM_LIT:1> <EOL> assert path in ( '<STR_LIT:file>' , '<STR_LIT>' ) <EOL> return MockNode ( self , path , rev , Node . FILE ) <EOL> def get_changeset ( self , rev ) : <EOL> assert rev % <NUM_LIT:3> == <NUM_LIT:1> <EOL> return MockChangeset ( self , rev , '<STR_LIT>' % rev , '<STR_LIT>' % rev , <EOL> datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , tzinfo = utc ) + <EOL> timedelta ( seconds = rev ) ) <EOL> def previous_rev ( self , rev , path = '<STR_LIT>' ) : <EOL> assert rev % <NUM_LIT:3> == <NUM_LIT:1> <EOL> return rev - <NUM_LIT:3> if rev > <NUM_LIT:0> else None <EOL> def get_path_history ( self , path , rev = None , limit = None ) : <EOL> histories = [ ( path , <NUM_LIT:100> , Changeset . DELETE ) , <EOL> ( path , <NUM_LIT> , Changeset . MOVE ) , <EOL> ( path + '<STR_LIT>' , <NUM_LIT:1> , Changeset . ADD ) ] <EOL> for history in histories : <EOL> if limit is not None and limit <= <NUM_LIT:0> : <EOL> break <EOL> if rev is None or rev >= history [ <NUM_LIT:1> ] : <EOL> yield history <EOL> if limit is not None : <EOL> limit -= <NUM_LIT:1> <EOL> def rev_older_than ( self , rev1 , rev2 ) : <EOL> return self . normalize_rev ( rev1 ) < self . normalize_rev ( rev2 ) <EOL> def close ( self ) : <EOL> pass <EOL> def _not_implemented ( self , * args , ** kwargs ) : <EOL> raise NotImplementedError <EOL> get_changes = _not_implemented <EOL> get_oldest_rev = _not_implemented <EOL> next_rev = _not_implemented <EOL> class MockChangeset ( Changeset ) : <EOL> def get_changes ( self ) : <EOL> raise StopIteration <EOL> class MockNode ( Node ) : <EOL> def __init__ ( self , repos , path , rev , kind ) : <EOL> super ( MockNode , self ) . __init__ ( repos , path , rev , kind ) <EOL> self . created_path = path <EOL> self . created_rev = rev <EOL> def get_history ( self , limit = None ) : <EOL> youngest_rev = self . repos . youngest_rev <EOL> rev = self . rev <EOL> path = self . path <EOL> while rev > <NUM_LIT:0> : <EOL> if limit is not None : <EOL> if limit <= <NUM_LIT:0> : <EOL> return <EOL> limit -= <NUM_LIT:1> <EOL> if rev == <NUM_LIT:1> : <EOL> change = Changeset . ADD <EOL> elif rev == <NUM_LIT> : <EOL> change = Changeset . MOVE <EOL> elif rev == youngest_rev : <EOL> change = Changeset . DELETE <EOL> else : <EOL> change = Changeset . EDIT <EOL> yield path , rev , change <EOL> if rev == <NUM_LIT> : <EOL> path += '<STR_LIT>' <EOL> rev -= <NUM_LIT:3> <EOL> def _not_implemented ( self , * args , ** kwargs ) : <EOL> raise NotImplementedError <EOL> get_annotations = _not_implemented <EOL> get_content = _not_implemented <EOL> get_content_length = _not_implemented <EOL> get_content_type = _not_implemented <EOL> get_entries = _not_implemented <EOL> get_last_modified = _not_implemented <EOL> get_properties = _not_implemented <EOL> class LogModuleTestCase ( RequestHandlerPermissionsTestCaseBase ) : <EOL> def setUp ( self ) : <EOL> self . _super = super ( LogModuleTestCase , self ) <EOL> self . _super . setUp ( LogModule ) <EOL> provider = DbRepositoryProvider ( self . env ) <EOL> provider . add_repository ( '<STR_LIT>' , '<STR_LIT:/>' , mock_repotype ) <EOL> def test_default_repository_not_configured ( self ) : <EOL> """<STR_LIT>""" <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , args = { '<STR_LIT>' : '<STR_LIT:/>' } ) <EOL> self . assertRaises ( TracError , self . process_request , req ) <EOL> def test_without_rev ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT:4>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> self . assertEqual ( '<STR_LIT>' , template ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:5> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] + [ '<STR_LIT>' ] * <NUM_LIT:3> + [ None ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> links = req . chrome [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' , links [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( links ) ) <EOL> def test_with_rev ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:5> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:4> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] * <NUM_LIT:3> + [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_with_rev_and_limit ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:4>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:5> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:4> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:4> + [ <NUM_LIT:2> ] , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:4> + [ '<STR_LIT>' ] , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] * <NUM_LIT:3> + [ '<STR_LIT>' , None ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> links = req . chrome [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' , links [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( links ) ) <EOL> def test_with_rev_on_start ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:4> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT:10> , <NUM_LIT:7> , <NUM_LIT:4> , <NUM_LIT:1> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] * <NUM_LIT:4> , [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:4> , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:4> , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] * <NUM_LIT:3> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_with_rev_and_limit_on_start ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:4>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:4> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT:10> , <NUM_LIT:7> , <NUM_LIT:4> , <NUM_LIT:1> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] * <NUM_LIT:4> , [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:4> , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:4> , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] * <NUM_LIT:3> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_with_invalid_rev ( self ) : <EOL> def fn ( message , ** kwargs ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , ** kwargs ) <EOL> try : <EOL> self . process_request ( req ) <EOL> except NoSuchChangeset as e : <EOL> self . assertEqual ( message , unicode ( e ) ) <EOL> fn ( '<STR_LIT>' , args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> fn ( '<STR_LIT>' , args = { '<STR_LIT>' : '<STR_LIT:0>' } ) <EOL> fn ( '<STR_LIT>' , args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_revranges_1 ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:9> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:9> , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:9> , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:9> , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None , '<STR_LIT>' , '<STR_LIT>' , None , <EOL> '<STR_LIT>' , None ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_revranges_2 ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:5> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:4> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:4> + [ <NUM_LIT:2> ] , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:4> + [ '<STR_LIT>' ] , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] * <NUM_LIT:3> + [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_revranges_3 ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:8> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:7> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:7> + [ <NUM_LIT:2> ] , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:7> + [ '<STR_LIT>' ] , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_revranges_4 ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:8> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:7> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:7> + [ <NUM_LIT:2> ] , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:7> + [ '<STR_LIT>' ] , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_revranges_1_with_limit ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:4>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:6> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:6> , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:6> , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:6> , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None , '<STR_LIT>' , None ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> links = req . chrome [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' , links [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( links ) ) <EOL> def test_revranges_1_next_link_with_limits ( self ) : <EOL> def next_link_args ( limit ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : str ( limit ) } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> links = req . chrome [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in links : <EOL> link = links [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> path_info , query_string = link . split ( '<STR_LIT:?>' , <NUM_LIT:1> ) <EOL> return dict ( parse_arg_list ( query_string ) ) <EOL> else : <EOL> return None <EOL> self . assertEqual ( { '<STR_LIT>' : '<STR_LIT:1>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , next_link_args ( <NUM_LIT:1> ) ) <EOL> self . assertEqual ( { '<STR_LIT>' : '<STR_LIT:2>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , next_link_args ( <NUM_LIT:2> ) ) <EOL> self . assertEqual ( { '<STR_LIT>' : '<STR_LIT:3>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , next_link_args ( <NUM_LIT:3> ) ) <EOL> self . assertEqual ( { '<STR_LIT>' : '<STR_LIT:4>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , next_link_args ( <NUM_LIT:4> ) ) <EOL> self . assertEqual ( { '<STR_LIT>' : '<STR_LIT:5>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , next_link_args ( <NUM_LIT:5> ) ) <EOL> self . assertEqual ( None , next_link_args ( <NUM_LIT:6> ) ) <EOL> def test_revranges_2_with_limit ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:4>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:5> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:4> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:4> + [ <NUM_LIT:2> ] , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:4> + [ '<STR_LIT>' ] , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] * <NUM_LIT:3> + [ '<STR_LIT>' , None ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> links = req . chrome [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' , links [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( links ) ) <EOL> def test_revranges_3_with_limit ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:8> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:7> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:7> + [ <NUM_LIT:2> ] , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:7> + [ '<STR_LIT>' ] , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_revranges_4_with_limit ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:8> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' ] * <NUM_LIT:7> + [ '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> ] * <NUM_LIT:7> + [ <NUM_LIT:2> ] , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None ] * <NUM_LIT:7> + [ '<STR_LIT>' ] , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_invalid_revranges ( self ) : <EOL> def fn ( message , ** kwargs ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , ** kwargs ) <EOL> try : <EOL> self . process_request ( req ) <EOL> except NoSuchChangeset as e : <EOL> self . assertEqual ( message , unicode ( e ) ) <EOL> fn ( '<STR_LIT>' , args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> fn ( '<STR_LIT>' , args = { '<STR_LIT>' : '<STR_LIT:0>' } ) <EOL> fn ( '<STR_LIT>' , args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> fn ( '<STR_LIT>' , args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> fn ( '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> fn ( '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_follow_copy ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:4>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:5> , len ( items ) ) <EOL> self . assertEqual ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT:file>' , '<STR_LIT:file>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT:path>' ] for item in items ] ) <EOL> self . assertEqual ( [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ] , [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertEqual ( [ None , None , '<STR_LIT>' , None , None ] , <EOL> [ item . get ( '<STR_LIT>' ) for item in items ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> links = req . chrome [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' , links [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( links ) ) <EOL> def test_path_history ( self ) : <EOL> req = MockRequest ( self . env , path_info = '<STR_LIT>' , <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> template , data , ctype = self . process_request ( req ) <EOL> items = data [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:3> , len ( items ) ) <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ item [ '<STR_LIT>' ] for item in items ] ) <EOL> self . assertNotIn ( '<STR_LIT>' , req . chrome [ '<STR_LIT>' ] ) <EOL> def test_log_link_checking_repository_resource ( self ) : <EOL> self . env . config . set ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> resource = Resource ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> req = MockRequest ( self . env , authname = '<STR_LIT>' ) <EOL> rendered = unicode ( format_to_oneliner ( self . env , <EOL> web_context ( req , resource ) , <EOL> '<STR_LIT>' ) ) <EOL> self . assertIn ( '<STR_LIT>' , rendered ) <EOL> req = MockRequest ( self . env , authname = '<STR_LIT>' ) <EOL> rendered = unicode ( format_to_oneliner ( self . env , <EOL> web_context ( req , resource ) , <EOL> '<STR_LIT>' ) ) <EOL> self . assertIn ( '<STR_LIT>' , rendered ) <EOL> def suite ( ) : <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( unittest . makeSuite ( LogModuleTestCase ) ) <EOL> return suite <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
