コード例 #1
0
def test_MockModule():
    mock = _MockModule('mocked_module')
    assert isinstance(mock.some_attr, _MockObject)
    assert isinstance(mock.some_method, _MockObject)
    assert isinstance(mock.attr1.attr2, _MockObject)
    assert isinstance(mock.attr1.attr2.meth(), _MockObject)

    assert repr(mock.some_attr) == 'mocked_module.some_attr'
    assert repr(mock.some_method) == 'mocked_module.some_method'
    assert repr(mock.attr1.attr2) == 'mocked_module.attr1.attr2'
    assert repr(mock.attr1.attr2.meth) == 'mocked_module.attr1.attr2.meth'

    assert repr(mock) == 'mocked_module'
コード例 #2
0
sys.path.insert(0, os.path.abspath("../../src"))
os.environ["DJANGO_DEBUG"] = "false"
os.environ["DJANGO_SETTINGS_MODULE"] = "dso_api.settings"
os.environ["SCHEMA_URL"] = "https://schemas.data.amsterdam.nl/"

# At readthedocs, GDAL is not part of the build container.
# Feature request here: https://github.com/readthedocs/readthedocs.org/issues/8160
# The workaround to use 'autodoc_mock_imports' doesn't work either, and is applied too late.
# Instead, the internal machinery of 'autodoc_mock_imports' is reused here to avoid GDAL imports.


class GDALMockModule(_MockModule):
    GDAL_VERSION = (3, 0)


sys.modules["django.contrib.gis.geos.libgeos"] = _MockModule(
    "django.contrib.gis.geos.libgeos")
sys.modules["django.contrib.gis.gdal.libgdal"] = GDALMockModule(
    "django.contrib.gis.gdal.libgdal")

django.setup()

# -- Project information -----------------------------------------------------

project = "DSO-API"
copyright = "2021, Team Data Diensten, Gemeente Amsterdam."
author = "Team Data Diensten, Gemeente Amsterdam."

# The full version, including alpha/beta/rc tags
release = "v1"

# -- General configuration ---------------------------------------------------