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')), [])
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',])
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', ])
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'])
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'])