示例#1
0
class FilebaseTest(unittest.TestCase):

    def setUp(self):
        self.filebase = Filebase('/tmp/output/{groups[0]}/{groups[1]}_test_{file_number}_file_')

    @freeze_time('2010-01-01')
    def test_filebase_init(self):
        filebase = Filebase('/tmp/output/%Y/{groups[0]}/{groups[1]}_test_{file_number}_file_')
        expected_dir = '/tmp/output/2010/{groups[0]}'
        expected_prefix = '{groups[1]}_test_{file_number}_file_'
        expected = '/'.join([expected_dir, expected_prefix])
        self.assertEqual(filebase.template, expected)
        self.assertEqual(filebase.prefix_template, expected_prefix)
        self.assertEqual(filebase.dirname_template, expected_dir)

    def test_get_dirname_with_group_info(self):
        # then
        self.assertEqual(
                self.filebase.formatted_dirname(
                        groups=('us', 'es')), '/tmp/output/us')

    def test_formatted_prefix(self):
        # then
        self.assertEqual(self.filebase.formatted_prefix(
                groups=('us', 'es'), file_number=0), 'es_test_0_file_')

    def test_has_group_info(self):
        # then
        self.assertTrue(self.filebase._has_key_info('groups'))
示例#2
0
class FilebaseTest(unittest.TestCase):
    def setUp(self):
        self.filebase = Filebase(
            '/tmp/output/{groups[0]}/{groups[1]}_test_{file_number}_file_')

    @freeze_time('2010-01-01')
    def test_filebase_init(self):
        filebase = Filebase(
            '/tmp/output/%Y/{groups[0]}/{groups[1]}_test_{file_number}_file_')
        expected_dir = '/tmp/output/2010/{groups[0]}'
        expected_prefix = '{groups[1]}_test_{file_number}_file_'
        expected = '/'.join([expected_dir, expected_prefix])
        self.assertEqual(filebase.template, expected)
        self.assertEqual(filebase.prefix_template, expected_prefix)
        self.assertEqual(filebase.dirname_template, expected_dir)

    def test_get_dirname_with_group_info(self):
        # then
        self.assertEqual(self.filebase.formatted_dirname(groups=('us', 'es')),
                         '/tmp/output/us')

    def test_formatted_prefix(self):
        # then
        self.assertEqual(
            self.filebase.formatted_prefix(groups=('us', 'es'), file_number=0),
            'es_test_0_file_')

    def test_has_group_info(self):
        # then
        self.assertTrue(self.filebase._has_key_info('groups'))
示例#3
0
 def test_filebase_init(self):
     filebase = Filebase(
         '/tmp/output/%Y/{groups[0]}/{groups[1]}_test_{file_number}_file_')
     expected_dir = '/tmp/output/2010/{groups[0]}'
     expected_prefix = '{groups[1]}_test_{file_number}_file_'
     expected = '/'.join([expected_dir, expected_prefix])
     self.assertEqual(filebase.template, expected)
     self.assertEqual(filebase.prefix_template, expected_prefix)
     self.assertEqual(filebase.dirname_template, expected_dir)
示例#4
0
 def setUp(self):
     self.filebase = Filebase('/tmp/output/{groups[0]}/{groups[1]}_test_{file_number}_file_')
示例#5
0
 def setUp(self):
     self.filebase = Filebase(
         '/tmp/output/{groups[0]}/{groups[1]}_test_{file_number}_file_')