Exemplo n.º 1
0
def list_values():
    pg = sa.create_engine("postgresql+psycopg2://%s:%s@%s:%s/%s" %
                          (conf["postgres"]["user"], conf["postgres"]["pwd"],
                           conf["postgres"]["host"], conf["postgres"]["port"],
                           conf["postgres"]["db"]))

    return as_dict(
        pg.execute("SELECT id, value FROM {table}".format(
            table=conf["postgres"]["table"])))
Exemplo n.º 2
0
def test_as_dict():
    assert as_dict([{
        "id": 1,
        "value": "test1"
    }, {
        "id": 2,
        "value": "test2"
    }]) == {
        1: "test1",
        2: "test2"
    }
Exemplo n.º 3
0
 def test_config_file(self):
     try:
         config = ConfigParser.ConfigParser()
         config.readfp(open('/etc/default/event_server'))
         data = utils.as_dict(config)
         config_file = True
         if 'Database' not in data.keys():
             self.fail("Config file error: No database section")
         elif 'Log' not in data.keys():
             self.fail("No logs section")
         elif 'Default' not in data.keys():
             self.fail("No default section")
         elif 'Errors' not in data.keys():
             self.fail("No errors section")
         else:
             self.assertTrue(True)
     except Exception as e:
         self.assertFalse(True, "Error Raised:" + str(e))
Exemplo n.º 4
0
	def test_config_file(self):
		try:
			config=ConfigParser.ConfigParser()
			config.readfp(open('/etc/default/event_server'))
			data=utils.as_dict(config)
			config_file=True
			if 'Database' not in data.keys():
				self.fail("Config file error: No database section")
			elif 'Log' not in data.keys():
				self.fail("No logs section")
			elif 'Default' not in data.keys():
				self.fail("No default section")
			elif 'Errors' not in data.keys():
				self.fail("No errors section")	
			else:
				self.assertTrue(True)
		except Exception as e:
			self.assertFalse(True,"Error Raised:"+str(e))
Exemplo n.º 5
0
 def setUp(self):
     self.config = ConfigParser.ConfigParser()
     self.config.readfp(open('/etc/default/event_server'))
     self.config = utils.as_dict(self.config)
Exemplo n.º 6
0
 def post(self):
     r = json.loads(self.request.body)
     guest = model.insert_guest(r['first'], r['last'])
     r = utils.as_dict(guest)
     self.send_json(r)
Exemplo n.º 7
0
	def setUp(self):
		self.config=ConfigParser.ConfigParser()
		self.config.readfp(open('/etc/default/event_server'))
		self.config=utils.as_dict(self.config)