示例#1
0
 def test_get_config(self):
     config = urlparse("mongodb://*****:*****@host:1234/sips")
     self.assertDictEqual(config, {
         'backend': 'mongodb',
         'username': '******',
         'password': '******',
         'hostname': 'host',
         'port': 1234,
         'db': 'sips'
     })
示例#2
0
 def __init__(self, uri=None):
     if uri is None:
         uri = "mongodb://localhost:27017/sips"
     super(MongoDBBackend, self).__init__(uri)
     self.uri = uri
     self.config = urlparse(self.uri)
     self.connection = pymongo.MongoClient(self.uri)
     self.db = self.connection[self.config['db']]
     self.ps_collection = 'giscedata_sips_ps'
     self.measures_collection = 'giscedata_sips_consums'
     self.db[self.ps_collection].ensure_index(
         "name", unique=True, background=True
     )
     self.db[self.measures_collection].ensure_index(
        "name", background=True,
     )