Пример #1
0
 def test_get_full_filebase(self):
     writer_config = {
         'options': {
             'filebase': '/tmp/some_file_',
         }
     }
     writer = FilebaseBaseWriter(writer_config, meta())
     writer.close()
     self.assertEqual(writer.filebase.template, '/tmp/some_file_')
Пример #2
0
 def test_get_full_filebase(self):
     writer_config = {
         'options': {
             'filebase': '/tmp/some_file_',
         }
     }
     writer = FilebaseBaseWriter(writer_config, meta())
     writer.close()
     self.assertEqual(writer.filebase.template, '/tmp/some_file_')
Пример #3
0
 def test_wrong_file_number_in_filebase(self):
     writer_config = {
         'options': {
             'filebase': '/tmp/%m/%Y-some_folder_{file_number}/{groups[1]}_',
         }
     }
     writer = FilebaseBaseWriter(writer_config, meta())
     writer.close()
     with self.assertRaisesRegexp(KeyError, 'filebase option should not contain'):
         writer.create_filebase_name(('g1', 'g2'), file_name='filename')
Пример #4
0
 def test_create_filebase_name(self):
     writer_config = {
         'options': {
             'filebase': '/tmp/%m/%Y-some_folder_{groups[0]}/{groups[1]}_{file_number}_',
         }
     }
     writer = FilebaseBaseWriter(writer_config, meta())
     writer.close()
     date = datetime.datetime.now()
     expected = (date.strftime('/tmp/%m/%Y-some_folder_g1'), 'filename')
     self.assertEqual(writer.create_filebase_name(('g1', 'g2'), file_name='filename'), expected)
Пример #5
0
 def test_get_file_number_not_implemented(self):
     writer_config = {
         'options': {
             'filebase': '/tmp/',
         }
     }
     writer = FilebaseBaseWriter(writer_config, meta())
     self.assertIsInstance(writer.get_file_suffix('', ''), basestring)
     path, file_name = writer.create_filebase_name([])
     self.assertEqual(path, '/tmp')
     writer.close()
Пример #6
0
 def test_get_file_number_not_implemented(self):
     writer_config = {
         'options': {
             'filebase': '/tmp/',
         }
     }
     writer = FilebaseBaseWriter(writer_config, meta())
     self.assertIsInstance(writer.get_file_suffix('', ''), basestring)
     path, file_name = writer.create_filebase_name([])
     self.assertEqual(path, '/tmp')
     writer.close()
Пример #7
0
 def test_wrong_file_number_in_filebase(self):
     writer_config = {
         'options': {
             'filebase':
             '/tmp/%m/%Y-some_folder_{file_number}/{groups[1]}_',
         }
     }
     writer = FilebaseBaseWriter(writer_config, meta())
     writer.close()
     with self.assertRaisesRegexp(KeyError,
                                  'filebase option should not contain'):
         writer.create_filebase_name(('g1', 'g2'), file_name='filename')
Пример #8
0
 def test_create_filebase_name(self):
     writer_config = {
         'options': {
             'filebase':
             '/tmp/%m/%Y-some_folder_{groups[0]}/{groups[1]}_{file_number}_',
         }
     }
     writer = FilebaseBaseWriter(writer_config, meta())
     writer.close()
     date = datetime.datetime.now()
     expected = (date.strftime('/tmp/%m/%Y-some_folder_g1'), 'filename')
     self.assertEqual(
         writer.create_filebase_name(('g1', 'g2'), file_name='filename'),
         expected)