Skip to content

Commit b4d3cb3

Browse files
committed
test after refactor
1 parent d16846c commit b4d3cb3

File tree

5 files changed

+50
-15
lines changed

5 files changed

+50
-15
lines changed

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ SERVER_PORT ?= 8008
3333
# Other settings
3434
DJANGO_SERVER ?= runserver
3535
DJANGO_SHELL ?= shell_plus
36-
REPORT_FAILED_TEST ?= report_failed_tests
37-
REPORT_FAILED_TEST_BRANCHES ?= develop,master
36+
REPORT_FAILED_TEST_BRANCHES ?= develop,master,test1
3837

3938
# JIRA Settings
4039
JIRA_ISSUE_TYPE ?= Bug
4140
JIRA_PROJECT_KEY ?= EZHOME
4241
JIRA_SERVER ?= https://ezhome-test.atlassian.net
4342
JIRA_USERNAME ?= jira_bot
4443
JIRA_PASSWORD ?= P@ssw0rd
44+
JIRA_DEFAULT_ASSIGNEE ?= [email protected]
4545

4646
# Setup bootstrapper & Gunicorn args
4747
has_bootstrapper = $(shell python -m bootstrapper --version 2>&1 | grep -v "No module")
@@ -126,5 +126,5 @@ server: clean pep8
126126
LEVEL=$(LEVEL) PYTHONPATH=$(PROJECT) $(GUNICORN) -b $(SERVER_HOST):$(SERVER_PORT) -w $(GUNICORN_WORKERS) -n $(GUNICORN_NAME) -t 60 --graceful-timeout 60 $(gunicorn_args) $(GUNICORN_ARGS) $(PROJECT).wsgi:application
127127

128128
# Reporting of failed cases:
129-
report_failed_tests:
130-
COMMAND="$(REPORT_FAILED_TEST) --branches $(REPORT_FAILED_TEST_BRANCHES) --issue-type $(JIRA_ISSUE_TYPE) --project-key $(JIRA_PROJECT_KEY) --jira-server $(JIRA_SERVER) --jira-username $(JIRA_USERNAME) --jira-password $(JIRA_PASSWORD) $(COMMAND_ARGS)" $(MAKE) manage
129+
jira_check_tests:
130+
ezh-jira-test-checker run_check --branches $(REPORT_FAILED_TEST_BRANCHES) --issue-type $(JIRA_ISSUE_TYPE) --project-key $(JIRA_PROJECT_KEY) --jira-server $(JIRA_SERVER) --jira-username $(JIRA_USERNAME) --jira-password $(JIRA_PASSWORD) --jira-default-assignee $(JIRA_DEFAULT_ASSIGNEE) $(COMMAND_ARGS)

circle.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ machine:
55
DATABASE_URL: postgres://ubuntu:@127.0.0.1:5432/circle_test
66
DJANGO_SETTINGS_MODULE: django_and_angular.settings.development
77
LEVEL: development
8+
9+
# JIRA integration
10+
REPORT_FAILED_TEST_BRANCHES: develop,master,test1
11+
JIRA_ISSUE_TYPE: Bug
12+
JIRA_PROJECT_KEY: EZHOME
13+
JIRA_SERVER: ezhome-test.atlassian.net
14+
JIRA_USERNAME: jira_bot
15+
JIRA_PASSWORD: jira_bot
16+
JIRA_DEFAULT_ASSIGNEE: [email protected]
817
timezone:
918
America/Los_Angeles
1019
node:
@@ -31,7 +40,7 @@ test:
3140
# - coveralls
3241
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
3342
- "[ -r nosetests.xml ] && mv nosetests.xml $CIRCLE_TEST_REPORTS/junit/ || :"
34-
- COMMAND_ARGS='--target-branch ${CIRCLE_BRANCH} --test-results ${CIRCLE_TEST_REPORTS}/junit/nosetests.xml' make report_failed_tests
43+
- "COMMAND_ARGS='--target-branch ${CIRCLE_BRANCH} --test-results ${CIRCLE_TEST_REPORTS}/junit/nosetests.xml --branches $(REPORT_FAILED_TEST_BRANCHES) --issue-type $(JIRA_ISSUE_TYPE) --project-key $(JIRA_PROJECT_KEY) --jira-server $(JIRA_SERVER) --jira-username $(JIRA_USERNAME) --jira-password $(JIRA_PASSWORD) --jira-default-assignee $(JIRA_DEFAULT_ASSIGNEE)' make jira_check_tests || :"
3544

3645
# # Override /etc/hosts
3746
# hosts:

requirements-dev.txt

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
--extra-index-url=http://ezhome-bot:[email protected]/simple/
2+
13
coverage==4.0
24
coveralls==1.0
35
django-nose==1.4.2
6+
# ezhinfra==0.2.? <TBD>
7+
# temporary solution for being able to check the PR
8+
-e [email protected]:ezhome/ezh-infrastructure-tools.git@d910af7fdbe2c04e1c258e718e5026992c1ac29d#egg=ezhinfra
49
flake8==2.3.0
510
flake8-import-order==0.5.3
611
flake8-pep257==1.0.3
7-
https://github.com/zheller/flake8-quotes/tarball/aef86c4f8388e790332757e5921047ad53160a75#egg=flake8-quotes
8-
GitPython==1.0.2 # For Jira integration
9-
jira==1.0.3 # For Jira integreation
12+
flake8-quotes==0.2.4
1013
nose==1.3.7
1114
pep257==0.6.0
1215
pep8==1.6.2

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ drf-nested-routers==0.9.0
88
gunicorn==19.1.1
99
psycopg2==2.6.1
1010
raven==5.10.2
11-
six==1.8.0
11+
six==1.9.0
1212
static3==0.5.1
1313
wsgiref==0.1.2

src/django_and_angular/management/commands/report_failed_tests.py

+29-6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ class Command(BaseCommand):
6767
default='nosetests.xml',
6868
help='Location of test results',
6969
),
70+
make_option(
71+
'--jira-default-assignee',
72+
action='store',
73+
dest='jira_default_assignee',
74+
default='',
75+
help='Default assignee for new user',
76+
)
7077
)
7178

7279
def handle(self, *args, **options):
@@ -75,6 +82,7 @@ def handle(self, *args, **options):
7582
self.jira_server = options['jira_server']
7683
self.jira_username = options['jira_username']
7784
self.jira_password = options['jira_password']
85+
self.jira_default_assignee = options['jira_default_assignee']
7886
test_results = options['test_results']
7987

8088
self.repo = Repo()
@@ -103,8 +111,13 @@ def handle(self, *args, **options):
103111
results = []
104112
for testcase in root:
105113
if testcase:
106-
results.append(self.handle_testcase(testcase))
107-
return '\n'.join(results)
114+
result = self.handle_testcase(testcase)
115+
if result is not None:
116+
results.append(result)
117+
if results:
118+
return '\n'.join(results)
119+
else:
120+
return 'No errors in tests'
108121
else:
109122
return 'No errors in tests'
110123
except IOError:
@@ -184,19 +197,29 @@ def handle_jira(self, path, authors, classname, testcase):
184197
)
185198
else:
186199
# Create issue
187-
assignee = jira.search_users(
200+
assignees = []
201+
assignees.extend(jira.search_users(
188202
user=authors['function'].email,
189203
maxResults=1
190-
)
204+
))
205+
assignees.extend(jira.search_users(
206+
user=authors['failure'].email,
207+
maxResults=1
208+
))
209+
if self.jira_default_assignee:
210+
assignees.extend(jira.search_users(
211+
user=self.jira_default_assignee,
212+
maxResults=1
213+
))
191214
issue_dict = dict(
192215
project={'key': self.project_key},
193216
summary=summary,
194217
issuetype={'name': self.issue_type},
195218
priority={'id': jira.priorities()[-1].id},
196219
description='Description here',
197220
)
198-
if assignee:
199-
issue_dict['assignee'] = {'name': assignee[0].name}
221+
if assignees:
222+
issue_dict['assignee'] = {'name': assignees[0].name}
200223
new_issue = jira.create_issue(fields=issue_dict)
201224
return 'New issue "{0}" has been created'.format(new_issue)
202225
except JIRAError as e:

0 commit comments

Comments
 (0)