예제 #1
0
 def test_event_id_data_change(self):
     'Test that changing data changes the ID'
     r0 = event_id_from_data(self.userInfo, self.instanceUserInfo,
                             self.siteInfo, 'c', 'foo', 'bar')
     r1 = event_id_from_data(self.userInfo, self.instanceUserInfo,
                             self.siteInfo, 'c', 'wibble', 'blarg')
     self.assertNotEqual(r0, r1)
예제 #2
0
    def test_event_id_time(self):
        'Check that time changes the ID'
        r0 = event_id_from_data(self.userInfo, self.instanceUserInfo,
                                self.siteInfo, 'c', None, None)
        sleep(1)
        r1 = event_id_from_data(self.userInfo, self.instanceUserInfo,
                                self.siteInfo, 'c', None, None)

        self.assertNotEqual(r0, r1, 'Time has no effect on the identifier')
예제 #3
0
 def test_ascii(self):
     'Test that ascii data does not thow the creation of IDs'
     self.userInfo.id = b'user'
     self.userInfo.name = b'User name'
     self.instanceUserInfo.id = b'instance user'
     self.instanceUserInfo.name = b'Instance User Info'
     self.siteInfo.id = b'site'
     self.siteInfo.name = b'Site Info'
     r = event_id_from_data(self.userInfo, self.instanceUserInfo,
                            self.siteInfo, b'c', b'foo', b'bar')
     self.assertIsNotNone(r)
     self.assertGreater(len(r), 1)
예제 #4
0
    def info(self, code, instanceUserInfo):
        d = datetime.now(UTC)
        mushForId = '%s-%s' % (self.groupInfo.name, self.groupInfo.id)
        eventId = event_id_from_data(
            self.userInfo, instanceUserInfo,  self.siteInfo, code, '',
            mushForId.encode('ascii', 'xmlcharrefreplace'))
        e = self.factory(self.context, eventId, code, d, self.userInfo,
                         instanceUserInfo, self.siteInfo, self.groupInfo,
                         '', '', SUBSYSTEM)

        self.queries.store(e)
        log.info(e)
        return e
예제 #5
0
    def info(self, instanceUser):
        mushForId = '%s-%s' % (self.groupInfo.name, self.groupInfo.id)
        eventId = event_id_from_data(
            instanceUser, instanceUser, self.siteInfo, REQUEST, '',
            mushForId.encode('ascii', 'xmlcharrefreplace'))
        d = datetime.now(UTC)
        f = AuditFactory()
        e = f(self.context, eventId, REQUEST, d, instanceUser, instanceUser,
              self.siteInfo, self.groupInfo, '', '', SUBSYSTEM)

        self.queries.store(e)
        log.info(e)
        return e
예제 #6
0
    def info(self, code, instanceDatum='', supplementaryDatum=''):
        """Log an info event to the audit trail.
            * Creates an ID for the new event,
            * Writes the instantiated event to the audit-table, and
            * Writes the event to the standard Python log.
        """
        d = datetime.now(UTC)
        eventId = event_id_from_data(self.userInfo, self.instanceUserInfo, self.siteInfo, code,
                                     instanceDatum,
                                     '%s-%s' % (self.groupInfo.name, self.groupInfo.id))

        e = self.factory(self.context, eventId, code, d, self.userInfo, self.instanceUserInfo,
                         self.siteInfo, self.groupInfo, instanceDatum, None, SUBSYSTEM)

        self.queries.store(e)
        log.info(e)
        return e
    def info(self, code, instanceDatum='', supplementaryDatum=''):
        """Log an info event to the audit trail.

        DESCRIPTION
            This method logs an event to the audit trail. It is
            named after the equivalent method in the standard Python
            logger, which it also writes to. The three arguments 
            (other than self) are combined to form the arguments to
            the factory, which creates the event that is then 
            recorded.
                
        ARGUMENTS
            "code"    The code that identifies the event that is 
                      logged. Sometimes this is enough.
                      
            "instanceDatum"
                      Data about the event. Each event class has its
                      own way to interpret this data.
                      
            "supplementaryDatum"
                      More data about an event.
        
        SIDE EFFECTS
            * Creates an ID for the new event,
            * Writes the instantiated event to the audit-table, and
            * Writes the event to the standard Python log.
        
        RETURNS
            None
        """
        d = datetime.now(UTC)
        eventId = event_id_from_data(self.instanceUserInfo,
          self.instanceUserInfo, self.siteInfo, code, instanceDatum,
          '%s-%s' % (self.groupInfo.name, self.groupInfo.id))
          
        e = self.factory(self.context, eventId, code, d,
          None, self.instanceUserInfo, self.siteInfo,
          self.groupInfo, instanceDatum, None, SUBSYSTEM)
          
        self.queries.store(e)
        log.info(e)
        return e
    def info(self, code, instanceDatum='', supplementaryDatum=''):
        """Log an info event to the audit trail.

        DESCRIPTION
            This method logs an event to the audit trail. It is
            named after the equivalent method in the standard Python
            logger, which it also writes to. The three arguments 
            (other than self) are combined to form the arguments to
            the factory, which creates the event that is then 
            recorded.
                
        ARGUMENTS
            "code"    The code that identifies the event that is 
                      logged. Sometimes this is enough.
                      
            "instanceDatum"
                      Data about the event. Each event class has its
                      own way to interpret this data.
                      
            "supplementaryDatum"
                      More data about an event.
        
        SIDE EFFECTS
            * Creates an ID for the new event,
            * Writes the instantiated event to the audit-table, and
            * Writes the event to the standard Python log.
        
        RETURNS
            None
        """
        d = datetime.now(UTC)
        eventId = event_id_from_data(
            self.instanceUserInfo, self.instanceUserInfo, self.siteInfo, code,
            instanceDatum, '%s-%s' % (self.groupInfo.name, self.groupInfo.id))

        e = self.factory(self.context, eventId, code, d, None,
                         self.instanceUserInfo, self.siteInfo, self.groupInfo,
                         instanceDatum, None, SUBSYSTEM)

        self.queries.store(e)
        log.info(e)
        return e
예제 #9
0
 def test_event_id_data(self):
     'Unicode data'
     r = event_id_from_data(self.userInfo, self.instanceUserInfo,
                            self.siteInfo, 'c', 'foo', 'bar')
     self.assertIsNotNone(r)
     self.assertGreater(len(r), 1)
예제 #10
0
 def test_event_id(self):
     'Basic test, with just Unicode'
     r = event_id_from_data(self.userInfo, self.instanceUserInfo,
                            self.siteInfo, 'c', None, None)
     self.assertIsNotNone(r)
     self.assertGreater(len(r), 1)