Beispiel #1
0
    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_branch_name_with_slash(self):
        fake_request = """{
            "id": 10,
            "user": "******",
            "repo": "testuser",
            "state": "requested",
            "branch": "testuser/testbranch",
            "revision": "00000",
            "description": "description for 'testuser/testbranch'",
            "title": "funny title",
            "reviewid": 102
        }"""

        with nested(
                mock.patch.object(SummaryForBranchServlet,
                                  "get_current_user",
                                  return_value="testuser"),
                mock.patch.object(SummaryForBranchServlet,
                                  "async_api_call",
                                  side_effect=self.mocked_api_call),
                mock.patch.object(self,
                                  "api_response",
                                  return_value="[%s]" % fake_request),
        ):
            self.fetch(
                "/summaryforbranch?userbranch=testuser/testuser/testbranch")
            response = self.wait()
            T.assert_equal(response.error, None)
            T.assert_in("'testuser/testbranch'", response.body)
            T.assert_in("102", response.body)
 def test_get_api_page(self):
     MockedSettings['api_app'] = {'port': 8043, 'servername': 'push.test.com'}
     with mock.patch.dict(Settings, MockedSettings):
         T.assert_equal(
             RequestHandler.get_api_page("pushes"),
             "http://push.test.com:8043/api/pushes"
         )
    def test_hoods_checklists(self):
        with fake_checklist_request():
            # insert fake data from FakeDataMixin
            fake_pushid = 2
            self.insert_pushes()
            self.insert_requests()
            req = self.get_requests_by_user('testuser1')[0]
            self.insert_pushcontent(req['id'], fake_pushid)

            # insert fake checklist data
            checklist_queries = []
            checklist_items = (
                {'request': req['id'], 'type': 'hoods', 'target': 'stage'},
                {'request': req['id'], 'type': 'hoods', 'target': 'post-stage'},
                {'request': req['id'], 'type': 'hoods', 'target': 'prod'},
                {'request': req['id'], 'type': 'hoods-cleanup', 'target': 'post-verify-stage'},
            )
            for checklist_item in checklist_items:
                checklist_queries.append(db.push_checklist.insert(checklist_item))

            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_in("Notify testuser1 to deploy Geoservices to stage", response.body)
            T.assert_in("Notify testuser1 to deploy Geoservices to prod", response.body)
            T.assert_in("Ask Search to force index distribution on stage for testuser1", response.body)
Beispiel #5
0
 def assert_request_buttons(self, tree, button_classes, button_text):
     found_buttons = []
     for button in tree.iter('button'):
         T.assert_in(button.attrib['class'], button_classes)
         T.assert_in(button.text, button_text)
         found_buttons.append(button)
     T.assert_equal(len(button_classes), len(found_buttons))
    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 assert_request_buttons(self, tree, button_classes, button_text):
     found_buttons = []
     for button in tree.iter('button'):
         T.assert_in(button.attrib['class'], button_classes)
         T.assert_in(button.text, button_text)
         found_buttons.append(button)
     T.assert_equal(len(button_classes), len(found_buttons))
    def test_checklist_single_search_tag(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]
            self.insert_pushcontent(test1_request['id'], fake_pushid)

            # insert fake checklist data
            checklist_queries = [
                db.push_checklist.insert({
                    'request': test1_request['id'],
                    'type': 'search',
                    'target': 'prod'
                }),
                db.push_checklist.insert({
                    'request': test1_request['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_in("multiple requests", response.body)
            T.assert_in("for testuser1", response.body)
            T.assert_in("After Certifying - Do In Prod", response.body)
    def assert_checklist_for_tags(self, tags, requestid=None):
        num_checks = 0
        checks = []

        # Gather reference checklists from the code
        for tag in tags:
            # While the tag name is 'search-backend', the checklist type
            # is truncated to 'search'.
            if tag == 'search-backend':
                tag = 'search'

            if tag not in checklist_reminders:
                continue

            plain_list = checklist_reminders[tag]
            num_checks += len(plain_list)
            checks += [(tag, check) for check in plain_list]

            cleanup_tag = '%s-cleanup' % tag
            cleanup_list = checklist_reminders[cleanup_tag]
            num_checks += len(cleanup_list)
            checks += [(cleanup_tag, check) for check in cleanup_list]

        reqid = self.make_request_with_tags(tags, requestid)
        checklists = self.get_checklists(reqid)

        T.assert_equal(num_checks, len(checklists))
        for check in checks:
            T.assert_in((reqid, check[0], check[1]), checklists)

        return reqid
Beispiel #10
0
    def test_checklist_single_search_tag(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]
            self.insert_pushcontent(test1_request['id'], fake_pushid)

            # insert fake checklist data
            checklist_queries = [
                db.push_checklist.insert({
                    'request': test1_request['id'],
                    'type': 'search',
                    'target': 'prod'
                }),
                db.push_checklist.insert({
                    'request': test1_request['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_in("multiple requests", response.body)
            T.assert_in("for testuser1", response.body)
            T.assert_in("After Certifying - Do In Prod", response.body)
    def test_process_queue_duplicate(self):
        with nested(
            mock.patch("%s.pushmanager.core.git.GitQueue.update_request_failure" % __name__),
            mock.patch("%s.pushmanager.core.git.GitQueue.update_request_successful" % __name__),
            # This will fail, stop logging errors
            mock.patch("%s.pushmanager.core.git.logging.error" % __name__),
            mock.patch(
                "%s.pushmanager.core.git.GitQueue._get_request_with_sha" % __name__,
                return_value={"id": 10, "state": "requested"},
            ),
            self.mocked_update_request(self.fake_request, self.fake_request),
        ):
            # GitQueue._get_request_with_sha returning a value means
            # we have a duplicated request. This should trigger a
            # failure
            T.assert_equal(pushmanager.core.git.GitQueue.update_request_failure.call_count, 1)
            T.assert_equal(pushmanager.core.git.GitQueue.update_request_successful.call_count, 0)

            # Match the error message for duplicate revision. error_msg
            # should be the last item of the first call object's *args list
            # (from mock library).
            T.assert_in(
                "another request with the same revision sha",
                pushmanager.core.git.GitQueue.update_request_failure.call_args_list[0][0][-1],
            )
Beispiel #12
0
    def test_process_queue_duplicate(self):
        with nested(
                mock.patch(
                    "%s.pushmanager.core.git.GitQueue.update_request_failure" %
                    __name__),
                mock.patch(
                    "%s.pushmanager.core.git.GitQueue.update_request_successful"
                    % __name__),
                # This will fail, stop logging errors
                mock.patch("%s.pushmanager.core.git.logging.error" % __name__),
                mock.patch(
                    "%s.pushmanager.core.git.GitQueue._get_request_with_sha" %
                    __name__,
                    return_value={
                        'id': 10,
                        'state': 'requested'
                    }),
                self.mocked_update_request(self.fake_request,
                                           self.fake_request)):
            # GitQueue._get_request_with_sha returning a value means
            # we have a duplicated request. This should trigger a
            # failure
            T.assert_equal(
                pushmanager.core.git.GitQueue.update_request_failure.
                call_count, 1)
            T.assert_equal(
                pushmanager.core.git.GitQueue.update_request_successful.
                call_count, 0)

            # Match the error message for duplicate revision. error_msg
            # should be the last item of the first call object's *args list
            # (from mock library).
            T.assert_in(
                "another request with the same revision sha", pushmanager.core.
                git.GitQueue.update_request_failure.call_args_list[0][0][-1])
    def test_removerequest(self):
        results = []

        def on_db_return(success, db_results):
            assert success
            results.extend(db_results.fetchall())

        with nested(
            mock.patch.dict(db.Settings, MockedSettings),
            mock.patch.object(
                RemoveRequestServlet,
                "get_current_user",
                return_value="testuser"
            )
        ):
            results = []
            db.execute_cb(db.push_pushcontents.select(), on_db_return)
            num_results_before = len(results)

            uri = "/removerequest?request=1&push=1"
            response = self.fetch(uri)
            T.assert_equal(response.error, None)

            results = []
            db.execute_cb(db.push_pushcontents.select(), on_db_return)
            num_results_after = len(results)

            T.assert_equal(num_results_after, num_results_before - 1, "Request removal failed.")
Beispiel #14
0
    def test_removerequest(self):
        results = []

        def on_db_return(success, db_results):
            assert success
            results.extend(db_results.fetchall())

        with nested(
                mock.patch.dict(db.Settings, MockedSettings),
                mock.patch.object(RemoveRequestServlet,
                                  "get_current_user",
                                  return_value="testuser")):
            results = []
            db.execute_cb(db.push_pushcontents.select(), on_db_return)
            num_results_before = len(results)

            uri = "/removerequest?request=1&push=1"
            response = self.fetch(uri)
            T.assert_equal(response.error, None)

            results = []
            db.execute_cb(db.push_pushcontents.select(), on_db_return)
            num_results_after = len(results)

            T.assert_equal(num_results_after, num_results_before - 1,
                           "Request removal failed.")
    def test_pushplans_and_search(self):
        tag = ['pushplans']
        orig_reqid = self.assert_checklist_for_tags(tag)

        tags = ['pushplans', 'search-backend']
        new_reqid = self.assert_checklist_for_tags(tags, orig_reqid)

        T.assert_equal(orig_reqid, new_reqid)
    def test_search_and_hoods(self):
        tag = ['hoods']
        orig_reqid = self.assert_checklist_for_tags(tag)

        tags = ['search-backend', 'hoods']
        new_reqid = self.assert_checklist_for_tags(tags, orig_reqid)

        T.assert_equal(orig_reqid, new_reqid)
    def test_pushplans_and_hoods(self):
        tag = ['hoods']
        orig_reqid = self.assert_checklist_for_tags(tag)

        tags = ['pushplans', 'hoods']
        new_reqid = self.assert_checklist_for_tags(tags, orig_reqid)

        T.assert_equal(orig_reqid, new_reqid)
 def test_create_request_bookmarklet(self):
     with self.page(CreateRequestBookmarkletHandler) as response:
         # We'll get a javascript as the body, just check some
         # variable names/strings that we know is there in the
         # script.
         T.assert_equal(response.error, None)
         T.assert_in("ticketNumberToURL", response.body)
         T.assert_in("codeReview", response.body)
 def test_get_api_page(self):
     MockedSettings['api_app'] = {
         'port': 8043,
         'servername': 'push.test.com'
     }
     with mock.patch.dict(Settings, MockedSettings):
         T.assert_equal(RequestHandler.get_api_page("pushes"),
                        "http://push.test.com:8043/api/pushes")
Beispiel #20
0
 def test_create_request_bookmarklet(self):
     with self.page(CreateRequestBookmarkletHandler) as response:
         # We'll get a javascript as the body, just check some
         # variable names/strings that we know is there in the
         # script.
         T.assert_equal(response.error, None)
         T.assert_in("ticketNumberToURL", response.body)
         T.assert_in("codeReview", response.body)
 def test_update_request_failure(self):
     with nested(
         mock.patch("%s.pushmanager.core.git.MailQueue.enqueue_user_email" % __name__),
         mock.patch("%s.pushmanager.core.git.webhook_req" % __name__),
         mock.patch("%s.pushmanager.core.git.logging.error" % __name__),
     ):
         pushmanager.core.git.GitQueue.update_request_failure(self.fake_request, "fake failure")
         T.assert_equal(pushmanager.core.git.MailQueue.enqueue_user_email.call_count, 1)
 def test_update_request_successful(self):
     with nested(
         mock.patch("%s.pushmanager.core.git.MailQueue.enqueue_user_email" % __name__),
         mock.patch("%s.pushmanager.core.git.webhook_req" % __name__),
     ):
         pushmanager.core.git.GitQueue.update_request_successful(self.fake_request)
         T.assert_equal(pushmanager.core.git.MailQueue.enqueue_user_email.call_count, 1)
         T.assert_equal(pushmanager.core.git.webhook_req.call_count, 3)
Beispiel #23
0
 def test_escape(self):
     T.assert_equal(
         [k for k in self.d if self.ed[k] != self.escaped[k]],
         [],
         "EscapedDict values doesn't match with pre-computed valued"
     )
     T.assert_in("&", self.ed['amp'])
     T.assert_not_in(">", self.ed['gt'])
    def test_include_new_push(self):
        tree = self.render_pushes_page()

        found_form = []
        for form in tree.iter('form'):
            if form.attrib['id'] == 'push-info-form':
                found_form.append(form)

        T.assert_equal(len(found_form), 1)
 def test_kill_processes(self):
     with contextlib.nested(
             self.mock_method('%s.pid.os.kill' % __name__, None, None),
             self.mock_method('%s.pid.is_process_alive' % __name__, False, None)
     ):
         # this should run fine, all processes are dead
         pids = [1, 2, 3, 4, 5]
         pid.kill_processes(pids)
         T.assert_equal(pids, [])
Beispiel #26
0
 def test_kill_processes(self):
     with contextlib.nested(
             self.mock_method('%s.pid.os.kill' % __name__, None, None),
             self.mock_method('%s.pid.is_process_alive' % __name__, False,
                              None)):
         # this should run fine, all processes are dead
         pids = [1, 2, 3, 4, 5]
         pid.kill_processes(pids)
         T.assert_equal(pids, [])
    def test_include_request_info(self):
        tree = self.render_module_request_with_users(self.basic_request,'testuser', 'testuser', **self.basic_kwargs)

        found_ul = []
        for ul in tree.iter('ul'):
            if ul.attrib['class'] == 'request-info-inline':
                found_ul.append(ul)

        T.assert_equal(1, len(found_ul))
    def test_include_new_push(self):
        tree = self.render_pushes_page()

        found_form = []
        for form in tree.iter('form'):
            if form.attrib['id'] == 'push-info-form':
                found_form.append(form)

        T.assert_equal(len(found_form), 1)
    def test_push_buildbot_revision_link(self):
        with self.request_fake_pushdata() as fakepush:
            pushdata, response = fakepush
            T.assert_equal(response.error, None)

            requests = pushdata[1]
            all_requests = requests['all']
            first_request = all_requests[0]
            buildbot_link = "https://%s/rev/%s" % (Settings['buildbot']['servername'], first_request['revision'])
            T.assert_equal(self.find_buildbot_link(response, buildbot_link), True)
    def test_xmppqueue_on_db_complete(self, xmppq, _):
        self.call_on_db_complete()

        no_watcher_call_args = xmppq.call_args_list[0][0]
        T.assert_equal(['testuser'], no_watcher_call_args[0])
        T.assert_in('for testuser', no_watcher_call_args[1])

        watched_call_args = xmppq.call_args_list[1][0]
        T.assert_equal(['testuser', 'testuser1', 'testuser2'], watched_call_args[0])
        T.assert_in('for testuser (testuser1,testuser2)', watched_call_args[1])
 def test_get_repository_uri_basic(self):
     MockedSettings["git"] = self.fake_settings
     with mock.patch.dict(Settings, MockedSettings):
         T.assert_equal(
             pushmanager.core.git.GitQueue._get_repository_uri("main_repository"), "git://example/main_repository"
         )
         T.assert_equal(
             pushmanager.core.git.GitQueue._get_repository_uri("second_repository"),
             "git://example/dev_directory/second_repository",
         )
 def test_update_duplicate_request_discarded(self):
     duplicate_req = copy.deepcopy(self.fake_request)
     duplicate_req["state"] = "discarded"
     with nested(
         mock.patch("%s.pushmanager.core.git.GitQueue.update_request_failure" % __name__),
         mock.patch("%s.pushmanager.core.git.GitQueue.update_request_successful" % __name__),
         self.mocked_update_request(self.fake_request, duplicate_req),
     ):
         T.assert_equal(pushmanager.core.git.GitQueue.update_request_failure.call_count, 0)
         T.assert_equal(pushmanager.core.git.GitQueue.update_request_successful.call_count, 1)
Beispiel #33
0
    def test_pushes(self):
        pushes, last_push = self.api_call("pushes")
        T.assert_length(pushes, 2)
        T.assert_equal(last_push, 2)

        pushes, last_push = self.api_call("pushes?rpp=1")
        T.assert_length(pushes, 1)

        pushes, last_push = self.api_call("pushes?before=%d" % time.time())
        T.assert_length(pushes, 2)
    def test_pushes(self):
        pushes, last_push = self.api_call("pushes")
        T.assert_length(pushes, 2)
        T.assert_equal(last_push, 2)

        pushes, last_push = self.api_call("pushes?rpp=1")
        T.assert_length(pushes, 1)

        pushes, last_push = self.api_call("pushes?before=%d" % time.time())
        T.assert_length(pushes, 2)
Beispiel #35
0
 def test_get_repository_uri_basic(self):
     MockedSettings["git"] = self.fake_settings
     with mock.patch.dict(Settings, MockedSettings):
         T.assert_equal(
             pushmanager.core.git.GitQueue._get_repository_uri(
                 "main_repository"), "git://example/main_repository")
         T.assert_equal(
             pushmanager.core.git.GitQueue._get_repository_uri(
                 "second_repository"),
             "git://example/dev_directory/second_repository")
Beispiel #36
0
    def test_include_request_info(self):
        tree = self.render_module_request_with_users(self.basic_request,
                                                     'testuser', 'testuser',
                                                     **self.basic_kwargs)

        found_ul = []
        for ul in tree.iter('ul'):
            if ul.attrib['class'] == 'request-info-inline':
                found_ul.append(ul)

        T.assert_equal(1, len(found_ul))
    def assert_button_link(self, button, tree, text=None, num=1):
        classname = '%s-request' % button.lower()
        if text is None:
            text = button.capitalize()

        buttons = []
        for button in tree.iter('button'):
            if button.attrib['class'] == classname:
                T.assert_equal(text, button.text)
                buttons.append(button)
        T.assert_equal(num, len(buttons))
Beispiel #38
0
    def test_dialogs_divs(self):
        tree = self.render_etree(self.push_dialogs_page,
                                 push_info=self.basic_push,
                                 **self.basic_kwargs)

        found_divs = []
        for div in tree.iter('div'):
            T.assert_in(div.attrib['id'], self.dialog_ids)
            found_divs.append(div)

        T.assert_equal(len(found_divs), len(self.dialog_ids))
Beispiel #39
0
    def test_send_mail(self):
        with mock.patch.object(pushmanager.core.mail.MailQueue, "smtp") as mocked_smtp:
            with mock.patch.object(pushmanager.core.mail.MailQueue, "message_queue"):
                recipient = "*****@*****.**"
                message = "test message"
                subject = "test subject"
                from_email = "*****@*****.**"

                pushmanager.core.mail.MailQueue._send_email(recipient, message, subject, from_email)

                T.assert_equal(mocked_smtp.sendmail.called, True)
Beispiel #40
0
    def test_include_push_info(self):
        tree = self.render_etree(self.push_page,
                                 push_info=self.basic_push,
                                 **self.basic_kwargs)

        found_ul = []
        for ul in tree.iter('ul'):
            if 'id' in ul.attrib and ul.attrib['id'] == 'push-info':
                found_ul.append(ul)

        T.assert_equal(1, len(found_ul))
Beispiel #41
0
    def test_include_dialogs(self):
        tree = self.render_etree(self.push_page,
                                 push_info=self.basic_push,
                                 **self.basic_kwargs)

        found_divs = []
        for div in tree.iter('div'):
            if 'id' in div.attrib and div.attrib['id'] == 'dialog-prototypes':
                found_divs.append(div)

        T.assert_equal(len(found_divs), 1)
    def test_pushcontent_insert_ignore(self, mock_transaction):
        request = {'request': 1, 'push': 1}
        response = self.fetch('/addrequest',
                              method='POST',
                              body=urllib.urlencode(request))
        T.assert_equal(response.error, None)
        T.assert_equal(mock_transaction.call_count, 1)

        # Extract the string of the prefix of the insert query
        insert_ignore_clause = mock_transaction.call_args[0][0][0]
        T.assert_is(type(insert_ignore_clause), db.InsertIgnore)
Beispiel #43
0
    def test_include_edit_push(self):
        tree = self.render_etree(self.push_page,
                                 push_info=self.basic_push,
                                 **self.basic_kwargs)

        found_form = []
        for form in tree.iter('form'):
            if form.attrib['id'] == 'push-info-form':
                found_form.append(form)

        T.assert_equal(len(found_form), 1)
    def test_xmppqueue_on_db_complete(self, xmppq, _):
        self.call_on_db_complete()

        no_watcher_call_args = xmppq.call_args_list[0][0]
        T.assert_equal(['testuser'], no_watcher_call_args[0])
        T.assert_in('for testuser', no_watcher_call_args[1])

        watched_call_args = xmppq.call_args_list[1][0]
        T.assert_equal(['testuser', 'testuser1', 'testuser2'],
                       watched_call_args[0])
        T.assert_in('for testuser (testuser1,testuser2)', watched_call_args[1])
Beispiel #45
0
    def assert_button_link(self, button, tree, text=None, num=1):
        classname = '%s-request' % button.lower()
        if text is None:
            text = button.capitalize()

        buttons = []
        for button in tree.iter('button'):
            if button.attrib['class'] == classname:
                T.assert_equal(text, button.text)
                buttons.append(button)
        T.assert_equal(num, len(buttons))
    def test_include_dialogs(self):
        tree = self.render_etree(
            self.push_page,
            push_info=self.basic_push,
            **self.basic_kwargs)

        found_divs = []
        for div in tree.iter('div'):
            if 'id' in div.attrib and div.attrib['id'] ==  'dialog-prototypes':
                found_divs.append(div)

        T.assert_equal(len(found_divs), 1)
 def test_get_repository_uri_with_auth(self):
     MockedSettings["git"] = self.fake_settings
     MockedSettings["git"]["auth"] = "myuser:mypass"
     with mock.patch.dict(Settings, MockedSettings):
         T.assert_equal(
             pushmanager.core.git.GitQueue._get_repository_uri("main_repository"),
             "git://*****:*****@example/main_repository",
         )
         T.assert_equal(
             pushmanager.core.git.GitQueue._get_repository_uri("second_repository"),
             "git://*****:*****@example/dev_directory/second_repository",
         )
    def test_include_edit_push(self):
        tree = self.render_etree(
            self.push_page,
            push_info=self.basic_push,
            **self.basic_kwargs)

        found_form = []
        for form in tree.iter('form'):
            if form.attrib['id'] ==  'push-info-form':
                found_form.append(form)

        T.assert_equal(len(found_form), 1)
Beispiel #49
0
    def test_push_buttons_random_user(self):
        with self.no_ui_modules():
            tree = self.render_etree(self.push_button_bar_page,
                                     push_info=self.basic_push,
                                     **self.basic_kwargs)

        found_buttons = []
        for button in tree.iter('button'):
            T.assert_in(button.attrib['id'], self.push_button_ids_base)
            found_buttons.append(button)

        T.assert_equal(len(found_buttons), len(self.push_button_ids_base))
Beispiel #50
0
    def test_include_push_status_when_accepting(self):
        tree = self.render_etree(self.push_page,
                                 push_info=self.basic_push,
                                 **self.basic_kwargs)

        found_h3 = []
        for h3 in tree.iter('h3'):
            T.assert_equal('status-header', h3.attrib['class'])
            T.assert_in(h3.attrib['section'], self.accepting_push_sections)
            found_h3.append(h3)

        T.assert_equal(len(self.accepting_push_sections), len(found_h3))
Beispiel #51
0
 def test_get_repository_uri_with_auth(self):
     MockedSettings["git"] = self.fake_settings
     MockedSettings["git"]["auth"] = "myuser:mypass"
     with mock.patch.dict(Settings, MockedSettings):
         T.assert_equal(
             pushmanager.core.git.GitQueue._get_repository_uri(
                 "main_repository"),
             "git://*****:*****@example/main_repository")
         T.assert_equal(
             pushmanager.core.git.GitQueue._get_repository_uri(
                 "second_repository"),
             "git://*****:*****@example/dev_directory/second_repository")
    def test_include_push_button_bar(self):
        tree = self.render_etree(
            self.push_page,
            push_info=self.basic_push,
            **self.basic_kwargs)

        found_ul = []
        for ul in tree.iter('ul'):
            if 'id' in ul.attrib and ul.attrib['id'] == 'action-buttons':
                found_ul.append(ul)

        T.assert_equal(1, len(found_ul))
    def test_dialogs_divs(self):
        tree = self.render_etree(
            self.push_dialogs_page,
            push_info=self.basic_push,
            **self.basic_kwargs)

        found_divs = []
        for div in tree.iter('div'):
            T.assert_in(div.attrib['id'], self.dialog_ids)
            found_divs.append(div)

        T.assert_equal(len(found_divs),len(self.dialog_ids))
Beispiel #54
0
    def test_push_buildbot_revision_link(self):
        with self.request_fake_pushdata() as fakepush:
            pushdata, response = fakepush
            T.assert_equal(response.error, None)

            requests = pushdata[1]
            all_requests = requests['all']
            first_request = all_requests[0]
            buildbot_link = "https://%s/rev/%s" % (
                Settings['buildbot']['servername'], first_request['revision'])
            T.assert_equal(self.find_buildbot_link(response, buildbot_link),
                           True)