From 6fb4655ca07991808f3ea06efe065d19ebe8b266 Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Wed, 5 Apr 2017 23:08:05 +0300 Subject: [PATCH] [core] Refactor validation * do not save validation errors from CLI layer to database. It includes such redundant data as IOError (when task file doesn't exist) * include validation at task start by default. It is bad sign to allow starting tasks without validation. Change-Id: I0d30ff31fb6fbc467ef3cda01e7de1f46c5f79fe --- tests/unit/fakes.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/unit/fakes.py b/tests/unit/fakes.py index 77c06ac5..a97370eb 100644 --- a/tests/unit/fakes.py +++ b/tests/unit/fakes.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import itertools import multiprocessing import random import re @@ -1840,7 +1841,6 @@ class FakeUserContext(FakeContext): class FakeDeployment(dict): - update_status = mock.Mock() def __init__(self, **kwargs): namespace = kwargs.pop("namespace", "openstack") @@ -1849,6 +1849,7 @@ class FakeDeployment(dict): "users": kwargs.pop("users", [])}], "default": [{"admin": None, "users": []}]} dict.__init__(self, **kwargs) + self.update_status = mock.Mock() def get_platforms(self): return [platform for platform in self["credentials"]] @@ -1857,18 +1858,16 @@ class FakeDeployment(dict): return self["credentials"][namespace][0] -class FakeTask(dict): +class FakeTask(dict, object): def __init__(self, task=None, temporary=False, **kwargs): self.is_temporary = temporary - self.task = task or kwargs self.set_failed = mock.Mock() self.set_validation_failed = mock.Mock() - - def __getitem__(self, key): - if key in self: - return self[key] - return self.task[key] + task = task or {} + for k, v in itertools.chain(task.items(), kwargs.items()): + self[k] = v + self.task = self def to_dict(self): return self