def setUpClass(cls): super().setUpClass() cls._exit_stack = contextlib.ExitStack() cls.exit_stack = cls._exit_stack.__enter__() cls.container_ip, cls.ca = cls.exit_stack.enter_context( mysql(sql_setup=cls.SQL_SETUP) ) cls.source_config = MySQLSourceConfig( host="mysql.unittest", port=3306, user=DOCKER_ENV["MYSQL_USER"], password=DOCKER_ENV["MYSQL_PASSWORD"], db=DOCKER_ENV["MYSQL_DATABASE"], record_query="select * from record_data where `key`=%s", update_query="""insert into record_data (`key`,`feature_PetalLength`,`feature_PetalWidth`, `feature_SepalLength`, `feature_SepalWidth`, `target_name_confidence`, `target_name_value`) values (%s,%s,%s,%s,%s,%s,%s) ON DUPLICATE KEY UPDATE `key`=%s, `feature_PetalLength`=%s, `feature_PetalWidth`=%s, `feature_SepalLength`=%s, `feature_SepalWidth`=%s, `target_name_confidence`=%s, `target_name_value`=%s""", records_query="select * from record_data", model_columns="key feature_PetalLength feature_PetalWidth feature_SepalLength feature_SepalWidth target_name_confidence target_name_value", ca=cls.ca, ) # Make it so that when the client tries to connect to mysql.unittest the # address it gets back is the one for the container cls.exit_stack.enter_context( patch( "socket.getaddrinfo", return_value=[ ( socket.AF_INET, socket.SOCK_STREAM, 6, "", (cls.container_ip, 3306), ) ], ) )
def setUpClass(cls): super().setUpClass() cls._exit_stack = contextlib.ExitStack() cls.exit_stack = cls._exit_stack.__enter__() cls.container_ip, cls.ca = cls.exit_stack.enter_context(mysql()) cls.database_config = MySQLDatabaseConfig( host="mysql.unittest", port=3306, user=DOCKER_ENV["MYSQL_USER"], password=DOCKER_ENV["MYSQL_PASSWORD"], db=DOCKER_ENV["MYSQL_DATABASE"], ca=cls.ca, ) # Make it so that when the client tries to connect to mysql.unittest the # address it get's back is the one for the container cls.exit_stack.enter_context( patch( "socket.getaddrinfo", return_value=[( socket.AF_INET, socket.SOCK_STREAM, 6, "", (cls.container_ip, 3306), )], ))
def setUpClass(cls): super().setUpClass() cls._exit_stack = contextlib.ExitStack() cls.exit_stack = cls._exit_stack.__enter__() cls.container_ip, cls.ca = cls.exit_stack.enter_context(mysql()) cls.source_config = MySQLSourceConfig( host="mysql.unittest", port=3306, user=DOCKER_ENV["MYSQL_USER"], password=DOCKER_ENV["MYSQL_PASSWORD"], db=DOCKER_ENV["MYSQL_DATABASE"], key="key", features={ k: k for k in [ "PetalLength", "PetalWidth", "SepalLength", "SepalWidth", ] }, predictions={"target_name": ("flower_type", "flower_confidence")}, ca=cls.ca, init=cls.SQL_SETUP, record="SELECT * FROM record_data WHERE `key`=%s", records="SELECT * FROM record_data", update=inspect.cleandoc(""" INSERT INTO record_data ( `key`, `PetalLength`, `PetalWidth`, `SepalLength`, `SepalWidth`, `flower_type`, `flower_confidence` ) VALUES (%s,%s,%s,%s,%s,%s,%s) ON DUPLICATE KEY UPDATE `PetalLength`=%s, `PetalWidth`=%s, `SepalLength`=%s, `SepalWidth`=%s, `flower_type`=%s, `flower_confidence`=%s """), ) # Make it so that when the client tries to connect to mysql.unittest the # address it gets back is the one for the container cls.exit_stack.enter_context( patch( "socket.getaddrinfo", return_value=[( socket.AF_INET, socket.SOCK_STREAM, 6, "", (cls.container_ip, 3306), )], ))