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
    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_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)
Example #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 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))
Example #7
0
    def test_process_queue_duplicate(self):
        with nested(
            mock.patch("%s.core.git.GitQueue.update_request_failure" % __name__),
            mock.patch("%s.core.git.GitQueue.update_request_successful" % __name__),
            # This will fail, stop logging errors
            mock.patch("%s.core.git.logging.error" % __name__),
            mock.patch(
                "%s.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(core.git.GitQueue.update_request_failure.call_count, 1)
            T.assert_equal(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",
                core.git.GitQueue.update_request_failure.call_args_list[0][0][-1]
            )
Example #8
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)
Example #9
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)
Example #10
0
    def test_process_queue_duplicate(self):
        with nested(
                mock.patch("%s.core.git.GitQueue.update_request_failure" %
                           __name__),
                mock.patch("%s.core.git.GitQueue.update_request_successful" %
                           __name__),
                # This will fail, stop logging errors
                mock.patch("%s.core.git.logging.error" % __name__),
                mock.patch("%s.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(core.git.GitQueue.update_request_failure.call_count,
                           1)
            T.assert_equal(
                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",
                core.git.GitQueue.update_request_failure.call_args_list[0][0]
                [-1])
    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
Example #12
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"])
Example #13
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)
Example #14
0
 def test_login_post(self):
     request = {"username": "******", "password": "******"}
     with mock.patch.object(logging, "exception"):
         response = self.fetch("/login",
                               method="POST",
                               body=urllib.urlencode(request))
         T.assert_in("Invalid username or password specified.",
                     response.body)
Example #15
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)
Example #16
0
    def verify_tag_rename(self, oldtag, newtag, success, db_results):
        self.check_db_results(success, db_results)

        #id, user, state, repo, branch, revision, *tags*, created, etc...
        tags = [result[6] for result in db_results.fetchall()]

        T.assert_not_in(oldtag, tags)
        T.assert_in(newtag, tags)
 def test_pushitems(self):
     with contextlib.nested(
         mock.patch.object(PushItemsServlet, "get_current_user", return_value=self.fake_request_data["user"]),
         mock.patch.object(PushItemsServlet, "async_api_call", side_effect=self.mocked_api_call),
         mock.patch.object(self, "api_response", return_value=self.fake_requests_response)
     ):
         self.fetch("/pushitems?push=%d" % self.fake_request_data["id"])
         response = self.wait()
         T.assert_in(self.fake_request_data["title"], response.body)
    def verify_type_rename(self, oldtype, newtype, success, db_results):
        self.check_db_results(success, db_results)

        # id, push, *type*, status, target
        types = [result[2] for result in db_results.fetchall()]

        T.assert_not_in(oldtype, types)
        T.assert_not_in('%s-cleanup' % oldtype, types)
        T.assert_in('%s' % newtype, types)
        T.assert_in('%s-cleanup' % newtype, types)
    def verify_type_rename(self, oldtype, newtype, success, db_results):
        self.check_db_results(success, db_results)

        # id, push, *type*, status, target
        types = [result[2] for result in db_results.fetchall()]

        T.assert_not_in(oldtype, types)
        T.assert_not_in('%s-cleanup' % oldtype, types)
        T.assert_in('%s' % newtype, types)
        T.assert_in('%s-cleanup' % newtype, types)
    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])
Example #21
0
 def test_login_post(self):
     request = {
         "username": "******",
         "password": "******"
     }
     with mock.patch.object(logging, "exception"):
         response = self.fetch(
             "/login",
             method="POST",
             body=urllib.urlencode(request)
         )
         T.assert_in("Invalid username or password specified.", response.body)
Example #22
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))
Example #23
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))
Example #24
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))
def test_create_community_cards():
    try:
        community = CommunityCardSet()
        for s, v in [('H', 2), ('H', 14), ('D', 11), ('S', 8), ('C', 8)]:
            community.add(Card(s, v))
        community_cards_string = str(community)
        for s, v in [('H', 2), ('H', 14), ('D', 11), ('S', 8), ('C', 8)]:
            msg = "The community set's string representation should contain the string " \
                  + "representation of the card " + str((s, v))
            assert_in(msg, str(Card(s, v)), community_cards_string)
    except:
        fail_on_error(
            "Trying to create a community card set and adding cards to it.",
            sys.exc_info())
def test_str():
    try:
        a_hand = PokerHand()
        a_hand.add_card(Card('S', 11))
        a_hand.add_card(Card('S', 10))
        a_hand_string = str(a_hand)
        assert_in("Added card 'S11'. String representation of hand should contain 'Jack of Spades'.",
                  "Jack of Spades",
                  a_hand_string)
        assert_in("Added card 'S10'. String representation of hand should contain '10 of Spades'.",
                  "10 of Spades",
                  a_hand_string)
    except:
        fail_on_error("Runtime error when calling __str__ of PokerHand object.", sys.exc_info())
Example #27
0
    def assert_push_info_listitems(self, list_items, push_info_items):
        for li in list_items:
            T.assert_in(li[0].text, push_info_items.keys())
            if li[0].text == 'Buildbot Runs':
                T.assert_equal(li[1][0].text, 'url')
                T.assert_equal(li[1][0].attrib['href'], push_info_items['Buildbot Runs'])
            elif li[0].text == 'State':
                T.assert_equal(li[1][0].attrib['class'], 'tags')  # Inner ul
                T.assert_equal(li[1][0][0].attrib['class'], 'tag-%s' % push_info_items['State'])  # Inner li
                T.assert_equal(li[1][0][0].text, push_info_items['State'])
            elif li[0].text == 'Push Type':
                T.assert_equal(li[1][0].attrib['class'], 'tags')  # Inner ul
                T.assert_equal(li[1][0][0].attrib['class'], 'tag-%s' % push_info_items['Push Type'])  # Inner li
                T.assert_equal(li[1][0][0].text, push_info_items['Push Type'])
            else:
                T.assert_equal(li[1].text, push_info_items[li[0].text])

        T.assert_equal(len(list_items), len(push_info_items))
Example #28
0
    def test_newpush(self):
        pushes = []

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

        with nested(
            mock.patch.dict(db.Settings, T.MockedSettings),
            mock.patch.object(NewPushServlet, "get_current_user", return_value = "jblack"),
            mock.patch.object(NewPushServlet, "redirect"),
        ):
            with mock.patch("%s.servlets.newpush.subprocess.call" % __name__) as mocked_call:
                title = "BestPushInTheWorld"
                branch = "jblack"
                push_type = "regular"

                uri = "/newpush?push-title=%s&branch=%s&push-type=%s" % (
                    title, branch, push_type
                )

                pushes = []
                db.execute_cb(db.push_pushes.select(), on_db_return)
                num_pushes_before = len(pushes)

                response = self.fetch(uri)
                assert response.error == None

                pushes = []
                db.execute_cb(db.push_pushes.select(), on_db_return)
                num_pushes_after = len(pushes)

                T.assert_equal(num_pushes_before + 1, num_pushes_after)

                # There should be one call to nodebot after a push is created
                T.assert_equal(servlets.newpush.subprocess.call.call_count, 1)

                # Verify that we have a valid call to
                # subprocess.call. Getting the arguments involves ugly
                # mock magic
                call = mocked_call.call_args
                args = call[0][0]
                last_arg = args[-1]
                T.assert_in("regular push starting! https://", last_arg)
Example #29
0
    def test_push_buttons_pushmaster(self):
        kwargs = dict(self.basic_kwargs)
        kwargs['current_user'] = self.basic_push['user']

        with self.no_ui_modules():
            tree = self.render_etree(
                self.push_button_bar_page,
                push_info=self.basic_push,
                **kwargs)

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

        T.assert_equal(
                len(found_buttons),
                len(self.push_button_ids_base + self.push_button_ids_pushmaster))
    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)
    def test_summaryforbranch(self):
        fake_request = """{
            "id": 10,
            "user": "******",
            "repo": "testuser",
            "state": "requested",
            "branch": "testuser_fixes",
            "revision": "00000",
            "description": "long desc",
            "title": "funny title",
            "reviewid": 101
        }"""

        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_fixes")
            response = self.wait()
            T.assert_equal(response.error, None)
            T.assert_in("long desc", response.body)
    def test_no_watched_mailqueue_on_db_complete(self, mailq):
        req = {
            'user': '******',
            'watchers': None,
            'repo': 'repo',
            'branch': 'branch',
            'title': 'title',
            'state': 'discarded',
        }
        self.call_on_db_complete(req)

        no_watcher_call_args = mailq.call_args_list[0][0]
        T.assert_equal(['testuser'], no_watcher_call_args[0])
        T.assert_in('Request for testuser', no_watcher_call_args[1])
        T.assert_in('testuser - title', no_watcher_call_args[1])
        T.assert_in('[push] testuser - title', no_watcher_call_args[2])
Example #33
0
    def test_no_watched_mailqueue_on_db_complete(self, mailq):
        req = {
            'user': '******',
            'watchers': None,
            'repo': 'repo',
            'branch': 'branch',
            'title': 'title',
            'state': 'discarded',
        }
        self.call_on_db_complete(req)

        no_watcher_call_args = mailq.call_args_list[0][0]
        T.assert_equal(['testuser'], no_watcher_call_args[0])
        T.assert_in('Request for testuser', no_watcher_call_args[1])
        T.assert_in('testuser - title', no_watcher_call_args[1])
        T.assert_in('[push] testuser - title', no_watcher_call_args[2])
    def test_watched_mailqueue_on_db_complete(self, mailq):
        req = {
            'user': '******',
            'watchers': 'testuser1,testuser2',
            'repo': 'repo',
            'branch': 'branch',
            'title': 'title',
            'state': 'delayed',
        }
        self.call_on_db_complete(req)

        watched_call_args = mailq.call_args_list[0][0]
        T.assert_equal(['testuser', 'testuser1', 'testuser2'], watched_call_args[0])
        T.assert_in('Request for testuser (testuser1,testuser2)', watched_call_args[1])
        T.assert_in('testuser (testuser1,testuser2) - title', watched_call_args[1])
        T.assert_in('[push] testuser (testuser1,testuser2) - title', watched_call_args[2])
    def test_watched_mailqueue_on_db_complete(self, mailq):
        req = {
            'user': '******',
            'watchers': 'testuser1,testuser2',
            'repo': 'repo',
            'branch': 'branch',
            'title': 'title',
            'state': 'delayed',
        }
        self.call_on_db_complete(req)

        watched_call_args = mailq.call_args_list[0][0]
        T.assert_equal(['testuser', 'testuser1', 'testuser2'],
                       watched_call_args[0])
        T.assert_in('Request for testuser (testuser1,testuser2)',
                    watched_call_args[1])
        T.assert_in('testuser (testuser1,testuser2) - title',
                    watched_call_args[1])
        T.assert_in('[push] testuser (testuser1,testuser2) - title',
                    watched_call_args[2])
Example #36
0
 def test_localizables_push_website_command_is_correct_in_push_js(self):
     with self.request_fake_pushdata():
         response = self.fetch("/static/js/push.js")
         T.assert_in("localizables_push_website.py", response.body)
         # Old (bash) version of the script shouldn't be there
         T.assert_not_in("localizables-push-website", response.body)
Example #37
0
 def test_check_sites_bookmarklet(self):
     with self.page(CheckSitesBookmarkletHandler) as response:
         # See comment above in test_create_request_bookmarklet
         T.assert_equal(response.error, None)
         T.assert_in("window.open", response.body)
 def test_no_checklist(self):
     with fake_checklist_request():
         uri = "/checklist?id=1"
         response = self.fetch(uri)
         T.assert_equal(response.error, None)
         T.assert_in("No checklist items for this push", response.body)
Example #39
0
 def test_push_page_is_using_push_js(self):
     with self.request_fake_pushdata() as fakepush:
         pushdata, response = fakepush
         T.assert_in("js/push.js", response.body)
Example #40
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'])
Example #41
0
 def test_localizables_push_website_command_is_correct_in_push_js(self):
     with self.request_fake_pushdata():
         response = self.fetch("/static/js/push.js")
         T.assert_in("localizables_push_website.py", response.body)
         # Old (bash) version of the script shouldn't be there
         T.assert_not_in("localizables-push-website", response.body)
Example #42
0
 def test_no_checklist(self):
     with fake_checklist_request():
         uri = "/checklist?id=1"
         response = self.fetch(uri)
         T.assert_equal(response.error, None)
         T.assert_in("No checklist items for this push", response.body)
Example #43
0
 def test_check_sites_bookmarklet(self):
     with self.page(CheckSitesBookmarkletHandler) as response:
         # See comment above in test_create_request_bookmarklet
         T.assert_equal(response.error, None)
         T.assert_in("window.open", response.body)
    def test_mailqueue_on_db_complete(self, mailq, *_):
        self.call_on_db_complete()

        no_watcher_call_args = mailq.call_args_list[0][0]
        T.assert_equal(['testuser'], no_watcher_call_args[0])
        T.assert_in('for testuser', no_watcher_call_args[1])
        T.assert_in('testuser - title', no_watcher_call_args[1])
        T.assert_in('[push] testuser - title', no_watcher_call_args[2])

        watched_call_args = mailq.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])
        T.assert_in('testuser (testuser1,testuser2) - title', watched_call_args[1])
        T.assert_in('[push] testuser (testuser1,testuser2) - title', watched_call_args[2])
Example #45
0
 def test_push_page_is_using_push_js(self):
     with self.request_fake_pushdata() as fakepush:
         pushdata, response = fakepush
         T.assert_in("js/push.js", response.body)