示例#1
0
 def test_readdir_alt(self):
     m = DefaultMapper()
     m.mkdir(['1'])
     m.mapping['notdir'] = ('somezip.zip', 'afile', 1)
     self.assertEqual(sorted(m.readdir('')), ['1', 'notdir'])
     self.assertEqual(sorted(m.readdir('notdir')), [])
     self.assertEqual(sorted(m.readdir('nowhere')), [])
示例#2
0
 def test_readdir_alt(self):
     m = DefaultMapper()
     m.mkdir(['1'])
     m.mapping['notdir'] = ('somezip.zip', 'afile', 1)
     self.assertEqual(sorted(m.readdir('')), ['1', 'notdir'])
     self.assertEqual(sorted(m.readdir('notdir')), [])
     self.assertEqual(sorted(m.readdir('nowhere')), [])
示例#3
0
    def test_mkdir_blocked(self):
        m = DefaultMapper()
        m.mapping['notdir'] = ('somezip.zip', 'afile', 1)

        with self.assertRaises(ValueError) as cm:
            m.mkdir(['notdir', '2', '3'])

        self.assertEqual(cm.exception.args[0],
            'cannot create directory `notdir` at `/`: file entry exists.'
        )
        self.assertEqual(m.mapping, {'notdir': ('somezip.zip', 'afile', 1)})

        # simple case should fail, too
        with self.assertRaises(ValueError) as cm:
            m.mkdir(['notdir',])
示例#4
0
    def test_mkdir_blocked(self):
        m = DefaultMapper()
        m.mapping['notdir'] = ('somezip.zip', 'afile', 1)

        with self.assertRaises(ValueError) as cm:
            m.mkdir(['notdir', '2', '3'])

        self.assertEqual(
            cm.exception.args[0],
            'cannot create directory `notdir` at `/`: file entry exists.')
        self.assertEqual(m.mapping, {'notdir': ('somezip.zip', 'afile', 1)})

        # simple case should fail, too
        with self.assertRaises(ValueError) as cm:
            m.mkdir([
                'notdir',
            ])
示例#5
0
 def test_readdir(self):
     m = DefaultMapper()
     self.assertEqual(m.readdir(''), [])
     m.mkdir(['1'])
     self.assertEqual(m.readdir(''), ['1'])
     m.mkdir(['2'])
     m.mkdir(['3', '4', '5'])
     self.assertEqual(sorted(m.readdir('')), ['1', '2', '3'])
     self.assertEqual(sorted(m.readdir('3')), ['4'])
     self.assertEqual(sorted(m.readdir('3/4')), ['5'])
示例#6
0
 def test_readdir(self):
     m = DefaultMapper()
     self.assertEqual(m.readdir(''), [])
     m.mkdir(['1'])
     self.assertEqual(m.readdir(''), ['1'])
     m.mkdir(['2'])
     m.mkdir(['3', '4', '5'])
     self.assertEqual(sorted(m.readdir('')), ['1', '2', '3'])
     self.assertEqual(sorted(m.readdir('3')), ['4'])
     self.assertEqual(sorted(m.readdir('3/4')), ['5'])
示例#7
0
 def test_mkdir(self):
     m = DefaultMapper()
     result = m.mkdir(['1', '2', '3'])
     self.assertEqual(result, m.mapping['1']['2']['3'])
     result = m.mkdir(['1', '2', '3'])
     self.assertEqual(result, m.mapping['1']['2']['3'])
示例#8
0
 def test_mkdir(self):
     m = DefaultMapper()
     result = m.mkdir(['1', '2', '3'])
     self.assertEqual(result, m.mapping['1']['2']['3'])
     result = m.mkdir(['1', '2', '3'])
     self.assertEqual(result, m.mapping['1']['2']['3'])