def testLoad(self):
        '''Test that an example configuration is loaded correctly'''
        global_conf = NamedTemporaryFile(delete=False)
        global_conf.write("""
# Foo commentary! A:B
---
# Fake Database access information
dbhost: remotehost
dbuser: '******'
dbpwd: thepassword
dbname: 'thedb'
# intermediate comment
nodejsPort: 4242
nodejsHostname: foohost
        """)
        global_conf.close()
        project_conf = NamedTemporaryFile(delete=False)
        project_conf.write("""
# Fake commentary!

---
project: theproject
repo: therepo # Relative to git-dir as specified on the command line
description: the description
ml: the mailing list
revisions: [ "v1", "v2", "v3",
            "v4",
            "v5"]
rcs : ["v1rc0", "v2rc0", "v3rc0", "v4rc0",
"v5rc0"
]
new_tag: newvalue
tagging: tag
""")
        project_conf.close()
        c = Configuration.load(global_conf.name, project_conf.name)
        self.assertEqual(c["dbhost"], "remotehost")
        self.assertEqual(c["dbuser"], "theuser")
        self.assertEqual(c["dbpwd"], "thepassword")
        self.assertEqual(c["dbname"], "thedb")
        self.assertEqual(c["project"], "theproject")
        self.assertEqual(c["nodejsPort"], 4242)
        self.assertEqual(c["nodejsHostname"], "foohost")
        self.assertEqual(c["repo"], "therepo")
        self.assertEqual(c["description"], "the description")
        self.assertEqual(c["ml"], "the mailing list")
        self.assertEqual(c["revisions"], ["v1", "v2", "v3", "v4", "v5"])
        self.assertEqual(c["rcs"],  ["v1rc0", "v2rc0", "v3rc0", "v4rc0", "v5rc0"])
        self.assertEqual(c["tagging"], "tag")
        self.assertEqual(c["new_tag"], "newvalue")
        os.unlink(global_conf.name)
        os.unlink(project_conf.name)
        # Check that the configuration is valid YAML
        yaml_conf = NamedTemporaryFile(delete=False)
        yaml_conf.write(str(c))
        yaml_conf.close()
        c2 = Configuration.load(yaml_conf.name)
        self.assertEqual(dict(c), dict(c2))
        os.unlink(yaml_conf.name)
 def testDict(self):
     '''Quick test if a Configuration object behaves like a dict'''
     c = Configuration()
     expected_keys = set(("nodejsPort", "nodejsHostname"))
     self.assertEqual(set(c.keys()), expected_keys)
     print(str(c))
     for k in c:
         self.assertIn(k, expected_keys)
         c[k]
 def getResults(self):
     conf = Configuration.load(self.prosoda_conf, self.project_conf)
     dbm = DBManager(conf)
     project_id = dbm.getProjectID(conf["project"], self.tagging)
     self.assertGreaterEqual(project_id, 0)
     results = {}
     for table in pid_tables + other_tables + ignore_tables:
         dbm.doExec("SELECT * FROM {table}".format(table=table))
         results[table] = dbm.doFetchAll()
     return results
 def checkClean(self):
     conf = Configuration.load(self.prosoda_conf, self.project_conf)
     dbm = DBManager(conf)
     project_id = dbm.getProjectID(conf["project"], self.tagging)
     dbm.doExecCommit("DELETE FROM project WHERE id={}".format(project_id))
     for table in pid_tables:
         res = dbm.doExec("SELECT * FROM {table} WHERE projectId={pid}".
                          format(table=table, pid=project_id))
         self.assertEqual(res, 0, msg="Table '{}' still dirty!".
                              format(table))
     for table in other_tables:
         res = dbm.doExec("SELECT * FROM {table}".format(table=table))
         self.assertEqual(res, 0,  msg="Table '{}' still dirty!".format(table))
 def setup_with_p(self, p):
     path = self.p.directory
     self.gitdir = dirname(path)
     self.resdir = pathjoin(path, ".git", "results")
     self.mldir = pathjoin(path, ".git")
     self.project_conf = self.p.prosoda_conf
     self.no_report = False
     self.loglevel = "devinfo"
     self.logfile = pathjoin(path, ".git", "log")
     self.recreate = False
     # This config_file is added in the prosoda test command handler
     self.prosoda_conf = self.config_file
     conf = Configuration.load(self.prosoda_conf, self.project_conf)
     dbm = DBManager(conf)
     for table in pid_tables + other_tables:
         dbm.doExecCommit("DELETE FROM {}".format(table))