def validate(self, keys=None, test_keys=None): """ All arguments to the :meth:`~cases.DtfCase.validate()` method are optional, and if any arguments have the value of ``None`` :meth:`validate()` will substitute values from the object instance or user input values. :param list keys: A list of required keys that the :attr:`test_spec.keys <cases.dtf.test_spec>` must contain to be valid. :param list test_keys: A list of keys from the ``test_spec`` that the must be identical to or a superset of the keys in the ``keys`` list. Defaults to the value of :attr:`test_spec.keys <cases.dtf.test_spec>`. Checks the keys in each test specification to ensure that the test has the required keys. """ if keys is None: if self.keys == []: msg = 'must add required_keys to DtfCase subclasses.' results.add(self.name, False, msg) raise DtfException(msg) else: keys = self.keys if test_keys is None: test_keys = self.test_spec.keys() t = True for key in keys: if key in test_keys: pass else: t = False break if t is True: msg = '"{0}" is a valid "{1}" test spec.'.format(self.name, self.test_spec['name'], self.test_spec['type']) else: msg = '"{0}" is not a valid "{1}" test spec.'.format(self.name, self.test_spec['name'], self.test_spec['type']) results.add(self.name, t, msg) return (t, msg)
def response(self, result, msg): """ :param bool result: ``True`` if the test passes, otherwise ``False``. :param msg string: A response message. :param bool verbose: Causes :meth:`~cases.DtfCases.response()` a to ``False``. :param bool fatal: Defaults to ``False``. """ logger.debug('received message "{0}" from test with result status {1}'.format(msg, str(result))) results.add(self.name, result, msg)