def test_validate_config(self): MongoDataSource({ 'name': 'test', 'addr': "localhost:27017", 'database': "mydb", 'username': '******', 'password': '******', })
def setUp(self): db = os.environ.get('MONGODB_DB') if not db: db = "test-{}".format(int(datetime.datetime.now().timestamp())) settings = { 'name': 'test', 'addr': os.environ.get('MONGODB_ADDR', "localhost:27017"), 'database': db, } username = os.environ.get('MONGODB_USER') if username: settings['username'] = username settings['password'] = os.environ.get('MONGODB_PWD') auth_source = os.environ.get('MONGODB_AUTH_SRC') if auth_source: settings['auth_source'] = auth_source self.source = MongoDataSource(settings) self.model = Model( dict( name="test-model", offset=30, span=300, bucket_interval=3600, interval=60, features=[ { 'name': 'avg_foo', 'metric': 'avg', 'collection': 'coll', 'field': 'foo', }, { 'name': 'count_bar', 'metric': 'count', 'collection': 'coll', 'field': 'bar', 'default': 0, }, ], )) self.t0 = datetime.datetime.now(datetime.timezone.utc).replace( hour=0, minute=0, second=0, microsecond=0, ).timestamp()