def json_should_not_match_schema(context, s, j): """Carrega o JSON {jdata} no atributo 'test_json' no context.""" schema = json_schema.loads(getattr(context, s), allow_unsafe=True) json_string = getattr(context, j) logging.info(schema) logging.info(json_string) assert not schema == json_string
def i_have_unsafe_schema(context, schema): """Carrega o schema {schema} con allow_unsafe.""" try: s = json_schema.loads(getattr(context, schema), allow_unsafe=True) except: logging.info("### Erro ao carregar o schema ###") logging.info(repr(getattr(context, schema))) raise context.__setattr__("test_schema", s)
def i_have_schema(context, schema): """Carrega o schema {schema} no atributo 'test_schema' no context.""" try: s = json_schema.loads(getattr(context, schema)) except: logging.info("### Erro ao carregar o schema ###") logging.info(repr(getattr(context, schema))) raise context.__setattr__("test_schema", s)
def json_should_match_schema(context, s, j): """Carrega o JSON {jdata} no atributo 'test_json' no context.""" schema = json_schema.loads(getattr(context, s), allow_unsafe=True) json_string = getattr(context, j) try: if not schema == json_string: schema.full_check(json_string) except: logging.info(schema) logging.info(json_string) pass assert schema == json_string
def i_cant_have_schema(context, schema): """Falha ao carregar o schema.""" try: s = json_schema.loads(getattr(context, schema)) except Exception, e: assert str(e) == "O schema nao parece ser valido"