3
OopsGroup is a data structure that holds information about a particular
4
exception type and value. We'll grab some OOPS reports from the OopsStore to
7
>>> from os.path import abspath, dirname, join
8
>>> from oopstools.oops.oopsgroup import OopsGroup
9
>>> from oopstools.oops.oopsstore import OopsStore
11
>>> here = dirname(__file__)
12
>>> oops_sample_path = abspath(join(here, 'files', 'oops-sample'))
13
>>> store = OopsStore(oops_sample_path)
14
>>> oops1 = store.find_oops('OOPS-689S6')
15
>>> oops2 = store.find_oops('OOPS-689S4')
17
Overwrite some oops attributes to help the testing.
19
>>> oops1.referrer = 'http://google.com'
20
>>> oops1.parsed_oops['value'] = 'Error value'
21
>>> oops2.parsed_oops['value'] = 'Error value'
23
Initialize the oops group with an exception_type and exception_value.
25
>>> oops1.exception_type
27
>>> oops1.exception_value
30
>>> oops_group = OopsGroup(oops1.exception_type, oops1.exception_value)
32
>>> oops_group.addOops(oops1)
33
>>> oops_group.addOops(oops2)
35
printTopReferrer() returns the most common local referrer.
37
>>> oops_group.printTopReferrer()
38
u'https://translations.staging.launchpad.net/'
40
The _isLocalReferrer() method returns True for local domains like
41
launchpad.net or ubuntu.com.
43
>>> referrer = 'https://launchpad.net/foo'
44
>>> oops_group._isLocalReferrer(referrer)
46
>>> referrer = 'http://wiki.ubuntu.com'
47
>>> oops_group._isLocalReferrer(referrer)
50
... 'http://example.com/whatever?q=https://launchpad.net/foo')
51
>>> oops_group._isLocalReferrer(referrer)