def get_profile_info(session, test_id=None): try: _conv = session["conv"] except KeyError: pass else: try: iss = _conv.entity.provider_info["issuer"] except TypeError: iss = "" profile = to_profile(session, "dict") if test_id is None: try: test_id = session["testid"] except KeyError: return {} return { "Issuer": iss, "Profile": profile, "Test ID": test_id, "Test description": session["node"].desc, "Timestamp": in_a_while() } return {}
def dump_log(self, session, test_id): try: _conv = session["conv"] except KeyError: pass else: _pi = get_profile_info(session, test_id) if _pi: sline = 60*"=" output = ["%s: %s" % (k, _pi[k]) for k in ["Issuer", "Profile", "Test ID"]] output.append("Timestamp: %s" % in_a_while()) output.extend(["", sline, ""]) output.extend(trace_output(_conv.trace)) output.extend(["", sline, ""]) output.extend(condition(_conv.events)) output.extend(["", sline, ""]) # and lastly the result info = { "events": _conv.events, "trace": _conv.trace } output.append("RESULT: %s" % represent_result(info, session)) output.append("") txt = "\n".join(output) print(txt)
def get_profile_info(session, test_id=None): try: _conv = session["conv"] except KeyError: pass else: try: iss = _conv.entity.provider_info["issuer"] except TypeError: iss = "" profile = to_profile(session, "dict") if test_id is None: try: test_id = session["testid"] except KeyError: return {} return {"Issuer": iss, "Profile": profile, "Test ID": test_id, "Test description": session["node"].desc, "Timestamp": in_a_while()} return {}
def dump_log(self, session, test_id=None): try: _conv = session["conv"] except KeyError: pass else: _pi = self.profile_info(session, test_id) if _pi: _tid = _pi["Test ID"] path = log_path(session, _tid) if not path: return sline = 60*"=" output = ["%s: %s" % (k, _pi[k]) for k in ["Issuer", "Profile", "Test ID"]] output.append("Timestamp: %s" % in_a_while()) output.extend(["", sline, ""]) output.extend(trace_output(_conv.trace)) output.extend(["", sline, ""]) output.extend(test_output(_conv.test_output)) output.extend(["", sline, ""]) # and lastly the result self.store_test_info(session, _pi) _info = session["test_info"][_tid] output.append("RESULT: %s" % represent_result(_info, _tid)) output.append("") f = open(path, "w") f.write("\n".join(output)) f.close() pp = path.split("/") create_tar_archive(pp[1], pp[2]) return path
def dump_log(self, session, test_id): try: _conv = session["conv"] except KeyError: pass else: _pi = get_profile_info(session, test_id) if _pi: sline = 60 * "=" output = [ "%s: %s" % (k, _pi[k]) for k in ["Issuer", "Profile", "Test ID"] ] output.append("Timestamp: %s" % in_a_while()) output.extend(["", sline, ""]) output.extend(trace_output(_conv.trace)) output.extend(["", sline, ""]) output.extend(condition(_conv.events)) output.extend(["", sline, ""]) # and lastly the result info = {"events": _conv.events, "trace": _conv.trace} output.append("RESULT: %s" % represent_result(info, session)) output.append("") txt = "\n".join(output) print(txt)
def test_valid(): assert valid("2000-01-12T00:00:00Z") is False current_year = datetime.today().year assert valid("%d-01-12T00:00:00Z" % (current_year + 1)) is True this_instance = instant() assert valid(this_instance) is False # unless on a very fast machine :-) soon = in_a_while(seconds=10) assert valid(soon) is True
def export(self): res = self.dump() res["expires"] = in_a_while(days=self._exp_days, seconds=self._exp_secs, minutes=self._exp_min, hours=self._exp_hour, weeks=self._exp_week) return res
def dump_log(self, session, test_id=None): try: _conv = session["conv"] except KeyError: pass else: _pi = self.profile_info(session, test_id) if _pi: _tid = _pi["Test ID"] path = log_path(session, _tid) if not path: return sline = 60 * "=" output = [ "%s: %s" % (k, _pi[k]) for k in ["Issuer", "Profile", "Test ID"] ] output.append("Timestamp: %s" % in_a_while()) output.extend(["", sline, ""]) output.extend(trace_output(_conv.trace)) output.extend(["", sline, ""]) output.extend(test_output(_conv.test_output)) output.extend(["", sline, ""]) # and lastly the result self.store_test_info(session, _pi) _info = session["test_info"][_tid] output.append("RESULT: %s" % represent_result(_info, _tid)) output.append("") f = open(path, "w") txt = "\n".join(output) try: f.write(txt) except UnicodeEncodeError: f.write(txt.encode("utf8")) f.close() pp = path.split("/") create_tar_archive(pp[1], pp[2]) return path
def test_later_than_str(): a = in_a_while(seconds=10) b = in_a_while(seconds=20) assert later_than(b, a) assert later_than(a, b) is False
def test_timeout(): soon = in_a_while(seconds=-1, time_format="") assert valid(soon) is False
def _expiration(timeout, strformat=None): if timeout == "now": return time_util.instant(strformat) else: # validity time should match lifetime of assertions return time_util.in_a_while(minutes=timeout, format=strformat)
def _expiration(timeout, time_format=None): if timeout == "now": return time_util.instant(time_format) else: # validity time should match lifetime of assertions return time_util.in_a_while(minutes=timeout, time_format=time_format)