本文整理汇总了Python中tests.mocks.EngineEmul.create_artifact方法的典型用法代码示例。如果您正苦于以下问题:Python EngineEmul.create_artifact方法的具体用法?Python EngineEmul.create_artifact怎么用?Python EngineEmul.create_artifact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.mocks.EngineEmul
的用法示例。
在下文中一共展示了EngineEmul.create_artifact方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_encode_decode_infinities
# 需要导入模块: from tests.mocks import EngineEmul [as 别名]
# 或者: from tests.mocks.EngineEmul import create_artifact [as 别名]
def test_encode_decode_infinities(self):
engine = EngineEmul()
obj = Configuration()
obj.merge({
"foo": float("inf"),
})
cfg = engine.create_artifact("config", ".json")
obj.dump(cfg, Configuration.JSON)
with open(cfg) as fds:
dump = json.loads(fds.read())
self.assertEqual(dump["foo"], "inf")
self.assertEqual(dehumanize_time(dump["foo"]), float("inf"))
示例2: TestSwagger2YAML
# 需要导入模块: from tests.mocks import EngineEmul [as 别名]
# 或者: from tests.mocks.EngineEmul import create_artifact [as 别名]
class TestSwagger2YAML(BZTestCase):
def setUp(self):
super(TestSwagger2YAML, self).setUp()
self.engine = EngineEmul()
def _get_swagger2yaml(self, path, file_name=None):
return Swagger2YAML(FakeOptions(file_name=file_name), RESOURCES_DIR + path)
def _get_tmp(self, prefix='test', suffix='.yml'):
return self.engine.create_artifact(prefix, suffix)
def test_convert(self):
self.maxDiff = None
source = RESOURCES_DIR + "/swagger/petstore.json"
result = self._get_tmp()
options = FakeOptions(file_name=result)
process(options, [source])
actual = yaml.load(open(result).read())
expected = yaml.load(open(RESOURCES_DIR + "/swagger/petstore-converted.yaml").read())
self.assertEqual(actual, expected)
示例3: TestConverter
# 需要导入模块: from tests.mocks import EngineEmul [as 别名]
# 或者: from tests.mocks.EngineEmul import create_artifact [as 别名]
class TestConverter(BZTestCase):
def setUp(self):
super(TestConverter, self).setUp()
self.engine = EngineEmul()
def _get_soapui2yaml(self, path, file_name=None, test_case=None):
return SoapUI2YAML(FakeOptions(file_name=file_name, test_case=test_case), __dir__() + path)
def _get_tmp(self, prefix='test', suffix='.yml'):
return self.engine.create_artifact(prefix, suffix)
def test_convert(self):
source = RESOURCES_DIR + "soapui/project.xml"
result = self._get_tmp()
options = FakeOptions(file_name=result, test_case="index")
process(options, [source])
actual = yaml.load(open(result).read())
expected = yaml.load(open(RESOURCES_DIR + "soapui/project.xml.yml").read())
self.assertEqual(actual, expected)
def test_flickr(self):
source = RESOURCES_DIR + "soapui/flickr-sample.xml"
result = self._get_tmp()
options = FakeOptions(file_name=result)
process(options, [source])
actual = yaml.load(open(result).read())
expected = yaml.load(open(RESOURCES_DIR + "soapui/flickr-sample.xml.yml").read())
self.assertEqual(actual, expected)
def test_egalaxy(self):
source = RESOURCES_DIR + "soapui/egalaxy.xml"
result = self._get_tmp()
options = FakeOptions(file_name=result)
process(options, [source])
actual = yaml.load(open(result).read())
expected = yaml.load(open(RESOURCES_DIR + "soapui/egalaxy.xml.yml").read())
self.assertEqual(actual, expected)
示例4: temp_yaml
# 需要导入模块: from tests.mocks import EngineEmul [as 别名]
# 或者: from tests.mocks.EngineEmul import create_artifact [as 别名]
def temp_yaml(self):
emul = EngineEmul()
return emul.create_artifact("test", ".yml")
示例5: TestConverter
# 需要导入模块: from tests.mocks import EngineEmul [as 别名]
# 或者: from tests.mocks.EngineEmul import create_artifact [as 别名]
class TestConverter(BZTestCase):
def setUp(self):
self.engine = EngineEmul()
def _get_jmx2yaml(self, path, file_name=None, dump_jmx=False):
return JMX2YAML(FakeOptions(file_name=file_name, dump_jmx=dump_jmx), __dir__() + path)
def _get_tmp(self, prefix='test', suffix='.yml'):
return self.engine.create_artifact(prefix, suffix)
def test_loadjmx1(self):
log_recorder = RecordingHandler()
obj = self._get_jmx2yaml("/jmeter/jmx/http.jmx", self._get_tmp())
obj.log.addHandler(log_recorder)
obj.process()
self.assertIn("Loading jmx file", log_recorder.info_buff.getvalue())
self.assertNotEqual("", log_recorder.debug_buff.getvalue())
self.assertEqual("", log_recorder.err_buff.getvalue())
obj.log.removeHandler(log_recorder)
def test_loadjmx2(self):
log_recorder = RecordingHandler()
obj = self._get_jmx2yaml("/jmeter/jmx/notfound.jmx")
obj.log.addHandler(log_recorder)
try:
obj.process()
self.fail()
except BaseException as exc:
self.assertIn("File does not exist", exc.args[0])
self.assertIn("Loading jmx file", log_recorder.info_buff.getvalue())
self.assertIn("does not exist", log_recorder.err_buff.getvalue())
self.assertEqual("", log_recorder.debug_buff.getvalue())
obj.log.removeHandler(log_recorder)
def test_loadjmx3(self):
log_recorder = RecordingHandler()
obj = self._get_jmx2yaml("/jmeter/jmx/broken.jmx")
obj.log.addHandler(log_recorder)
try:
obj.process()
self.fail()
except BaseException as exc:
self.assertIn("XML parsing failed", exc.args[0])
self.assertIn("Loading jmx file", log_recorder.info_buff.getvalue())
self.assertIn("Error while processing jmx file", log_recorder.err_buff.getvalue())
self.assertIn("XML parsing error", log_recorder.debug_buff.getvalue())
obj.log.removeHandler(log_recorder)
def test_loadjmx4(self):
log_recorder = RecordingHandler()
obj = self._get_jmx2yaml("/jmeter/jmx/http.jmx", self._get_tmp('tmp', 'file'))
obj.log.addHandler(log_recorder)
obj.process()
self.assertIn("Loading jmx file", log_recorder.info_buff.getvalue())
self.assertIn("Done processing, result saved in", log_recorder.info_buff.getvalue())
self.assertIn("Removing unknown element", log_recorder.warn_buff.getvalue())
obj.log.removeHandler(log_recorder)
def test_export_clean_jmx(self):
tmp_jmx_name = self._get_tmp('tmp', '.jmx')
open(tmp_jmx_name, 'w+').close() # touch file
yml = self._get_tmp()
obj = self._get_jmx2yaml("/yaml/converter/disabled.jmx", yml, dump_jmx=tmp_jmx_name)
log_recorder = RecordingHandler()
obj.log.addHandler(log_recorder)
obj.process()
self.assertIn("Loading jmx file", log_recorder.info_buff.getvalue())
self.assertIn("already exists and will be overwritten", log_recorder.warn_buff.getvalue())
obj.log.removeHandler(log_recorder)
def test_not_jmx(self):
obj = self._get_jmx2yaml("/jmeter/jmx/not-jmx.xml")
try:
obj.process()
self.fail()
except BaseException as exc:
self.assertIn("Bad jmx format", exc.args[0])
def test_clean_disabled_jmx(self):
yml = self._get_tmp()
obj = self._get_jmx2yaml("/yaml/converter/disabled.jmx", yml)
obj.process()
disabled_elements = [element for element in obj.converter.dialect.tree.iter() if
element.get("enabled") == "false"]
self.assertEquals(0, len(disabled_elements))
def test_copy_global_csv_dataset(self):
yml = self._get_tmp()
obj = self._get_jmx2yaml("/yaml/converter/global_copy.jmx", yml)
obj.process()
yml = yaml.load(open(yml).read())
datasets_first_tg = yml.get("scenarios").get("Thread Group one").get("data-sources")
datasets_second_tg = yml.get("scenarios").get("Thread Group two").get("data-sources")
global_csv_tg_one = [dataset for dataset in datasets_first_tg if dataset.get('path') == 'global.csv']
global_csv_tg_two = [dataset for dataset in datasets_second_tg if dataset.get('path') == 'global.csv']
local_csv_tg_one = [dataset for dataset in datasets_first_tg if dataset.get('path') == 'local.csv']
#.........这里部分代码省略.........
示例6: TestConverter
# 需要导入模块: from tests.mocks import EngineEmul [as 别名]
# 或者: from tests.mocks.EngineEmul import create_artifact [as 别名]
class TestConverter(BZTestCase):
def setUp(self):
super(TestConverter, self).setUp()
self.engine = EngineEmul()
self.obj = JMX2YAML(file_name=None, options=FakeOptions())
def configure(self, src_file, dst_file=None, dump_jmx=None):
self.obj.src_file = src_file
self.obj.options = FakeOptions(file_name=dst_file, dump_jmx=dump_jmx)
def tearDown(self):
if self.obj.dst_file and os.path.isfile(self.obj.dst_file):
os.remove(self.obj.dst_file)
super(TestConverter, self).tearDown()
@staticmethod
def same_yaml(file1, file2):
yml1 = yaml.load(open(file1).read())
yml2 = yaml.load(open(file2).read())
return yml1 == yml2
def _get_tmp(self, prefix='test', suffix='.yml'):
return self.engine.create_artifact(prefix, suffix)
def test_objprop(self):
self.configure(RESOURCES_DIR + "jmeter/jmx/http.jmx", self._get_tmp())
self.sniff_log(self.obj.log)
self.obj.process()
self.assertNotIn("Removing unknown element: name (None)", self.log_recorder.warn_buff.getvalue())
self.assertNotIn("Removing unknown element: value (None)", self.log_recorder.warn_buff.getvalue())
def test_loadjmx1(self):
self.configure(RESOURCES_DIR + "jmeter/jmx/http.jmx", self._get_tmp())
self.sniff_log(self.obj.log)
self.obj.process()
self.assertIn("Loading jmx file", self.log_recorder.info_buff.getvalue())
self.assertNotEqual("", self.log_recorder.debug_buff.getvalue())
self.assertEqual("", self.log_recorder.err_buff.getvalue())
def test_loadjmx2(self):
self.configure(RESOURCES_DIR + "jmeter/jmx/notfound.jmx")
self.sniff_log(self.obj.log)
try:
self.obj.process()
self.fail()
except BaseException as exc:
self.assertIn("File does not exist", exc.args[0])
self.assertIn("Loading jmx file", self.log_recorder.info_buff.getvalue())
self.assertEqual("", self.log_recorder.debug_buff.getvalue())
def test_loadjmx3(self):
self.configure(RESOURCES_DIR + "jmeter/jmx/broken.jmx")
self.sniff_log(self.obj.log)
try:
self.obj.process()
self.fail()
except BaseException as exc:
self.assertIn("XML parsing failed", exc.args[0])
self.assertIn("Loading jmx file", self.log_recorder.info_buff.getvalue())
self.assertIn("Error while processing jmx file", self.log_recorder.err_buff.getvalue())
def test_loadjmx4(self):
self.configure(RESOURCES_DIR + "jmeter/jmx/http.jmx", self._get_tmp('tmp', 'file'))
self.sniff_log(self.obj.log)
self.obj.process()
self.assertIn("Loading jmx file", self.log_recorder.info_buff.getvalue())
self.assertIn("Done processing, result saved in", self.log_recorder.info_buff.getvalue())
self.assertIn("Removing unknown element", self.log_recorder.warn_buff.getvalue())
def test_export_clean_jmx(self):
tmp_jmx_name = self._get_tmp('tmp', '.jmx')
open(tmp_jmx_name, 'w+').close() # touch file
self.configure(RESOURCES_DIR + "yaml/converter/disabled.jmx", dump_jmx=tmp_jmx_name)
self.sniff_log(self.obj.log)
self.obj.process()
self.assertIn("Loading jmx file", self.log_recorder.info_buff.getvalue())
self.assertIn("already exists and will be overwritten", self.log_recorder.warn_buff.getvalue())
def test_not_jmx(self):
self.configure(RESOURCES_DIR + "jmeter/jmx/not-jmx.xml")
try:
self.obj.process()
self.fail()
except BaseException as exc:
self.assertIn("Bad jmx format", exc.args[0])
def test_clean_disabled_jmx(self):
self.configure(RESOURCES_DIR + "yaml/converter/disabled.jmx", self._get_tmp())
self.obj.process()
disabled_elements = [element for element in self.obj.converter.dialect.tree.iter() if
element.get("enabled") == "false"]
self.assertEquals(0, len(disabled_elements))
def test_copy_global_csv_dataset(self):
self.configure(RESOURCES_DIR + "yaml/converter/global_copy.jmx")
self.obj.process()
yml = yaml.load(open(self.obj.dst_file).read())
datasets_first_tg = yml.get("scenarios").get("Thread Group one").get("data-sources")
datasets_second_tg = yml.get("scenarios").get("Thread Group two").get("data-sources")
#.........这里部分代码省略.........