Ejemplo n.º 1
0
    def test_merge(self):
        obj = Configuration()
        configs = [
            __dir__() + "/resources/yaml/test.yml",
            __dir__() + "/resources/json/merge1.json",
            __dir__() + "/resources/json/merge2.json",
        ]
        obj.load(configs)
        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.JSON)
        with open(fname) as fh:
            logging.debug("JSON:\n%s", fh.read())
        jmeter = obj['modules']['jmeter']
        classval = jmeter['class']
        self.assertEquals("bzt.modules.jmeter.JMeterExecutor", classval)
        self.assertEquals("value", obj['key'])
        self.assertEquals(6, len(obj["list-append"]))
        self.assertEquals(2, len(obj["list-replace"]))
        self.assertEquals(2, len(obj["list-replace-notexistent"]))
        self.assertIsInstance(obj["list-complex"][1][0], BetterDict)
        self.assertIsInstance(obj["list-complex"][1][0], BetterDict)
        self.assertIsInstance(obj["list-complex"][1][0], BetterDict)
        self.assertFalse("properties" in jmeter)

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.JSON)
        checker = Configuration()
        checker.load([fname])
        token = checker["list-complex"][1][0]['token']
        self.assertNotEquals('test', token)
        token_orig = obj["list-complex"][1][0]['token']
        self.assertEquals('test', token_orig)
Ejemplo n.º 2
0
 def test_tabs(self):
     obj = Configuration()
     obj.tab_replacement_spaces = 4
     obj.load([RESOURCES_DIR + "yaml/tabs-issue.yml"])
     fname = tempfile.mkstemp()[1]
     obj.dump(fname, Configuration.YAML)
     self.assertFilesEqual(RESOURCES_DIR + "yaml/tabs-issue-spaces.yml", fname)
Ejemplo n.º 3
0
    def test_merge(self):
        obj = Configuration()
        configs = [
            RESOURCES_DIR + "yaml/test.yml",
            RESOURCES_DIR + "json/merge1.json",
            RESOURCES_DIR + "json/merge2.json",
        ]
        obj.load(configs)
        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.JSON)
        with open(fname) as fh:
            ROOT_LOGGER.debug("JSON:\n%s", fh.read())
        jmeter = obj['modules']['jmeter']
        classval = jmeter['class']
        self.assertEquals("bzt.modules.jmeter.JMeterExecutor", classval)
        self.assertEquals("value", obj['key'])
        self.assertEquals(6, len(obj["list-append"]))
        self.assertEquals(2, len(obj["list-replace"]))
        self.assertEquals(2, len(obj["list-replace-notexistent"]))
        self.assertIsInstance(obj["list-complex"][1][0], BetterDict)
        self.assertIsInstance(obj["list-complex"][1][0], BetterDict)
        self.assertIsInstance(obj["list-complex"][1][0], BetterDict)
        self.assertFalse("properties" in jmeter)

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.JSON)
        checker = Configuration()
        checker.load([fname])
        token = checker["list-complex"][1][0]['token']
        self.assertNotEquals('test', token)
        token_orig = obj["list-complex"][1][0]['token']
        self.assertEquals('test', token_orig)
Ejemplo n.º 4
0
 def test_tabs(self):
     obj = Configuration()
     obj.tab_replacement_spaces = 4
     obj.load([RESOURCES_DIR + "yaml/tabs-issue.yml"])
     fname = temp_file()
     obj.dump(fname, Configuration.YAML)
     self.assertFilesEqual(RESOURCES_DIR + "yaml/tabs-issue-spaces.yml", fname)
Ejemplo n.º 5
0
 def test_tabs(self):
     obj = Configuration()
     obj.tab_replacement_spaces = 4
     obj.load([RESOURCES_DIR + "yaml/tabs-issue.yml"])
     fname = tempfile.mkstemp()[1]
     obj.dump(fname, Configuration.YAML)
     # import shutil; shutil.copy(fname, RESOURCES_DIR + "yaml/tabs-issue-spaces.yml")
     self.assertFilesEqual(RESOURCES_DIR + "yaml/tabs-issue-spaces.yml", fname)
Ejemplo n.º 6
0
 def test_tabs(self):
     obj = Configuration()
     obj.tab_replacement_spaces = 4
     obj.load([__dir__() + "/resources/yaml/tabs-issue.yml"])
     fname = tempfile.mkstemp()[1]
     obj.dump(fname, Configuration.YAML)
     # import shutil; shutil.copy(fname, __dir__() + "/resources/yaml/tabs-issue-spaces.yml")
     self.assertFilesEqual(
         __dir__() + "/resources/yaml/tabs-issue-spaces.yml", fname)
Ejemplo n.º 7
0
    def test_load(self):
        obj = Configuration()
        configs = [
            BASE_CONFIG, RESOURCES_DIR + "json/jmx.json",
            RESOURCES_DIR + "json/concurrency.json"
        ]
        obj.load(configs)
        logging.debug("config:\n%s", obj)

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.JSON)
        with open(fname) as fh:
            logging.debug("JSON:\n%s", fh.read())

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.YAML)
        with open(fname) as fh:
            logging.debug("YAML:\n%s", fh.read())
Ejemplo n.º 8
0
    def test_load(self):
        obj = Configuration()
        configs = [
            __dir__() + "/../bzt/resources/base-config.yml",
            __dir__() + "/resources/json/jmx.json",
            __dir__() + "/resources/json/concurrency.json"
        ]
        obj.load(configs)
        logging.debug("config:\n%s", obj)

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.JSON)
        with open(fname) as fh:
            logging.debug("JSON:\n%s", fh.read())

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.YAML)
        with open(fname) as fh:
            logging.debug("YAML:\n%s", fh.read())
Ejemplo n.º 9
0
    def test_load(self):
        obj = Configuration()
        configs = [
            BASE_CONFIG,
            RESOURCES_DIR + "json/jmx.json",
            RESOURCES_DIR + "json/concurrency.json"
        ]
        obj.load(configs)
        ROOT_LOGGER.debug("config:\n%s", obj)

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.JSON)
        with open(fname) as fh:
            ROOT_LOGGER.debug("JSON:\n%s", fh.read())

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.YAML)
        with open(fname) as fh:
            ROOT_LOGGER.debug("YAML:\n%s", fh.read())
Ejemplo n.º 10
0
    def test_load(self):
        obj = Configuration()
        configs = [
            __dir__() + "/../bzt/10-base.json",
            __dir__() + "/json/jmx.json",
            __dir__() + "/json/concurrency.json"
        ]
        obj.load(configs)
        logging.debug("config:\n%s", obj)

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.JSON)
        with open(fname) as fh:
            logging.debug("JSON:\n%s", fh.read())

        fname = tempfile.mkstemp()[1]
        obj.dump(fname, Configuration.YAML)
        with open(fname) as fh:
            logging.debug("YAML:\n%s", fh.read())
def get_token():
    a = Configuration()
    a.load([os.path.expanduser("~/.bzt-rc")])
    return a['modules']['blazemeter']['token']
Ejemplo n.º 12
0
def get_token():
    a = Configuration()
    a.load([os.path.expanduser("~/.bzt-rc")])
    return a['modules']['blazemeter']['token']