Ejemplo n.º 1
0
 def test_get_msg(self):
     '''This currently checks that an exception is not thrown.'''
     for record in self._records:
         sr = SummaryRecord()
         sr.load_from_msg(record)
         
         # not a proper test yet
         sr.get_msg()
Ejemplo n.º 2
0
    def test_load_from_msg_wrong_2(self):
        '''This checks that an exception is thrown when invalid 
        records are loaded.'''
        for record in self._wrong_records:
            sr = SummaryRecord()

            try:
                sr.load_from_msg(record)
                self.fail("Incorrect record loaded as message.")
            except InvalidRecordException:
                continue
Ejemplo n.º 3
0
 def test_load_from_msg_wrong_2(self):
     '''This checks that an exception is thrown when invalid 
     records are loaded.'''
     for record in self._wrong_records:
         sr = SummaryRecord()
         
         try:
             sr.load_from_msg(record)
             self.fail("Incorrect record loaded as message.")
         except InvalidRecordException:
             continue
Ejemplo n.º 4
0
    def test_load_from_msg_wrong(self):
        '''Check that invalid records don't get loaded.'''

        sr = SummaryRecord()

        # Note that when values are being loaded from messages, they are all strings.
        # Not a dictionary because I want to use more than one value per key.
        invalid_values = [('Month', 0), ('Month', 13), ('Year', 2030),
                          ('CpuDuration', -123), ('WallDuration', 'hello'),
                          ('Site', 'Null')]

        for key, value in invalid_values:
            sr.load_from_msg(self._records[1])

            sr._record_content[key] = value
            self.assertRaises(InvalidRecordException, sr.get_msg)
Ejemplo n.º 5
0
 def test_load_from_msg_wrong(self):
     '''Check that invalid records don't get loaded.'''
     
     sr = SummaryRecord()
     
     # Note that when values are being loaded from messages, they are all strings.
     # Not a dictionary because I want to use more than one value per key.
     invalid_values = [('Month', 0), ('Month', 13), ('Year', 2030), 
                       ('CpuDuration', -123), ('WallDuration', 'hello'),
                       ('Site', 'Null')]
     
     for key, value in invalid_values:
         sr.load_from_msg(self._records[1])
         
         sr._record_content[key] = value
         self.assertRaises(InvalidRecordException, sr.get_msg)
Ejemplo n.º 6
0
 def test_get_ur(self):
     """Check that get_ur outputs correct XML."""
     sr = SummaryRecord()
     sr.load_from_msg(self._records[0])
     xml = ('<aur:SummaryRecord><aur:Site>RAL-LCG2</aur:Site><aur:Month>3</a'
            'ur:Month><aur:Year>2010</aur:Year><aur:UserIdentity><urf:GroupA'
            'ttribute urf:type="vo-group">/atlas</urf:GroupAttribute><urf:Gr'
            'oupAttribute urf:type="vo-role">Role=production</urf:GroupAttri'
            'bute></aur:UserIdentity><aur:SubmitHost>some.host.org</aur:Subm'
            'itHost><aur:Infrastructure urf:type="grid"/><aur:EarliestEndTim'
            'e>2010-03-01T01:00:00Z</aur:EarliestEndTime><aur:LatestEndTime>'
            '2010-03-20T01:00:00Z</aur:LatestEndTime><aur:WallDuration>PT234'
            '256S</aur:WallDuration><aur:CpuDuration>PT244435S</aur:CpuDurat'
            'ion><aur:ServiceLevel urf:type="Si2k">1000.0</aur:ServiceLevel>'
            '<aur:NumberOfJobs>100</aur:NumberOfJobs></aur:SummaryRecord>')
     self.assertEqual(sr.get_ur(), xml)
 def test_get_ur(self):
     """Check that get_ur outputs correct XML."""
     sr = SummaryRecord()
     sr.load_from_msg(self._records[0])
     xml = (
         '<aur:SummaryRecord><aur:Site>RAL-LCG2</aur:Site><aur:Month>3</a'
         'ur:Month><aur:Year>2010</aur:Year><aur:UserIdentity><urf:GroupA'
         'ttribute urf:type="vo-group">/atlas</urf:GroupAttribute><urf:Gr'
         'oupAttribute urf:type="vo-role">Role=production</urf:GroupAttri'
         'bute></aur:UserIdentity><aur:SubmitHost>some.host.org</aur:Subm'
         'itHost><aur:Infrastructure urf:type="grid"/><aur:EarliestEndTim'
         'e>2010-03-01T01:00:00Z</aur:EarliestEndTime><aur:LatestEndTime>'
         '2010-03-20T01:00:00Z</aur:LatestEndTime><aur:WallDuration>PT234'
         '256S</aur:WallDuration><aur:CpuDuration>PT244435S</aur:CpuDurat'
         'ion><aur:ServiceLevel urf:type="Si2k">1000.0</aur:ServiceLevel>'
         '<aur:NumberOfJobs>100</aur:NumberOfJobs></aur:SummaryRecord>')
     self.assertEqual(sr.get_ur(), xml)
Ejemplo n.º 8
0
    def test_get_apel_db_insert(self):
        '''Test that the method getting the data to put into the DB
        actually does retrieve the correct values.'''

        for rec_txt, rec_tuple in zip(self._records, self._tuples):

            sr = SummaryRecord()
            sr.load_from_msg(rec_txt)

            test_dn = "This is a test DN."

            # Mock object so we don't have to use an actual DB.
            values = sr.get_db_tuple(test_dn)
        for item1, item2 in zip(values, rec_tuple):
            #            if isinstance(item1, datetime):
            #                if abs(item1 - item2) > timedelta(seconds = 1):
            #                    self.fail('Datetimes %s and %s do not match.' % (item1, item2))

            if item1 != item2 and str(item1) != str(item2):
                print values
                self.fail('Values changed when creating a summary record: ' +
                          str(item1) + ": " + str(item2))
Ejemplo n.º 9
0
    def test_get_apel_db_insert(self):
        '''Test that the method getting the data to put into the DB
        actually does retrieve the correct values.'''
        
        for rec_txt, rec_tuple in zip(self._records, self._tuples):
        
            sr = SummaryRecord()
            sr.load_from_msg(rec_txt)
        
            test_dn = "This is a test DN."
        
            # Mock object so we don't have to use an actual DB.
            values = sr.get_db_tuple(test_dn)
        for item1, item2 in zip(values, rec_tuple):
#            if isinstance(item1, datetime):
#                if abs(item1 - item2) > timedelta(seconds = 1):
#                    self.fail('Datetimes %s and %s do not match.' % (item1, item2))
                
            if item1 != item2 and str(item1) != str(item2):
                print values
                self.fail('Values changed when creating a summary record: ' +
                          str(item1) + ": " + str(item2))
Ejemplo n.º 10
0
    def test_get_msg(self):
        '''This currently checks that an exception is not thrown.'''
        for record in self._records:
            sr = SummaryRecord()
            sr.load_from_msg(record)

            # not a proper test yet
            sr.get_msg()