def test_checklist_duplicate(self): with fake_checklist_request(): # insert fake data from FakeDataMixin fake_pushid = 2 self.insert_pushes() self.insert_requests() test1_request = self.get_requests_by_user('testuser1')[0] test2_request = self.get_requests_by_user('testuser2')[0] self.insert_pushcontent(test1_request['id'], fake_pushid) self.insert_pushcontent(test2_request['id'], fake_pushid) # insert fake checklist data checklist_queries = [] for req in (test1_request, test2_request): checklist_queries.append( db.push_checklist.insert({ 'request': req['id'], 'type': 'search', 'target': 'prod' })) checklist_queries.append( db.push_checklist.insert({ 'request': req['id'], 'type': 'search-cleanup', 'target': 'post-verify-prod' })) db.execute_transaction_cb(checklist_queries, on_db_return) uri = "/checklist?id=%d" % fake_pushid response = self.fetch(uri) T.assert_equal(response.error, None) T.assert_not_in("No checklist items for this push", response.body) T.assert_not_equal( re.search("for testuser\d,testuser\d", response.body), None) T.assert_in("After Certifying - Do In Prod", response.body)
def test_checklist_duplicate(self): with fake_checklist_request(): # insert fake data from FakeDataMixin fake_pushid = 2 self.insert_pushes() self.insert_requests() test1_request = self.get_requests_by_user('testuser1')[0] test2_request = self.get_requests_by_user('testuser2')[0] self.insert_pushcontent(test1_request['id'], fake_pushid) self.insert_pushcontent(test2_request['id'], fake_pushid) # insert fake checklist data checklist_queries = [] for req in (test1_request, test2_request): checklist_queries.append(db.push_checklist.insert({ 'request': req['id'], 'type': 'search', 'target': 'prod' })) checklist_queries.append(db.push_checklist.insert({ 'request': req['id'], 'type': 'search-cleanup', 'target': 'post-verify-prod' })) db.execute_transaction_cb(checklist_queries, on_db_return) uri = "/checklist?id=%d" % fake_pushid response = self.fetch(uri) T.assert_equal(response.error, None) T.assert_not_in("No checklist items for this push", response.body) T.assert_not_equal(re.search("for testuser\d,testuser\d", response.body), None) T.assert_in("After Certifying - Do In Prod", response.body)
def test_include_push_buttons(self): kwargs = dict(self.basic_kwargs) kwargs['push_buttons'] = True tree = self.render_module_request_with_users(self.basic_request, 'testuser', 'testuser', **kwargs) found_span = [] for span in tree.iter('span'): T.assert_not_equal('edit-request-buttons', span.attrib['class']) if span.attrib['class'] == 'push-request-buttons': found_span.append(span) T.assert_equal(1, len(found_span))
def test_duplicate_pickmerequest(self): with self.fake_pickme_request_ignore_error(): # Pickme request shoud not be on two valid # pushes. Allowing so would create confusion when/if a # pushmaster accepts the request in a push. pushid = 1 duplicate_pushid = 2 requestid = 2 response = self.fetch("/pickmerequest?push=%d&request=%d" % (pushid, requestid)) T.assert_equal(response.error, None) response = self.fetch("/pickmerequest?push=%d&request=%d" % (duplicate_pushid, requestid)) T.assert_not_equal(response.error, None)
def test_pushcontents_duplicate_key(self): with self.fake_pickme_request_ignore_error(): # push_pushcontents table should define a multi column # primary key on (request id, push id). # # Fake data from T.ServletTestMixin already have this # (pushid, requestid) binding. Adding another pickme request # with same (request id, push id) should fail. requestid = 1 pushid = 1 uri = "/pickmerequest?push=%d&request=%d" % (pushid, requestid) response = self.fetch(uri) T.assert_not_equal(response.error, None)
def test_include_no_request_buttons(self): tree = self.render_module_request_with_users(self.basic_request, 'testuser', 'testuser', **self.basic_kwargs) for span in tree.iter('span'): T.assert_not_equal('push-request-buttons', span.attrib['class']) T.assert_not_equal('edit-request-buttons', span.attrib['class'])