Ignore:
Timestamp:
14 Jun 2012, 16:47:57 (12 years ago)
Author:
uli
Message:

Search only logfiles with correct basename, fix tests.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/datacenter.py

    r8634 r8725  
    224224        for name in os.listdir(os.path.join(self.storage, 'logs')):
    225225            if RE_LOGFILE_BACKUP_NAME.match(name):
    226                 files.append(name)
     226                if name.rsplit('.', 1)[0] == basename:
     227                    files.append(name)
    227228        return sorted(files, key=numerical_suffix, reverse=True)
    228229
  • main/waeup.kofa/trunk/src/waeup/kofa/tests/test_datacenter.py

    r8634 r8725  
    1212from waeup.kofa.interfaces import IDataCenter, IDataCenterConfig
    1313
    14 
    1514class DataCenterLogQueryTests(unittest.TestCase):
    1615    # Tests for querying logfiles via datacenter.
     
    3736        path = self.logpath
    3837        for m in range(num-1,-1,-1):
     38            # write messages in order: lowest message in oldest file
    3939            fp = open(path, 'wb')
    4040            for n in range(50*m, 50*m+50):
     
    4242                fp.write('Other Line %d\n' % (n + 1))
    4343            fp.close()
    44             path = self.logpath + '.%d' % (m + 1)
     44            path = self.logpath + '.%d' % m
    4545        return
    4646
     
    7575        open(self.logpath, 'wb').write('Msg 1\n')
    7676        open(self.logpath + '-not-a-real-log', 'wb').write('Msg 2\n')
     77        open(self.logpath + '-not-a-real-log.1', 'wb').write('Msg 3\n')
    7778        result = list(datacenter.queryLogfiles('myapp.log', 'Msg'))
    78         # Msg 2 won't show up in results.
     79        # Msg 2 and 3 won't show up in results.
    7980        self.assertEqual(result, ['Msg 1\n'])
    8081        return
     
    226227        # The source is deleted afterwards
    227228        self.assertEqual(os.path.exists(csv_file2), False)
     229        return
    228230
    229231    def test_append_csv_file_no_dest(self):
     
    240242        # The source is deleted afterwards
    241243        self.assertEqual(os.path.exists(csv_file2), False)
     244        return
    242245
    243246    def test_append_csv_file_no_source(self):
     
    252255        # csv_file1 is the same as before
    253256        self.assertEqual(result, 'name,age\nManfred,28\n')
     257        return
    254258
    255259    def test_append_csv_file_same_src_and_dest(self):
     
    265269        self.assertEqual(result, 'name,age\nManfred,28\n')
    266270        self.assertEqual(os.path.exists(csv_file2), True)
     271        return
Note: See TracChangeset for help on using the changeset viewer.