~lifeless/python-oops-tools/bug-881400

« back to all changes in this revision

Viewing changes to src/oopstools/oops/test/oopsgroup.txt

  • Committer: Robert Collins
  • Date: 2011-10-13 20:18:51 UTC
  • Revision ID: robertc@robertcollins.net-20111013201851-ym8jmdhoeol3p83s
Export of cruft-deleted tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
= OopsGroup =
 
2
 
 
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
 
5
make testing easier.
 
6
 
 
7
    >>> from os.path import abspath, dirname, join
 
8
    >>> from oopstools.oops.oopsgroup import OopsGroup
 
9
    >>> from oopstools.oops.oopsstore import OopsStore
 
10
 
 
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')
 
16
 
 
17
Overwrite some oops attributes to help the testing.
 
18
 
 
19
    >>> oops1.referrer = 'http://google.com'
 
20
    >>> oops1.parsed_oops['value'] = 'Error value'
 
21
    >>> oops2.parsed_oops['value'] = 'Error value'
 
22
 
 
23
Initialize the oops group with an exception_type and exception_value.
 
24
 
 
25
    >>> oops1.exception_type
 
26
    u'SoftRequestTimeout'
 
27
    >>> oops1.exception_value
 
28
    'Error value'
 
29
 
 
30
    >>> oops_group = OopsGroup(oops1.exception_type, oops1.exception_value)
 
31
 
 
32
    >>> oops_group.addOops(oops1)
 
33
    >>> oops_group.addOops(oops2)
 
34
 
 
35
printTopReferrer() returns the most common local referrer.
 
36
 
 
37
    >>> oops_group.printTopReferrer()
 
38
    u'https://translations.staging.launchpad.net/'
 
39
 
 
40
The _isLocalReferrer() method returns True for local domains like
 
41
launchpad.net or ubuntu.com.
 
42
 
 
43
    >>> referrer = 'https://launchpad.net/foo'
 
44
    >>> oops_group._isLocalReferrer(referrer)
 
45
    True
 
46
    >>> referrer = 'http://wiki.ubuntu.com'
 
47
    >>> oops_group._isLocalReferrer(referrer)
 
48
    True
 
49
    >>> referrer = (
 
50
    ...     'http://example.com/whatever?q=https://launchpad.net/foo')
 
51
    >>> oops_group._isLocalReferrer(referrer)
 
52
    False
 
53