ó
ýGpNc           @   s¬   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d e j j f d „  ƒ  YZ d e j	 f d „  ƒ  YZ
 e d k r¨ d d l Z e j ƒ  n  d S(   sI   Simple in-memory CrashDatabase implementation, mainly useful for testing.iÿÿÿÿNt   CrashDatabasec           B   sÎ   e  Z d  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e d d d „ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s‘   Simple implementation of crash database interface which keeps everything
    in memory.
    
    This is mainly useful for testing and debugging.c         C   sZ   t  j j j |  | | | ƒ g  |  _ t ƒ  |  _ t ƒ  |  _ d | k rV |  j ƒ  n  d S(   ss   Initialize crash database connection.
        
        This class does not support bug patterns and authentication.t
   dummy_dataN(	   t   apportt   crashdbR    t   __init__t   reportst   sett
   unretracedt   dup_uncheckedt   add_dummy_data(   t   selft	   auth_filet   bugpattern_urlt   options(    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyR      s    
	c         C   sr   |  j  j i | d 6d d 6d d 6d d 6ƒ t |  j  ƒ d } d | k r^ |  j j | ƒ n |  j j | ƒ | S(	   s„   Store the report and return a handle number (starting from 0).
        
        This does not support (nor need) progress callbacks.t   reportt   fixed_versiont   dup_oft    s   comment:i   t	   TracebackN(   R   t   appendt   Nonet   lenR   t   addR   (   R
   R   t   progress_callbackt   id(    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   upload'   s    c         C   s-   | j  d ƒ r! d | d | f Sd | Sd S(   s™   Return http://<sourcepackage>.bugs.example.com/<handle> for package bugs
        or http://bugs.example.com/<handle> for reports without a SourcePackage.t   SourcePackages   http://%s.bugs.example.com/%is   http://bugs.example.com/%iN(   t   has_key(   R
   R   t   handle(    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   get_comment_url5   s    
c         C   s   |  j  | d S(   s>   Download the problem report from given ID and return a Report.R   (   R   (   R
   R   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   download?   s    c         C   s   |  j  | d d g S(   s5   Return list of affected source packages for given ID.R   R   (   R   (   R
   R   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   get_affected_packagesD   s    c         C   s   t  S(   s3   Check whether the user is the reporter of given ID.(   t   True(   R
   R   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   is_reporterI   s    c         C   s   |  j  | ƒ S(   sB  Check whether the user is eligible to update a report.

        A user should add additional information to an existing ID if (s)he is
        the reporter or subscribed, the bug is open, not a duplicate, etc. The
        exact policy and checks should be done according to  the particular
        implementation.
        (   R!   (   R
   R   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt
   can_updateN   s    c   	      C   sg   |  j  | } | | d <| rR xC | D]' } | | k r$ | | | d | <q$ q$ Wn | d j | ƒ d S(   sq  Update the given report ID with all data from report.

        This creates a text comment with the "short" data (see
        ProblemReport.write_mime()), and creates attachments for all the
        bulk/binary data. 
        
        If change_description is True, and the crash db implementation supports
        it, the short data will be put into the description instead (like in a
        new bug).

        comment will be added to the "short" data. If attachment_comment is
        given, it will be added to the attachment uploads.

        If key_filter is a list or set, then only those keys will be added.
        t   commentR   N(   R   t   update(	   R
   R   R   R#   t   change_descriptiont   attachment_commentt
   key_filtert   rt   f(    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyR$   X   s    
c         C   s   |  j  | d d S(   sN   Get 'DistroRelease: <release>' from the given report ID and return
        it.R   t   DistroRelease(   R   (   R
   R   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   get_distro_releases   s    c         C   sk   t  ƒ  } x[ t t |  j ƒ ƒ D]D } |  j | d d k r |  j | d d k r | j | ƒ q q W| S(   sW  Return an ID set of all crashes which are not yet fixed.

        The list must not contain bugs which were rejected or duplicate.
        
        This function should make sure that the returned list is correct. If
        there are any errors with connecting to the crash database, it should
        raise an exception (preferably IOError).R   R   N(   R   t   xrangeR   R   R   R   (   R
   t   resultt   i(    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   get_unfixedy   s    		c         C   sG   y. |  j  | d d k r d S|  j  | d SWn t k
 rB d SXd S(   s  Return the package version that fixes a given crash.

        Return None if the crash is not yet fixed, or an empty string if the
        crash is fixed, but it cannot be determined by which version. Return
        'invalid' if the crash report got invalidated, such as closed a
        duplicate or rejected.

        This function should make sure that the returned result is correct. If
        there are any errors with connecting to the crash database, it should
        raise an exception (preferably IOError).R   t   invalidR   N(   R   R   t
   IndexError(   R
   R   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   get_fixed_versionŠ   s    c         C   s   |  j  | d S(   sc   Return master ID for a duplicate bug.

        If the bug is not a duplicate, return None.
        R   (   R   (   R
   R   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   duplicate_of   s    c         C   s   | |  j  | d <d S(   st   Mark a crash id as duplicate of given master ID.
        
        If master is None, id gets un-duplicated.
        R   N(   R   (   R
   R   t   master(    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   close_duplicate¤   s    c         C   s6   |  j  | d d k s t ‚ d | |  j  | d <d S(   sp   Mark a crash id as reintroducing an earlier crash which is
        already marked as fixed (having ID 'master').R   s    regression, already fixed in #%iR#   N(   R   R   t   AssertionError(   R
   R   R4   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   mark_regression«   s    c         C   s,   y |  j  j | ƒ Wn t k
 r' n Xd S(   s/   Mark crash id as checked for being a duplicate.N(   R   t   removet   KeyError(   R
   R   R   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   _mark_dup_checked²   s    c         C   s   |  j  j | ƒ d S(   s   Mark crash id as retraced.N(   R   R8   (   R
   R   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   mark_retracedº   s    c         C   s   |  j  S(   s}   Return an ID set of all crashes which have not been retraced yet and
        which happened on the current host architecture.(   R   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   get_unretraced¿   s    c         C   s   |  j  S(   s#  Return an ID set of all crashes which have not been checked for
        being a duplicate.

        This is mainly useful for crashes of scripting languages such as
        Python, since they do not need to be retraced. It should not return
        bugs that are covered by get_unretraced().(   R   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   get_dup_uncheckedÅ   s    c         C   s   t  |  j ƒ d S(   s0   Return the ID of the most recently filed report.i   (   R   R   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt	   latest_idÏ   s    c         C   s™  t  j ƒ  } d | d <d | d <d | d <d | d <d	 | d
 <d | d <|  j | ƒ t  j ƒ  } d | d <d | d <d | d <d | d <d	 | d
 <d | d <|  j | ƒ t  j ƒ  } d | d <d | d <d | d <d | d <d | d
 <d | d <|  j | ƒ t  j ƒ  } d | d <d | d <d | d <d | d
 <d | d <|  j | ƒ t  j ƒ  } d | d <d | d <d | d <d | d
 <d | d <|  j | ƒ d S(   sM   Add some dummy crash reports.

        This is mostly useful for test suites.s   libfoo1 1.2-3t   Packaget   fooR   s   FooLinux Pi/2R*   t   11t   Signals
   /bin/crasht   ExecutablePaths‰   foo_bar (x=1) at crash.c:28
d01 (x=1) at crash.c:29
raise () from /lib/libpthread.so.0
<signal handler called>
__frob (x=1) at crash.c:30t   StacktraceTops   libfoo1 1.2-4s
   Testux 1.0s‰   foo_bar (x=2) at crash.c:28
d01 (x=3) at crash.c:29
raise () from /lib/libpthread.so.0
<signal handler called>
__frob (x=4) at crash.c:30s   bar 42-4t   bars   /usr/bin/brokensu   h (p=0x0) at crash.c:25
g (x=1, y=42) at crash.c:26
f (x=1) at crash.c:27
e (x=1) at crash.c:28
d (x=1) at crash.c:29s   python-goo 3epsilon1t   pygoos
   Testux 2.2s   /usr/bin/pygoosè   Traceback (most recent call last):
File "test.py", line 7, in <module>
print _f(5)
File "test.py", line 5, in _f
return g_foo00(x+1)
File "test.py", line 2, in g_foo00
return x/0
ZeroDivisionError: integer division or modulo by zeroR   s   python-goo 5N(   R   t   ReportR   (   R
   R(   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyR	   Ô   sL    



























N(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R!   R"   t   FalseR$   R+   R/   R2   R3   R5   R7   R:   R;   R<   R=   R>   R	   (    (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyR       s,   		
				
										
	t   _Tc           B   s¼   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s¹   t  d  d  i d d 6ƒ |  _ |  j |  j j |  j j d ƒ d ƒ d ƒ |  j j d ƒ j ƒ  sh t d ‚ |  j |  j j d ƒ j ƒ  |  j j d ƒ j ƒ  ƒ |  j |  j j ƒ  d ƒ d  S(   Nt   1R   i    s   http://foo.bugs.example.com/0i   s2   test-suite internal check: Python crash sigs existi   (	   R    R   t   crashest   assertEqualR   R   t   crash_signatureR6   R>   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   setUp,  s    c         C   sK   t  d d i  ƒ |  _ |  j |  j j ƒ  d ƒ |  j t |  j j d ƒ d S(   s!   No dummy data is added by defaultiÿÿÿÿi    N(   R    R   RN   RO   R>   t   assertRaisesR1   R   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_no_dummy_data<  s    c         C   sQ   |  j  |  j j ƒ  t d d d g ƒ ƒ |  j  |  j j ƒ  t d d g ƒ ƒ d S(   s+   Bookkeeping in retraced and dupchecked bugsi    i   i   i   i   N(   RO   RN   R<   R   R=   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_retrace_markersC  s    (c         C   sž   t  j ƒ  } | d IJ| j ƒ  t j j d d | j ƒ } |  j | j	 d d ƒ t j j d d | j ƒ } |  j
 d | j	 k ƒ |  j | j	 d d ƒ d S(	   s   Dynamic code in crashdb.confs'  default = 'testsuite'

def get_dyn():
    return str(2 + 2)

def get_dyn_name():
    return 'on_the' + 'fly'

databases = {
    'testsuite': { 
        'impl': 'memory',
        'dyn_option': get_dyn(),
    },
    get_dyn_name(): {
        'impl': 'memory',
        'whoami': 'dynname',
    }
}
t
   dyn_optiont   4t	   on_theflyt	   dyn_opiont   whoamit   dynnameN(   t   tempfilet   NamedTemporaryFilet   flushR   R   t   get_crashdbR   t   nameRO   R   t   assertFalse(   R
   t   crashdb_conft   db(    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_dynamic_crashdb_confI  s    
c         C   su   |  j  j d ƒ } |  j | d d ƒ |  j | d d ƒ |  j |  j  j d d d ƒ |  j t |  j  j d ƒ d S(	   s   Crash uploading and downloadingi    R   R@   R?   s   libfoo1 1.2-3R   i   N(   RN   R   RO   R   R   RR   R1   (   R
   R(   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_submitm  s
    c         C   s€   |  j  |  j j d ƒ d g ƒ |  j  |  j j d ƒ d g ƒ |  j  |  j j d ƒ d g ƒ |  j  |  j j d ƒ d g ƒ d  S(   Ni    R@   i   i   RE   i   RF   (   RO   RN   R   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_get_affected_packagesx  s    c         C   sá   t  j ƒ  } d | d <d | d <d | d <|  j j d | d ƒ |  j |  j j d d	 d ƒ |  j |  j j d ƒ d d ƒ |  j |  j j d ƒ d d ƒ |  j |  j j d ƒ d d ƒ |  j t |  j j d
 d d ƒ d S(   s   update()t   newR?   t   Bogust   FooBars   Fresh!RD   i   t   muhahaR#   i   R   N(
   R   RG   RN   R$   RO   R   R   RR   R1   R   (   R
   R(   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_update~  s    


   c         C   sí   t  j ƒ  } d | d <d | d <d | d <|  j j d | d d	 d d g ƒ|  j |  j j d d
 d ƒ |  j |  j j d ƒ d d ƒ |  j |  j j d ƒ d d ƒ |  j |  j j d ƒ d d ƒ |  j t |  j j d d d ƒ d S(   s   update() with key_filterRf   R?   Rg   Rh   s   Fresh!RD   i   Ri   R'   R#   s   libfoo1 1.2-4i   R   N(
   R   RG   RN   R$   RO   R   R   RR   R1   R   (   R
   R(   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_update_filterŽ  s    


"   c         C   sà   t  j ƒ  } d | d <d | d <d | d <|  j j d | d ƒ |  j |  j j d d	 d ƒ |  j |  j j d ƒ d d
 ƒ |  j |  j j d ƒ d d ƒ |  j |  j j d ƒ j d ƒ ƒ |  j	 t
 |  j j d d ƒ d S(   s   update_traces()Rf   R?   Rg   Rh   s   Fresh!RD   i   Ri   R#   s   libfoo1 1.2-4i   N(   R   RG   RN   t   update_tracesRO   R   R   R`   R   RR   R1   R   (   R
   R(   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_update_tracesž  s    


  "c         C   s    |  j  |  j j d ƒ d ƒ d S(   s   get_distro_release()i    s   FooLinux Pi/2N(   RO   RN   R+   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_get_distro_release®  s    c         C   sl  |  j  |  j j ƒ  t d d d d d g ƒ ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ |  j j d d ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j ƒ  t d d d d g ƒ ƒ |  j  |  j j d ƒ d ƒ |  j  |  j j d ƒ d ƒ d S(	   sE   get_unfixed(), get_fixed_version(), duplicate_of(), close_duplicate()i    i   i   i   i   R0   ic   N(   RO   RN   R/   R   R2   R   R3   R5   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_status³  s    .+c         C   s   d |  j  j d d <|  j  j d d ƒ |  j |  j  j d d d ƒ |  j |  j  j d ƒ d ƒ |  j |  j  j d ƒ d ƒ d S(   s   mark_regression()s   4.1i   R   i   R#   s   regression, already fixed in #3N(   RN   R   R7   RO   R3   R   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_mark_regressionÆ  s    c         C   s§   |  j  j d ƒ |  j |  j  j d ƒ d ƒ |  j |  j  j ƒ  i d |  j  j d ƒ j ƒ  6ƒ |  j  j d d ƒ |  j |  j  j ƒ  i d |  j  j d ƒ j ƒ  6ƒ d S(   s   duplicate_db_fixed()s   :memory:i    t   42N(   i    N(   i    Rq   (	   RN   t   init_duplicate_dbRO   t   check_duplicateR   t   _duplicate_db_dumpR   RP   t   duplicate_db_fixed(   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_duplicate_db_fixedÕ  s     c         C   s  |  j  t |  j j d ƒ |  j j d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j j d ƒ |  j |  j j ƒ  i d |  j j	 d ƒ j
 ƒ  6d |  j j	 d ƒ j
 ƒ  6ƒ |  j j d ƒ |  j |  j j ƒ  i d |  j j	 d ƒ j
 ƒ  6ƒ d S(	   s   duplicate_db_remove()i    s   :memory:i   ic   N(   i    N(   i   N(   i    N(   RR   R6   RN   Rs   Rr   RO   R   t   duplicate_db_removeRt   R   RP   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_duplicate_db_removeã  s    c         C   s{  |  j  t |  j j d |  j j d ƒ ƒ |  j  t |  j j d ƒ |  j j d ƒ |  j |  j j ƒ  i  ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j	 d |  j j
 d k ƒ |  j |  j j ƒ  i d |  j j d ƒ j ƒ  6d |  j j d ƒ j ƒ  6d |  j j d ƒ j ƒ  6ƒ d |  j j
 d d	 <|  j j d d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j |  j j
 d d d
 ƒ |  j |  j j ƒ  i d |  j j d ƒ j ƒ  6d |  j j d ƒ j ƒ  6d |  j j d ƒ j ƒ  6d |  j j d ƒ j ƒ  6ƒ t j |  j j d ƒ ƒ } |  j |  j j | |  j j | ƒ ƒ d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j	 d |  j j
 d k ƒ t j |  j j d ƒ ƒ } d | d <|  j |  j j | |  j j | ƒ ƒ d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j	 d |  j j
 d k ƒ |  j |  j j ƒ  i d  |  j j d ƒ j ƒ  6d! |  j j d ƒ j ƒ  6d" |  j j d ƒ j ƒ  6d# |  j j d ƒ j ƒ  6ƒ d |  j j
 d d	 <|  j j d d ƒ t j |  j j d ƒ ƒ } d | d <|  j |  j j | |  j j | ƒ ƒ d ƒ |  j |  j j d ƒ d$ ƒ |  j	 d |  j j
 d k ƒ |  j |  j j ƒ  i d% |  j j d ƒ j ƒ  6d& |  j j d ƒ j ƒ  6d' |  j j d ƒ j ƒ  6d( |  j j d ƒ j ƒ  6ƒ d S()   s   check_duplicate()i    s   :memory:i   i   i   i   R#   s   4.1R   s   regression, already fixed in #3s   http://pygoo.bugs.example.com/5i   s   python-goo 5.1R?   s   http://pygoo.bugs.example.com/6i   R   s   http://pygoo.bugs.example.com/7i   N(   i    N(   i   N(   i    N(   i   N(   i   N(   i    N(   i   N(   i   s   4.1(   i   N(   i   s   4.1(   i   N(   i    N(   i   N(   i   s   4.1(   i   N(   i   R   (   i    N(   i   N(   i   R   (   i   N(   RR   R6   RN   Rs   R   Rr   RO   Rt   R   R`   R   RP   R5   R3   t   copyR   R   Ru   (   R
   R(   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_check_duplicateý  sr    $
$
$c         C   sê   t  j ƒ  } d | d <d | d <d | d <d | d <d	 | d
 <d | d <|  j |  j j | |  j j | ƒ ƒ d ƒ |  j |  j j | |  j j | ƒ ƒ d ƒ |  j j d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ d S(   s$   check_duplicate() with UTF-8 stringss   bash 5R?   t   bashR   s
   Testux 2.2R*   s	   /bin/bashRC   t   6RB   s   AfirmaÃ§Ã£o x != 0t   AssertionMessages   http://bash.bugs.example.com/5s   http://bash.bugs.example.com/6s   :memory:i   i   N(   i   N(	   R   RG   RO   RN   R   R   Rr   Rs   R   (   R
   R(   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_check_duplicate_utf8b  s    





$$c         C   se  t  j ƒ  } d | d <d | d <d | d <|  j |  j j | |  j j | ƒ ƒ d ƒ |  j j d ƒ |  j |  j j d	 ƒ d ƒ |  j |  j j	 ƒ  i d d 6ƒ |  j |  j j d
 ƒ d ƒ d |  j j
 d
 ƒ d <|  j |  j j d
 ƒ d ƒ d |  j j
 d ƒ d <|  j |  j j d ƒ d ƒ |  j |  j j	 ƒ  i d d 6d d 6d |  j j
 d
 ƒ j ƒ  6ƒ d S(   s7   check_duplicate() with custom DuplicateSignature: fieldR{   R   s   bash 5R?   t
   Code42Bluet   DuplicateSignatures   http://bash.bugs.example.com/5s   :memory:i   i    t   CodeRedi   N(   i   N(   i   N(   i   N(   i   N(   i    N(   R   RG   RO   RN   R   R   Rr   Rs   R   Rt   R   RP   (   R
   R(   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt%   test_check_duplicate_custom_signaturev  s"    


$ c         C   sw   |  j  j d ƒ |  j |  j  j d ƒ d ƒ |  j |  j  j d ƒ d ƒ |  j |  j  j d |  j  j d ƒ ƒ d ƒ d S(   s0   check_duplicate() with explicitly passing reports   :memory:i    i   i   N(   i    N(   RN   Rr   RO   Rs   R   R   (   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_check_duplicate_report_arg‘  s
    c         C   sl  |  j  t |  j j d ƒ |  j j d ƒ |  j |  j j d ƒ d ƒ |  j |  j j d ƒ d ƒ |  j |  j j ƒ  i d |  j j d ƒ j	 ƒ  6d |  j j d ƒ j	 ƒ  6ƒ |  j j
 d d ƒ |  j |  j j ƒ  i d	 |  j j d ƒ j	 ƒ  6d
 |  j j d ƒ j	 ƒ  6ƒ |  j j
 d d ƒ |  j |  j j ƒ  i d |  j j d ƒ j	 ƒ  6d |  j j d ƒ j	 ƒ  6ƒ d S(   s   duplicate_db_change_master_id()i    s   :memory:i   i   ic   N(   i    N(   i   N(   i    N(   i   N(   i    N(   ic   N(   RR   R6   RN   Rs   Rr   RO   R   Rt   R   RP   t   duplicate_db_change_master_id(   R
   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_change_master_id   s    c         C   sI  z4t  j ƒ  \ } } t j | ƒ |  j j | ƒ |  j |  j j d ƒ d ƒ |  j |  j j	 ƒ  i d |  j j
 d ƒ j ƒ  6ƒ |  j j d d ƒ |  j |  j j	 ƒ  i d |  j j
 d ƒ j ƒ  6ƒ |  ` t | d ƒ } | j t j j | ƒ d d ƒ | j ƒ  t d d i  ƒ |  _ |  j t |  j j | ƒ Wd t j | ƒ Xd S(	   s   Detection of DB file corruptioni    Rq   s   r+i   i   N(   i    N(   i    s   42(   R[   t   mkstempt   ost   closeRN   Rr   RO   Rs   R   Rt   R   RP   Ru   t   opent   truncatet   patht   getsizeR    RR   t   StandardErrort   unlink(   R
   t   fdRb   R)   (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   test_db_corruptionÀ  s"      !
(   RH   RI   RQ   RS   RT   Rc   Rd   Re   Rj   Rk   Rm   Rn   Ro   Rp   Rv   Rx   Rz   R~   R‚   Rƒ   R…   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyRL   +  s(   				$											e				 t   __main__(   RJ   Ry   t   timeR‡   t   unittestt   apport.crashdbR   R   R    t   TestCaseRL   RH   R[   t   main(    (    (    s>   /usr/lib/python2.7/dist-packages/apport/crashdb_impl/memory.pyt   <module>   s   0ÿ ÿ ±