Ejemplo n.º 1
0
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))
Ejemplo n.º 3
0
 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))
Ejemplo n.º 4
0
 def test_average(self):
     resp = keen.average("query test", target_property="number", timeframe="today")
     assert type(resp) in (float, int)
Ejemplo n.º 5
0
 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))
Ejemplo n.º 6
0
 def test_average(self):
     resp = keen.average("query test",
                         target_property="number",
                         timeframe="today")
     assert type(resp) in (float, int)