def test_unknown_actino(self): printer = Octoprint("192.168.1.15", client=PrinterClientInfo(connected=True)) with self.assertRaises(Exception) as ctx: printer.modify_current_job("random") self.assertTrue("random is not allowed" in str(ctx.exception))
def test_modify_job_disconnect(self, mock_post_uri): printer = Octoprint("192.168.1.15", client=PrinterClientInfo(connected=True)) self.assertTrue(printer.client.connected) result = printer.modify_current_job("toggle") self.assertFalse(result) self.assertFalse(printer.client.connected)
def test_modify_job_cancel_ok(self, mock_post_uri): mock_post_uri.return_value.status_code = 204 printer = Octoprint("192.168.1.15", client=PrinterClientInfo(connected=True)) result = printer.modify_current_job("cancel") self.assertTrue(result) args, kwargs = mock_post_uri.call_args self.assertEqual(kwargs["json"], {"command": "cancel"})
def test_modify_job_inactive_printer(self, mock_post_uri): printer = Octoprint("192.168.1.15") self.assertEqual(mock_post_uri.call_count, 0) result = printer.modify_current_job("toggle") self.assertFalse(result)
def test_modify_job_disconnected(self, mock_post_uri): printer = Octoprint("192.168.1.15", client=PrinterClientInfo(connected=False)) result = printer.modify_current_job("toggle") self.assertEqual(mock_post_uri.call_count, 0) self.assertFalse(result)