Example #1
0
    def test_copy_file_to_sandbox(self):
        sandbox = Sandbox(54321)
        file_path = self.PROJECT_ROOT.joinpath('./tests/resources/server.py')

        # copy
        result = sandbox.copy_file_to_sandbox(file_path, '/')
        self.assertTrue(result)

        # check existence
        result = sandbox.exec('[ -e "/server.py" ]')
        self.assertEqual(0, result.get('ExitCode'))

        # cehck contents
        result = sandbox.exec('cat /server.py')
        fileobj = open(file_path, "rb")
        file_contents = fileobj.read()
        fileobj.close()
        self.assertEqual(file_contents, result.get('Output'))
Example #2
0
    def test_host_file_not_found(self):
        sandbox = Sandbox(54321)
        file_path = self.PROJECT_ROOT.joinpath('./resources/app.py')

        with self.assertRaises(FileNotFoundError):
            sandbox.copy_file_to_sandbox(file_path, '/')
Example #3
0
    def test_copy_file_to_container_with_relative_path(self):
        sandbox = Sandbox(54321)

        with self.assertRaises(
                FileNotFoundError):  # FIXME It's not proper exception
            sandbox.copy_file_to_sandbox('../tests/resources/server.py', '/')