Ejemplo n.º 1
0
class TestInMemoryFSLayer(unittest.TestCase):
    def setUp(self):
        self.file_mapping = {}
        self.fslayer = InMemoryFSLayer(self.file_mapping)

    def test_file_exists(self):
        self.file_mapping['/my/fake/path'] = 'file contents'
        self.assertTrue(self.fslayer.file_exists('/my/fake/path'))

    def test_can_read_file_contents(self):
        self.file_mapping['/myfile'] = 'helloworld'
        self.assertEqual(self.fslayer.file_contents('/myfile'), 'helloworld')
        self.assertEqual(self.fslayer.file_contents('/myfile', binary=True),
                         b'helloworld')

    def test_file_does_not_exist_error(self):
        with self.assertRaises(FileReadError):
            self.fslayer.file_contents('/tmp/thisdoesnot-exist.asdf')
Ejemplo n.º 2
0
class TestInMemoryFSLayer(unittest.TestCase):
    def setUp(self):
        self.file_mapping = {}
        self.fslayer = InMemoryFSLayer(self.file_mapping)

    def test_file_exists(self):
        self.file_mapping['/my/fake/path'] = 'file contents'
        self.assertTrue(self.fslayer.file_exists('/my/fake/path'))

    def test_can_read_file_contents(self):
        self.file_mapping['/myfile'] = 'helloworld'
        self.assertEqual(self.fslayer.file_contents('/myfile'), 'helloworld')
        self.assertEqual(self.fslayer.file_contents('/myfile', binary=True),
                         b'helloworld')

    def test_file_does_not_exist_error(self):
        with self.assertRaises(FileReadError):
            self.fslayer.file_contents('/tmp/thisdoesnot-exist.asdf')
Ejemplo n.º 3
0
 def setUp(self):
     self.file_mapping = {}
     self.fslayer = InMemoryFSLayer(self.file_mapping)
Ejemplo n.º 4
0
 def setUp(self):
     self.file_mapping = {}
     self.fslayer = InMemoryFSLayer(self.file_mapping)
Ejemplo n.º 5
0
 def setUp(self):
     # filename -> file content
     self.files = {}
     self.fslayer = InMemoryFSLayer(self.files)