annotate urlmatch.txt @ 10:b02420253bfd default tip

add recomposition and a test for it
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 28 Jun 2011 18:39:18 -0700
parents 8d47894191a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 urlmatch
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 ========
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
8
64935a05afdb stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
4 Test basic diff functionality::
64935a05afdb stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
5
64935a05afdb stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
6 >>> matcher = UrlMatcher()
64935a05afdb stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
7 >>> matcher.diff('http://www.example.com', 'http://example.com')
64935a05afdb stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
8 {'domain': [None, None, ('www', None)]}
64935a05afdb stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
9 >>> matcher.diff('http://example.com', 'https://example.com')
64935a05afdb stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
10 {'scheme': ('http', 'https')}
64935a05afdb stub tests for diff, as yet unfinished
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
11
0
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 Test making a basic tree::
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 >>> urlmatcher = URLmatcher()
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 >>> urls = ['http://example.com/foo/bar.html',
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 ... 'http://example.com/foo/baz.html',
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 ... 'http://example.com/foo/fleem.html']
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 >>> urlmatcher.add(*urls)
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 >>> urlmatcher.tree()
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 ['http://example.com/foo/': ['bar.html', 'baz.html', 'fleem.html']]
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 Now a more complex tree::
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 >>> urlmatcher = URLmatcher()
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 >>> urlmatcher.add(*['http://example.com/index.html',
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 ... 'https://example.com/,
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 ... 'http://gitcub.com/k0s'])
8bd0c3b2163e create urlmatch package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28 >>> urlmatcher.tree()
9
8d47894191a0 more stubbing of tests
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
29 ['example.com': ['http://example.com/index.html', 'https://example.com'],