Esempio n. 1
0
File: utils.py Progetto: uvyifan/fms
 def testOutputfileDefaultValue(self):
     """
     Outputfile should be sys.stdout if missing
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['outputfilename'], 'sys.stdout')
Esempio n. 2
0
File: utils.py Progetto: uvyifan/fms
 def testRandomseedDefaultValue(self):
     """
     Randomseed should be None if missing
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['randomseed'], None)
Esempio n. 3
0
File: utils.py Progetto: uvyifan/fms
 def testRandomSeedValue(self):
     """
     Randomseed is read correctly
     """
     ymlparamsfile = '%s/fullconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['randomseed'], 12345678)
Esempio n. 4
0
File: utils.py Progetto: uvyifan/fms
 def testUniqueByAgentDefaultValue(self):
     """
     unique_by_agent value is True if missing
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertTrue(params['unique_by_agent'])
Esempio n. 5
0
File: utils.py Progetto: uvyifan/fms
 def testCsvDelimiterDefaultValue(self):
     """
     csvdelimiter value is ';' if missing
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['csvdelimiter'], ';')
Esempio n. 6
0
File: utils.py Progetto: uvyifan/fms
 def testOrdersLogFileDefaultValue(self):
     """
     OrdersLogFile shoud be None if missing
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['orderslogfilename'], None)
Esempio n. 7
0
File: utils.py Progetto: uvyifan/fms
 def testExperimentNameValue(self):
     """
     Experiment name is correctly read
     """
     ymlparamsfile = '%s/fullconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['name'], 'Test Experiment')
Esempio n. 8
0
File: utils.py Progetto: uvyifan/fms
 def testDaylengthValue(self):
     """
     Daylength is correctly read as an int
     """
     ymlparamsfile = '%s/fullconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['engines'][0]['daylength'], 10)
Esempio n. 9
0
File: utils.py Progetto: uvyifan/fms
 def testClearBooksAtEODValue(self):
     """
     Engine's clearbooksateod param is correctly read
     """
     ymlparamsfile = '%s/fullconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertFalse(params['engines'][0]['clearbooksateod'])
Esempio n. 10
0
File: utils.py Progetto: uvyifan/fms
 def testDaylengthDefaultValue(self):
     """
     Daylength should be 1 if missing
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['engines'][0]['daylength'], 1)
Esempio n. 11
0
File: utils.py Progetto: uvyifan/fms
 def testClearBooksAtEODDefaultValue(self):
     """
     Clear books at end of day if this param is missing
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertTrue(params['engines'][0]['clearbooksateod'])
Esempio n. 12
0
File: utils.py Progetto: uvyifan/fms
 def testWorldClassValue(self):
     """
     World class is read correctly
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['world']['classname'], 'NullWorld')
Esempio n. 13
0
File: utils.py Progetto: uvyifan/fms
 def testMarketClassValue(self):
     """
     Market param classname is read correctly
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['engines'][0]['market']['classname'],
                      'ContinuousOrderDriven')
Esempio n. 14
0
File: utils.py Progetto: uvyifan/fms
 def testEngineClassValue(self):
     """
     Engine classname is read correctly
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['engines'][0]['classname'],
                      'AsynchronousRandWReplace')
Esempio n. 15
0
File: utils.py Progetto: uvyifan/fms
 def testOuputfileValue(self):
     """
     Outputfile might be read from config
     """
     ymlparamsfile = '%s/fullconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['outputfilename'],
                      '%s/dummyoutput.csv' % self.fixturesdir)
Esempio n. 16
0
File: utils.py Progetto: uvyifan/fms
 def testExperimentNameDefaultValue(self):
     """
     Experiment name is built from filename if missing
     """
     ymlparamsfile = '%s/minimalconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['name'],
                      '%s/minimalconfig.yml experiment' % self.fixturesdir)
Esempio n. 17
0
File: utils.py Progetto: uvyifan/fms
 def testOrderLogFileValue(self):
     """
     OrdersLogFile might be read from config
     """
     ymlparamsfile = '%s/fullconfig.yml' % self.fixturesdir
     params = YamlParamsParser(ymlparamsfile)
     self.assertEqual(params['orderslogfilename'],
                      '%s/dummyoutput.log' % self.fixturesdir)
Esempio n. 18
0
def _get_params(args, opts):
    """
    Get params from conffile
    """
    logger = logging.getLogger('fms')
    simconffile = _get_simconffile(args)
    if os.path.splitext(simconffile)[-1] == '.xml':
        logger.debug("Calling XmlParamsParser on %s" % simconffile)
        params = XmlParamsParser(simconffile)
    else:
        logger.debug("Calling YamlParamsParser on %s" % simconffile)
        params = YamlParamsParser(simconffile)
    params['simconffile'] = simconffile
    params = _apply_opts(params, opts)
    params.printparams()
    return params
Esempio n. 19
0
                    else:
                        suite.addTest(doctest.DocFileSuite(
                            os.path.join(os.path.split(root)[1], f),
                            package='fms.contrib.%s' % t,
                            optionflags=+doctest.ELLIPSIS))
                else:
                    suite.addTest(doctest.DocFileSuite(
                        os.path.join(os.path.split(root)[1], f),
                        package='fms',
                        optionflags=+doctest.ELLIPSIS))

unittest.TextTestRunner(verbosity=2).run(suite)

for simconffile in expList():
    logger.info("Running %s" % simconffile)
    params = YamlParamsParser(simconffile)
    params['show_books'] = False
    params['timer'] = False
    params.outputfile = StringIO()
    (world, engineslist, agentslist) = fms.core.set_classes(params)
    for e in engineslist:
        e['instance'].run(world, agentslist, e['market']['instance'])
    benchfile = "%s.csv" % simconffile.split('.')[0]
    benchmark = open(benchfile).read()
    testresult = params.outputfile.getvalue()
    if not benchmark == testresult:
        logger.error("%s failed" % simconffile)
        print testresult
    else:
        logger.info("%s ok" % simconffile)
    params.close_files(1)