aboutsummaryrefslogtreecommitdiffstats
path: root/tests/api/__init__.py
blob: 5f20faf1e9f16416689703c6279f1b0e317d59eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import logging
from unittest import mock

from falcon import testing

from snekbox.api import SnekAPI
from snekbox.process import EvalResult


class SnekAPITestCase(testing.TestCase):
    def setUp(self):
        super().setUp()

        self.patcher = mock.patch("snekbox.api.snekapi.NsJail", autospec=True)
        self.mock_nsjail = self.patcher.start()
        self.mock_nsjail.return_value.python3.return_value = EvalResult(
            args=[], returncode=0, stdout="output", stderr="error"
        )
        self.addCleanup(self.patcher.stop)

        logging.getLogger("snekbox.nsjail").setLevel(logging.WARNING)

        self.app = SnekAPI()