Skip to content

Commit

Permalink
[manuscripts2] Add tests for OVERVIEW section of the report
Browse files Browse the repository at this point in the history
- Add tests for 'git' and 'github_issues' data sources
- Add relevant data git 'git', 'github_issues' and 'github_prs'
- update .travis.yml file
- add utility functions for tests
  • Loading branch information
aswanipranjal committed Jul 23, 2018
1 parent 5be2cf6 commit f8cde2e
Show file tree
Hide file tree
Showing 12 changed files with 538,247 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ sudo: false

services:
- elasticsearch
- mysql

# sleep to wait for Elasticsearch init
before_install:
- sleep 10
- pip install -r "requirements.txt"
- pip install flake8
- pip install coveralls
- pip install PyMySql

# install:
# - ./setup.py install

script:
- flake8 .
- mysqladmin -u root create test_sh
- cd tests
- coverage run --include=*manuscripts/manuscripts* run_tests.py

Expand Down
11 changes: 8 additions & 3 deletions manuscripts2/metrics/github_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ def __init__(self, index, start, end):
self.name = "Closed tickets"
self.desc = "Number of closed tickets"
self.query.is_closed()
self.query.get_cardinality("id").by_period()
self.query.get_cardinality("id")\
.since(start=self.start, field="closed_at")\
.until(end=self.end, field="closed_at")\
.by_period()


class BMI(IssuesMetrics):
Expand All @@ -85,11 +88,13 @@ def __init__(self, index, start, end):
self.opened = Issues(index)
self.opened.get_cardinality("id").since(self.start).until(self.end)
self.closed = Issues(index).is_closed()
self.closed.get_cardinality("id").since(self.start).until(self.end)
self.closed.get_cardinality("id")\
.since(self.start, field="closed_at")\
.until(self.end, field="closed_at")

def aggregations(self):
end_prev_month = get_prev_month(self.end, Query.interval_)
closed_agg = self.closed.since(end_prev_month).get_aggs()
closed_agg = self.closed.since(end_prev_month, field="closed_at").get_aggs()
opened_agg = self.opened.since(end_prev_month).get_aggs()

if opened_agg == 0:
Expand Down
2 changes: 1 addition & 1 deletion manuscripts2/metrics/github_prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, index, start, end):

def aggregations(self):
end_prev_month = get_prev_month(self.end, Query.interval_)
closed_agg = self.closed.since(end_prev_month).get_aggs()
closed_agg = self.closed.since(end_prev_month, field="updated_at").get_aggs()
opened_agg = self.opened.since(end_prev_month).get_aggs()

if opened_agg == 0:
Expand Down
Empty file added tests/__init__.py
Empty file.
Loading

0 comments on commit f8cde2e

Please sign in to comment.