Device Detection services for 51Degrees Pipeline

tests.test_cloudexampleimports Namespace Reference

Detailed Description

A cloud example has to run with only the cloud packages installed, because the on-premise package ships as source and needs a C++ toolchain to build.

Someone following a cloud example should not have to build that.

These tests import each cloud example in a separate process with the on-premise package blocked, so they prove the point whether or not the on-premise package happens to be installed on the machine running them. They need no resource key and no network connection.

Classes

class  CloudExampleImportTests

Variables

list BLOCKED
list CLOUD_EXAMPLES
str SCRIPT

Variable Documentation

◆ BLOCKED

list tests.test_cloudexampleimports.BLOCKED
Initial value:
= [
"fiftyone_devicedetection_onpremise",
"fiftyone_devicedetection",
]

◆ CLOUD_EXAMPLES

list tests.test_cloudexampleimports.CLOUD_EXAMPLES
Initial value:
= [
"fiftyone_devicedetection_examples.cloud.configurator_console",
"fiftyone_devicedetection_examples.cloud.failuretomatch",
"fiftyone_devicedetection_examples.cloud.gettingstarted_console",
"fiftyone_devicedetection_examples.cloud.metadata_console",
"fiftyone_devicedetection_examples.cloud.nativemodellookup_console",
"fiftyone_devicedetection_examples.cloud.taclookup_console",
"fiftyone_devicedetection_examples.cloud.gettingstarted_web.app",
"fiftyone_devicedetection_examples.cloud.useragentclienthints_web.app",
]

◆ SCRIPT

str tests.test_cloudexampleimports.SCRIPT
Initial value:
= """
import importlib.abc
import sys
blocked = {blocked!r}
class Blocker(importlib.abc.MetaPathFinder):
def find_module(self, fullname, path=None):
return self.find_spec(fullname, path)
def find_spec(self, fullname, path=None, target=None):
root = fullname.split(".")[0]
if root in blocked:
raise ImportError(
"'" + fullname + "' must not be needed by a cloud example")
return None
sys.meta_path.insert(0, Blocker())
import {module}
print("ok")
"""