예제 #1
0
    def test_success(self):
        # not reading log
        self.assertEqual(
            0,
            module.main(
                [
                    "test.py",
                    "--on-pre-submit",
                    "test_hook",
                    "--no-watch-log",
                ]
            ),
        )

        self.get_function.assert_called()
        self.client.check.assert_called()

        # reading log
        self.client.get_batch_state.return_value = "success"
        self.assertEqual(
            0,
            module.main(
                [
                    "test.py",
                    "--on-pre-submit",
                    "test_hook",
                ]
            ),
        )
예제 #2
0
 def test_task_ending_error(self):
     self.client.get_batch_state.return_value = "dead"
     self.assertEqual(1, module.main(["test.py", "--on-task-failed", "test_hook"]))
예제 #3
0
 def test_ending_get_batch_state(self):
     self.client.get_batch_state.side_effect = livy.RequestError(0, "Test error")
     self.assertEqual(1, module.main(["test.py"]))
예제 #4
0
 def test_readlog_interrupt(self):
     self.reader.read_until_finish.side_effect = KeyboardInterrupt()
     self.assertEqual(1, module.main(["test.py"]))
예제 #5
0
 def test_readlog_error(self):
     self.reader.read_until_finish.side_effect = livy.RequestError(0, "Test error")
     self.assertEqual(1, module.main(["test.py"]))
예제 #6
0
 def test_create_batch_error_2(self):
     self.client.create_batch.return_value = {"foo": "bar"}
     self.assertEqual(1, module.main(["test.py"]))
예제 #7
0
 def test_create_batch_error_1(self):
     self.client.create_batch.side_effect = livy.RequestError(0, "Test error")
     self.assertEqual(1, module.main(["test.py"]))
예제 #8
0
 def test_server_error(self):
     self.client.check.side_effect = livy.RequestError(0, "Test error")
     self.assertEqual(1, module.main(["test.py"]))