Example #1
0
def test_invalid_schema_in_get_schema():
    """Asserts that an invalid schema throws an error in get_schema."""
    from json import JSONDecodeError

    # setup
    uid = uuid.uuid4()
    schema_dir = f'/tmp/{uid}'
    schema_file = f'{schema_dir}/bad_schema.json'
    os.makedirs(schema_dir)
    text_file = open(schema_file, 'w')
    text_file.write('this will fail[];fail()')
    text_file.close()

    with pytest.raises(JSONDecodeError):
        get_schema_store(validate_schema=True, schema_search_path=schema_dir)
    def rsbc_filing_schema_store(self) -> dict:
        """Return the cached schema_store.

        If this is running in a Flask context,
        then it will return the dict cache holding the JSONSchemas
        used by the Registry for legal filings.
        :return: dict
        """
        if 'rsbc_filing_schema_store' not in g:
            g.rsbc_filing_schema_store = get_schema_store()  # pylint: disable=assigning-non-slot

        return g.rsbc_filing_schema_store
Example #3
0
    def rsbc_schema_store(self) -> dict:
        """Return the cached schema_store.

        If this is running in a Flask context,
        then it will return the dict cache holding the JSONSchemas
        used by the Registry for the application transactions.
        :return: dict
        """
        if 'rsbc_schema_store' not in g:
            g.rsbc_schema_store = get_schema_store()

        return g.rsbc_schema_store
def test_get_schema_store():
    """Assert the schema store is setup correctly."""
    schema_store = get_schema_store()

    assert len(schema_store) == len(TEST_SCHEMAS_DATA)

    # assuming  test_is_business_schema_valid passes, this should pass too
    try:
        for k, schema in schema_store.items():
            print(f'checking schema:{k}')
            Draft7Validator.check_schema(schema)
    except SchemaError as error:
        print(error)
        assert False
    assert True