def test_create(self) -> None: client = self.client definition = TaskDefinition() definition.name = "The greatest task ever" def_str = json.dumps(definition.to_dict()) with client_ctx(Tasks, client): tasks = Tasks() # pylint: disable=no-member tasks._Tasks__create_from_json(def_str) # type: ignore # pylint: enable=no-member client._call.assert_called_once_with( 'comp.task.create', definition.to_dict(), ) client._call.reset_mock() patched_open = "golem.interface.client.tasks.open" with patch(patched_open, mock_open(read_data='{"name": "Golem task"}')): client._call.return_value = ('task_id', None) tasks.create("foo") task_def = json.loads('{"name": "Golem task"}') client._call.assert_called_once_with( 'comp.task.create', task_def, force=False, )
def test_get_output_path(self): td = TaskDefinition() td.name = "MY task" tdict = {'options': {'output_path': '/dir3/dir4', 'format': 'txt'}} assert RenderingTaskBuilder.get_output_path(tdict, td) == \ path.join("/dir3/dir4", "MY task.txt")