def get_avg_buildtime(repo=None, interval=None): """ Query Keen.io database and retrieve average build time. Parameters : - repo : repo name (fe. buildtimetrend/service) - interval : timeframe, possible values : 'week', 'month', 'year', anything else defaults to 'week' """ if repo is None or not is_readable(): return -1 interval_data = check_time_interval(interval) try: return keen.average( "build_jobs", target_property="job.duration", timeframe=interval_data['timeframe'], max_age=interval_data['max_age'], filters=[get_repo_filter(repo)] ) except requests.ConnectionError: logger.error("Connection to Keen.io API failed") return -1 except keen.exceptions.KeenApiError as msg: logger.error("Error in keenio.get_avg_buildtime() : " + str(msg)) return -1
def test_average(self): resp = keen.average("query test", target_property="number", timeframe="today") self.assertTrue(type(resp) in (int, float), type(resp))
def test_average(self, get): get.return_value = self.INT_RESPONSE resp = keen.average("query test", target_property="number", timeframe="today") self.assertTrue(type(resp) in (int, float), type(resp))
def test_average(self): resp = keen.average("query test", target_property="number", timeframe="today") assert type(resp) in (float, int)