unittest.mock.DEFAULT

Here are the examples of the python api unittest.mock.DEFAULT taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

39 Examples 7

5 Source : test_io.py
with MIT License
from int-brain-lab

    def setUp(self):
        self.patcher = patch.multiple('globus_sdk',
                                      NativeAppAuthClient=unittest.mock.DEFAULT,
                                      RefreshTokenAuthorizer=unittest.mock.DEFAULT,
                                      TransferClient=unittest.mock.DEFAULT)
        self.patcher.start()
        self.addCleanup(self.patcher.stop)

    def test_as_globus_path(self):

3 Source : mocklib.py
with Apache License 2.0
from NSO-developer

    def __init__(self, mock_gens):
        self.attribute_name = None
        self.new = mock.DEFAULT
        self.mock_gens = mock_gens

    def __call__(self, fn):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def defaultEntityReference(self, specifications, context, hostSession):
        self.__assertIsIterableOf(specifications, EntitySpecification)
        self.__assertCallingContext(context, hostSession)
        return mock.DEFAULT

    def getEntityAttribute(self, entityRefs, name, context, hostSession, defaultValue=None):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def getEntityAttribute(self, entityRefs, name, context, hostSession, defaultValue=None):
        self.__assertIsIterableOf(entityRefs, str)
        assert isinstance(name, str)
        self.__assertCallingContext(context, hostSession)
        assert isinstance(defaultValue, (str, int, float, bool)) or defaultValue is None
        return mock.DEFAULT

    def setEntityAttribute(self, entityRefs, name, value, context, hostSession):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def setEntityAttribute(self, entityRefs, name, value, context, hostSession):
        self.__assertIsIterableOf(entityRefs, str)
        assert isinstance(name, str)
        assert isinstance(value, (str, bool, int, float))
        self.__assertCallingContext(context, hostSession)
        return mock.DEFAULT

    def entityVersion(self, entityRefs, context, hostSession):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def entityVersion(self, entityRefs, context, hostSession):
        self.__assertIsIterableOf(entityRefs, str)
        self.__assertCallingContext(context, hostSession)
        return mock.DEFAULT

    def entityVersions(

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def entityVersions(
            self, entityRefs, context, hostSession, includeMetaVersions=False, maxNumVersions=-1):
        self.__assertIsIterableOf(entityRefs, str)
        self.__assertCallingContext(context, hostSession)
        assert isinstance(includeMetaVersions, bool)
        assert isinstance(maxNumVersions, int)
        return mock.DEFAULT

    def finalizedEntityVersion(self, entityRefs, context, hostSession, overrideVersionName=None):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def finalizedEntityVersion(self, entityRefs, context, hostSession, overrideVersionName=None):
        self.__assertIsIterableOf(entityRefs, str)
        self.__assertCallingContext(context, hostSession)
        assert isinstance(overrideVersionName, str) or overrideVersionName is None
        return mock.DEFAULT

    def setRelatedReferences(

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def preflight(self, targetEntityRefs, entitySpecs, context, hostSession):
        self.__assertIsIterableOf(targetEntityRefs, str)
        self.__assertIsIterableOf(entitySpecs, EntitySpecification)
        self.__assertCallingContext(context, hostSession)
        assert len(targetEntityRefs) == len(entitySpecs)
        return mock.DEFAULT

    def createState(self, hostSession, parentState=None):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def managementPolicy(self, specifications, context, hostSession):
        self.__assertIsIterableOf(specifications, EntitySpecification)
        self.__assertCallingContext(context, hostSession)

        return mock.DEFAULT

    def isEntityReference(self, tokens, hostSession):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def isEntityReference(self, tokens, hostSession):
        self.__assertIsIterableOf(tokens, str)
        assert isinstance(hostSession, HostSession)
        return mock.DEFAULT

    def entityExists(self, entityRefs, context, hostSession):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def entityExists(self, entityRefs, context, hostSession):
        self.__assertIsIterableOf(entityRefs, str)
        self.__assertCallingContext(context, hostSession)
        return mock.DEFAULT

    def resolveEntityReference(self, entityRefs, context, hostSession):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def resolveEntityReference(self, entityRefs, context, hostSession):
        self.__assertIsIterableOf(entityRefs, str)
        self.__assertCallingContext(context, hostSession)
        return mock.DEFAULT

    def entityName(self, entityRefs, context, hostSession):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def entityName(self, entityRefs, context, hostSession):
        self.__assertIsIterableOf(entityRefs, str)
        self.__assertCallingContext(context, hostSession)
        return mock.DEFAULT

    def entityDisplayName(self, entityRefs, context, hostSession):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def entityDisplayName(self, entityRefs, context, hostSession):
        self.__assertIsIterableOf(entityRefs, str)
        self.__assertCallingContext(context, hostSession)
        return mock.DEFAULT

    def getEntityAttributes(self, entityRefs, context, hostSession):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def getEntityAttributes(self, entityRefs, context, hostSession):
        self.__assertIsIterableOf(entityRefs, str)
        self.__assertCallingContext(context, hostSession)
        return mock.DEFAULT

    def setEntityAttributes(self, entityRefs, data, context, hostSession, merge=True):

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def setEntityAttributes(self, entityRefs, data, context, hostSession, merge=True):
        self.__assertIsIterableOf(entityRefs, str)
        # TODO(DF): The following fails for `register` since it passes a
        #   list of dicts.
        # assert isinstance(data, dict)
        self.__assertCallingContext(context, hostSession)
        assert isinstance(merge, bool)
        return mock.DEFAULT

    def getRelatedReferences(

3 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def register(self, primaryStrings, targetEntityRefs, entitySpecs, context, hostSession):
        self.__assertIsIterableOf(primaryStrings, str)
        self.__assertIsIterableOf(targetEntityRefs, str)
        self.__assertIsIterableOf(entitySpecs, EntitySpecification)
        self.__assertCallingContext(context, hostSession)
        assert len(primaryStrings) == len(targetEntityRefs)
        assert len(primaryStrings) == len(entitySpecs)
        return mock.DEFAULT

    @staticmethod

3 Source : util.py
with MIT License
from tpodlaski

    def update(self, *args, **kwargs):
        self.args = args
        self.kwargs = kwargs
        self.headers = self.kwargs['headers']
        (self.scheme, self.netloc, self.path, self.params,  self.query_str, 
         self.fragment) = urlparse(args[0])
        self.url = '{}://{}{}'.format(self.scheme, self.netloc, self.path)
        self.query = MultiDict(parse_qsl(self.query_str))
        if 'data' in self.kwargs:
            self.data = json.loads(self.kwargs['data']) if self.kwargs['data'] else {}
        else:
            self.data = {}
        return mock.DEFAULT


class MockTestCase(TestCase):

0 Source : __init__.py
with Apache License 2.0
from CS-SI

    def compute_csw_records(self, mock_catalog, raise_error_for="", *args, **kwargs):
        if raise_error_for:
            for constraint in kwargs["constraints"]:
                if constraint.propertyname == raise_error_for:
                    exception_report = etree.parse(
                        StringIO(
                            '  <  ExceptionReport xmlns="http://www.opengis.net/ows/1.1" '
                            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation='  # noqa
                            '"http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd" version="1.0.0" language="en">'  # noqa
                            ' < Exception exceptionCode="NoApplicableCode"> < ExceptionText>Unknown exception < /ExceptionText>'  # noqa
                            " < /Exception> < /ExceptionReport>"
                        )
                    )
                    raise ExceptionReport(exception_report)
        bbox_wgs84 = random.choice(
            [
                None,
                (
                    self.footprint["lonmin"],
                    self.footprint["latmin"],
                    self.footprint["lonmax"],
                    self.footprint["latmax"],
                ),
            ]
        )
        Record = namedtuple(
            "CswRecord",
            [
                "identifier",
                "title",
                "creator",
                "publisher",
                "abstract",
                "subjects",
                "date",
                "references",
                "bbox_wgs84",
                "bbox",
                "xml",
            ],
        )
        BBox = namedtuple("BBox", ["minx", "miny", "maxx", "maxy", "crs"])
        Crs = namedtuple("Crs", ["code", "id"])
        mock_catalog.records = OrderedDict(
            {
                "id ent ifier": Record(
                    identifier="id ent ifier",
                    title="MyRecord",
                    creator="eodagUnitTests",
                    publisher="eodagUnitTests",
                    abstract="A dumb CSW record for testing purposes",
                    subjects=[],
                    date="",
                    references=[
                        {
                            "scheme": "WWW:DOWNLOAD-1.0-http--download",
                            "url": "http://www.url.eu/dl",
                        }
                    ],
                    bbox_wgs84=bbox_wgs84,
                    bbox=BBox(
                        minx=self.footprint["lonmin"],
                        miny=self.footprint["latmin"],
                        maxx=self.footprint["lonmax"],
                        maxy=self.footprint["latmax"],
                        crs=Crs(code=4326, id="EPSG"),
                    ),
                    xml="""
                     < csw:Record xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
                        xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/"    # noqa
                        xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml"    # noqa
                        xmlns:ows="http://www.opengis.net/ows" xmlns:xs="http://www.w3.org/2001/XMLSchema"    # noqa
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                         < dc:identifier>urn:x-gs:resource:localhost::52 < /dc:identifier>
                         < dc:title>S2 mosaic on Madrid < /dc:title>
                         < dc:format/>
                         < dct:references scheme="WWW:LINK-1.0-http--link">
                            http://localhost:8000/admin/storm_csw/resource/52/change/
                         < /dct:references>
                         < dct:modified>2017-05-05 13:02:35.548758+00:00 < /dct:modified>
                         < dct:abstract/>
                         < dc:date>2017-05-05 13:02:35.139807+00:00 < /dc:date>
                         < dc:creator>  < /dc:creator>
                         < dc:coverage/>
                         < ows:BoundingBox dimensions="2" crs="EPSG">
                         < ows:LowerCorner>40.405012373 -3.70433905592 < /ows:LowerCorner>
                         < ows:UpperCorner>40.420696583 -3.67011406889 < /ows:UpperCorner>
                         < /ows:BoundingBox>
                     < /csw:Record>
                """,
                )
            }
        )
        return mock.DEFAULT

    def _dummy_product(

0 Source : core.py
with Apache License 2.0
from mars-project

def patch_super():
    back = inspect.currentframe().f_back
    if not back or "__class__" not in back.f_locals:
        raise RuntimeError("Calling super() in the incorrect context.")

    patch_super_cls = back.f_locals["__class__"].__patch_super__
    patch_self = back.f_locals.get("self")

    class _SuperAccessor:
        def __getattribute__(self, item):
            func = getattr(patch_super_cls, item)
            if func == mock.DEFAULT:
                raise AttributeError(f"super object has no attribute '{item}'")
            if patch_self:
                return types.MethodType(func, patch_self)
            return func

    return _SuperAccessor()


def print_entrance(func):

0 Source : django-tests-migrations-test_commands.py
with Apache License 2.0
from SMAT-Lab

    def test_makemigrations_consistency_checks_respect_routers(self):
        """
        The history consistency checks in makemigrations respect
        settings.DATABASE_ROUTERS.
        """
        def patched_has_table(migration_recorder):
            if migration_recorder.connection is connections['other']:
                raise Exception('Other connection')
            else:
                return mock.DEFAULT

        self.assertTableNotExists('migrations_unicodemodel')
        apps.register_model('migrations', UnicodeModel)
        with mock.patch.object(
                MigrationRecorder, 'has_table',
                autospec=True, side_effect=patched_has_table) as has_table:
            with self.temporary_migration_module() as migration_dir:
                call_command("makemigrations", "migrations", verbosity=0)
                initial_file = os.path.join(migration_dir, "0001_initial.py")
                self.assertTrue(os.path.exists(initial_file))
                self.assertEqual(has_table.call_count, 1)  # 'default' is checked

                # Router says not to migrate 'other' so consistency shouldn't
                # be checked.
                with self.settings(DATABASE_ROUTERS=['migrations.routers.TestRouter']):
                    call_command('makemigrations', 'migrations', verbosity=0)
                self.assertEqual(has_table.call_count, 2)  # 'default' again

                # With a router that doesn't prohibit migrating 'other',
                # consistency is checked.
                with self.settings(DATABASE_ROUTERS=['migrations.routers.DefaultOtherRouter']):
                    with self.assertRaisesMessage(Exception, 'Other connection'):
                        call_command('makemigrations', 'migrations', verbosity=0)
                self.assertEqual(has_table.call_count, 4)  # 'default' and 'other'

                # With a router that doesn't allow migrating on any database,
                # no consistency checks are made.
                with self.settings(DATABASE_ROUTERS=['migrations.routers.TestRouter']):
                    with mock.patch.object(TestRouter, 'allow_migrate', return_value=False) as allow_migrate:
                        call_command('makemigrations', 'migrations', verbosity=0)
                allow_migrate.assert_any_call('other', 'migrations', model_name='UnicodeModel')
                # allow_migrate() is called with the correct arguments.
                self.assertGreater(len(allow_migrate.mock_calls), 0)
                called_aliases = set()
                for mock_call in allow_migrate.mock_calls:
                    _, call_args, call_kwargs = mock_call
                    connection_alias, app_name = call_args
                    called_aliases.add(connection_alias)
                    # Raises an error if invalid app_name/model_name occurs.
                    apps.get_app_config(app_name).get_model(call_kwargs['model_name'])
                self.assertEqual(called_aliases, set(connections))
                self.assertEqual(has_table.call_count, 4)

    def test_failing_migration(self):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def info(self):
        return mock.DEFAULT

    def updateTerminology(self, stringDict, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def updateTerminology(self, stringDict, hostSession):
        return mock.DEFAULT

    def getSettings(self, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def getSettings(self, hostSession):
        return mock.DEFAULT

    def setSettings(self, settings, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def setSettings(self, settings, hostSession):
        return mock.DEFAULT

    def prefetch(self, entityRefs, context, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def prefetch(self, entityRefs, context, hostSession):
        return mock.DEFAULT

    def flushCaches(self, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def flushCaches(self, hostSession):
        return mock.DEFAULT

    def defaultEntityReference(self, specifications, context, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def setRelatedReferences(
            self, entityRef, relationshipSpec, relatedRefs, context, hostSession, append=True):
        return mock.DEFAULT

    def preflight(self, targetEntityRefs, entitySpecs, context, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def createState(self, hostSession, parentState=None):
        return mock.DEFAULT

    def startTransaction(self, state, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def startTransaction(self, state, hostSession):
        return mock.DEFAULT

    def finishTransaction(self, state, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def finishTransaction(self, state, hostSession):
        return mock.DEFAULT

    def cancelTransaction(self, state, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def cancelTransaction(self, state, hostSession):
        return mock.DEFAULT

    def freezeState(self, state, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def freezeState(self, state, hostSession):
        return mock.DEFAULT

    def thawState(self, token, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def thawState(self, token, hostSession):
        return mock.DEFAULT

    @staticmethod

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def identifier():
        return mock.DEFAULT

    def displayName(self):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def displayName(self):
        return mock.DEFAULT

    def initialize(self, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def initialize(self, hostSession):
        return mock.DEFAULT

    def managementPolicy(self, specifications, context, hostSession):

0 Source : test_manager.py
with Apache License 2.0
from TheFoundryVisionmongers

    def getRelatedReferences(
            self, entityRefs, relationshipSpecs, context, hostSession, resultSpec=None):
        return mock.DEFAULT

    def register(self, primaryStrings, targetEntityRefs, entitySpecs, context, hostSession):