Skip to content

Commit 691d8b5

Browse files
committed
Add tests for two platform
1 parent 2f5b076 commit 691d8b5

File tree

1 file changed

+66
-2
lines changed

1 file changed

+66
-2
lines changed

tests/functionality_two_platforms.py

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def _setup(self,
106106
two_phab_revisions=False,
107107
assert_affected_func=None,
108108
assert_prior_bug_reference=True,
109+
assert_assignee_func=None,
109110
command_callbacks={},
110111
keep_tmp_db=False):
111112
self.server = server.HTTPServer(('', 27490), MockTreeherderServerFactory(treeherder_response))
@@ -131,6 +132,7 @@ def _setup(self,
131132
'get_filed_bug_id_func': get_filed_bug_id_func,
132133
'filed_bug_ids_func': filed_bug_ids_func,
133134
'assert_affected_func': assert_affected_func,
135+
'assert_assignee_func': assert_assignee_func,
134136
'assert_prior_bug_reference': assert_prior_bug_reference
135137
},
136138
'Mercurial': {},
@@ -861,15 +863,77 @@ def treeherder(request_type, fullpath):
861863
return "jobs_success_notlinux.txt"
862864
self.assertTrue(False, "Should not reach here")
863865

866+
saw_assignee = False
867+
868+
def assert_assignee_func(assignee):
869+
nonlocal saw_assignee
870+
if assignee is not None:
871+
saw_assignee = True
872+
assert assignee == "[email protected]", "Bugzilla Assignee was incorrect"
873+
864874
call_counter = 0
865875
library_filter = 'dav1d'
866876
(u, expected_values, _check_jobs) = self._setup(
867877
library_filter,
868878
lambda b: ["80240fe58a7558fc21d4f2499261a53f3a9f6fad|2021-02-09 15:30:04 -0500|2021-02-12 17:40:01 +0000"],
869879
lambda: ["80240fe58a7558fc21d4f2499261a53f3a9f6fad", "56AAAAAAacfacba40993e47ef8302993c59e264e"],
870880
lambda: 50, # get_filed_bug_id_func,
871-
lambda b: {} if call_counter == 0 else OrderedDict({50: {'id':50, 'assigned_to_detail':{'email':'[email protected]'}}}), # filed_bug_ids_func
872-
treeherder
881+
lambda b: {} if call_counter == 0 else OrderedDict({50: {'id': 50, 'assigned_to_detail': {'email': '[email protected]'}}}), # filed_bug_ids_func
882+
treeherder,
883+
assert_assignee_func=assert_assignee_func
884+
)
885+
886+
try:
887+
# Check that we created the job successfully
888+
u.run(library_filter=library_filter)
889+
_check_jobs(JOBSTATUS.AWAITING_INITIAL_PLATFORM_TRY_RESULTS, JOBOUTCOME.PENDING)
890+
# Run it again, this time we'll tell it the jobs are still in process
891+
u.run(library_filter=library_filter)
892+
_check_jobs(JOBSTATUS.AWAITING_INITIAL_PLATFORM_TRY_RESULTS, JOBOUTCOME.PENDING)
893+
894+
call_counter += 1 # See (**)
895+
896+
# Run it again, this time we'll tell it the jobs are done
897+
u.run(library_filter=library_filter)
898+
_check_jobs(JOBSTATUS.AWAITING_SECOND_PLATFORMS_TRY_RESULTS, JOBOUTCOME.PENDING)
899+
# Run it again, this time we'll tell it everything succeeded
900+
u.run(library_filter=library_filter)
901+
_check_jobs(JOBSTATUS.DONE, JOBOUTCOME.ALL_SUCCESS)
902+
assert saw_assignee, "Did not see the correct asignee for the bug at any point"
903+
finally:
904+
self._cleanup(u, expected_values)
905+
906+
# Create -> Jobs are Running -> All Success
907+
@logEntryExitHeaderLine
908+
def testAssigneeNotOverwritten(self):
909+
@treeherder_response
910+
def treeherder(request_type, fullpath):
911+
if request_type == TYPE_HEALTH:
912+
return "health_all_success.txt"
913+
self.assertTrue(False, "Should not reach here")
914+
else: # TYPE_JOBS
915+
if treeherder.jobs_calls == 0:
916+
return "jobs_still_running.txt"
917+
if "80240fe58a7558fc21d4f2499261a53f3a9f6fad" in fullpath:
918+
return "jobs_success_linuxonly.txt"
919+
elif "56AAAAAAacfacba40993e47ef8302993c59e264e" in fullpath:
920+
return "jobs_success_notlinux.txt"
921+
self.assertTrue(False, "Should not reach here")
922+
923+
def assert_assignee_func(assignee):
924+
if assignee is not None:
925+
assert assignee == "[email protected]", "We did not set the assignee correctly."
926+
927+
call_counter = 0
928+
library_filter = 'dav1d'
929+
(u, expected_values, _check_jobs) = self._setup(
930+
library_filter,
931+
lambda b: ["80240fe58a7558fc21d4f2499261a53f3a9f6fad|2021-02-09 15:30:04 -0500|2021-02-12 17:40:01 +0000"],
932+
lambda: ["80240fe58a7558fc21d4f2499261a53f3a9f6fad", "56AAAAAAacfacba40993e47ef8302993c59e264e"],
933+
lambda: 50, # get_filed_bug_id_func,
934+
lambda b: {} if call_counter == 0 else OrderedDict({50: {'id': 50, 'assigned_to_detail': {'email': '[email protected]'}}}), # filed_bug_ids_func
935+
treeherder,
936+
assert_assignee_func=assert_assignee_func
873937
)
874938

875939
try:

0 commit comments

Comments
 (0)