def testModuleImportDynamic(self):
     moduleName = str(uuid.uuid4())
     kwargs = {"foo": 1, "bar": moduleName}
     createModule(moduleName, **kwargs)
     module = __import__(moduleName, {}, {}, [])
     self.assertIsInstance(module, types.ModuleType)
     self.assertEqual(module.__name__, moduleName)
 def testModuleContainsClientClass(self):
     moduleName = str(uuid.uuid4())
     kwargs = {"foo": 1, "bar": moduleName}
     createModule(moduleName, **kwargs)
     module = __import__(moduleName, {}, {}, [])
     self.assertTrue("Client" in module.__dict__)
     # module.Client is a class
     self.assertTrue(type(module.Client) is type)
 def testModuleImportStatic(self):
     moduleName = "foo"
     kwargs = {"foo": 1, "bar": 2}
     createModule(moduleName, **kwargs)
     try:
         import foo
     except ImportError:
         self.fail("Could not import module")
     self.assertIsInstance(foo, types.ModuleType)
 def testClientArgOveride(self):
     moduleName = str(uuid.uuid4())
     moduleKwargs = {"foo": 1, "bar": moduleName}
     initializerKwargs = {"foo": 11, "baz": None}
     with mockMemcacheClient():
         createModule(moduleName, **moduleKwargs)
         module = __import__(moduleName, {}, {}, [])
         client = module.Client(**initializerKwargs)
     expected = dict(moduleKwargs, **initializerKwargs)
     self.assertEqual(client.initKwargs, expected)
 def testClientOveridesInitializer(self):
     moduleName = str(uuid.uuid4())
     kwargs = {"foo": 1, "bar": moduleName}
     args = (1, 2, "woot")
     with mockMemcacheClient():
         createModule(moduleName, **kwargs)
         module = __import__(moduleName, {}, {}, [])
         client = module.Client(*args)
     self.assertEqual(client.initArgs, args)
     self.assertEqual(client.initKwargs, kwargs)