def cleanup(cls, url):
     SplinterWrapper.open(url)
     if cls.browser.is_element_present_by_id("action-toggle"):
         fill_form(cls.browser, {"action-toggle": True})
         fill_form_and_submit(cls.browser, {"action": "delete_selected"},
                              "index", True, True)
         cls.browser.find_by_value("Yes, I'm sure").first.click()
Ejemplo n.º 2
0
 def reply_poll_to_an_ureporter(cls, poll_id, message):
     SplinterWrapper.open("/%s/responses/" % poll_id)
     responses_all = cls.browser.find_by_id("input_select_all").first
     responses_all.check()
     cls.browser.fill("text", message)
     reply_link = cls.browser.find_link_by_text("Reply to selected")
     reply_link.click()
 def reply_poll_to_an_ureporter(cls, poll_id, message):
     SplinterWrapper.open("/%s/responses/" % poll_id)
     responses_all = cls.browser.find_by_id("input_select_all").first
     responses_all.check()
     cls.browser.fill("text", message)
     reply_link = cls.browser.find_link_by_text("Reply to selected")
     reply_link.click()
    def test_login_redirects_to_admin_dashboard_on_success(self):
        SplinterWrapper.open("/accounts/logout")
        SplinterWrapper.open("/accounts/login")
        fill_form(self.browser, {"username": "******", "password":"******"}, True, True)
        self.browser.find_by_value("Login").first.click()

        self.assertEqual(self.browser.is_text_present('Add New Poll'), True)
 def start_poll(cls,browser, poll_id):
     SplinterWrapper.open("/view_poll/%s " % poll_id)
     if len(browser.find_link_by_text('Start Poll')) > 0:
         browser.find_link_by_text('Start Poll').first.click()
         time.sleep(2) #Sending questions is an asynchronous process
     elif len(browser.find_link_by_text('Reopen Poll')) > 0:
         PollBase.reopen_poll(browser,poll_id)
Ejemplo n.º 6
0
 def start_poll(cls, browser, poll_id):
     SplinterWrapper.open("/view_poll/%s " % poll_id)
     if len(browser.find_link_by_text('Start Poll')) > 0:
         browser.find_link_by_text('Start Poll').first.click()
         time.sleep(2)  #Sending questions is an asynchronous process
     elif len(browser.find_link_by_text('Reopen Poll')) > 0:
         PollBase.reopen_poll(browser, poll_id)
 def tearDownClass(cls):
     cls.delete_poll()
     cls.cleanup("/admin/rapidsms/connection/")
     cls.cleanup("/admin/rapidsms/backend/")
     cls.cleanup("/admin/rapidsms/contact/")
     cls.cleanup("/admin/auth/group/")
     SplinterWrapper.open('/account/logout')
    def test_should_show_the_status_page(self):
        SplinterWrapper.open("/poll_status/%s" % self.poll_id)

        self.assertEqual(self.browser.is_element_present_by_id('poll-details'), True)
        self.assertTrue(self.poll_id in self.browser.find_by_id("poll-details").first.text)
        self.assertEqual(self.browser.find_by_id('contact-count').text, "1")
        self.assertEqual(self.browser.find_by_id('category-count').text, "3")
        self.assertEqual(self.browser.find_by_id('is-yesno').text, "yes")
 def reassign_poll_response(cls, poll_id, second_poll_id):
     SplinterWrapper.open("/%s/responses/" % poll_id)
     responses_all = cls.browser.find_by_id("input_select_all").first
     responses_all.check()
     elements = cls.browser.find_by_id("id_poll")
     elements.first.find_by_value(second_poll_id).first._element.click()
     assign_link = cls.browser.find_link_by_text("Assign selected to poll")
     assign_link.click()
Ejemplo n.º 10
0
 def reassign_poll_response(cls, poll_id, second_poll_id):
     SplinterWrapper.open("/%s/responses/" % poll_id)
     responses_all = cls.browser.find_by_id("input_select_all").first
     responses_all.check()
     elements = cls.browser.find_by_id("id_poll")
     elements.first.find_by_value(second_poll_id).first._element.click()
     assign_link = cls.browser.find_link_by_text("Assign selected to poll")
     assign_link.click()
Ejemplo n.º 11
0
    def create_poll(cls, browser, name, type, question, group):
        SplinterWrapper.open("/createpoll/")
        form_data = {"id_type": type, "id_name": name, "id_groups": group}
        browser.fill("question_en", question)
        fill_form(browser, form_data)
        browser.find_by_css(".buttons a").last.click()

        return browser.url.split('/')[-2]
 def assert_that_poll_question_are_sent_out_to_contacts(self, number_of_contact_for_poll, question):
     SplinterWrapper.open('/router/console')
     rows = rows_of_table_by_class(self.browser, 'messages module')
     total = 0
     for row in rows:
         if row.find_by_tag('td').first.text == question:
             total += 1
     self.assertEqual(total, number_of_contact_for_poll)
Ejemplo n.º 13
0
    def respond_to_the_started_poll(cls, sender, message):
        SplinterWrapper.open('/router/console/')
        rows_responses = rows_of_table_by_class(cls.browser, "messages module")
        number_of_responses = len(rows_responses)

        form_data = {"text": message, "sender": sender}
        fill_form(cls.browser, form_data, True)
        cls.browser.find_by_css("input[type=submit]").first.click()
        return number_of_responses
 def assert_that_poll_question_are_sent_out_to_contacts(
         self, number_of_contact_for_poll, question):
     SplinterWrapper.open('/router/console')
     rows = rows_of_table_by_class(self.browser, 'messages module')
     total = 0
     for row in rows:
         if row.find_by_tag('td').first.text == question:
             total += 1
     self.assertEqual(total, number_of_contact_for_poll)
    def test_login_redirects_to_admin_dashboard_on_success(self):
        SplinterWrapper.open("/accounts/logout")
        SplinterWrapper.open("/accounts/login")
        fill_form(self.browser, {
            "username": "******",
            "password": "******"
        }, True, True)
        self.browser.find_by_value("Login").first.click()

        self.assertEqual(self.browser.is_text_present('Add New Poll'), True)
    def test_that_poll_responses_are_shown_up_at_report_page(self):
        PollBase.start_poll(self.browser, self.poll_id)

        PollBase.respond_to_the_started_poll("0794339344", "yes")
        SplinterWrapper.open('/polls/%s/report/' % self.poll_id)
        self.assert_that_question_is(self.question)
        self.assert_the_number_of_participants_of_the_poll_is(1)

        self.assert_that_response_location_is("Kasese")
        self.assert_that_number_of_responses_is(1)
    def test_that_poll_responses_are_shown_up_at_report_page(self):
        PollBase.start_poll(self.browser,self.poll_id)

        PollBase.respond_to_the_started_poll("0794339344", "yes")
        SplinterWrapper.open('/polls/%s/report/' % self.poll_id)
        self.assert_that_question_is(self.question)
        self.assert_the_number_of_participants_of_the_poll_is(1)

        self.assert_that_response_location_is("Kasese")
        self.assert_that_number_of_responses_is(1)
    def create_poll(cls, browser, name, type, question, group):
        SplinterWrapper.open("/createpoll/")
        form_data = {
            "id_type": type,
            "id_name": name,
            "id_groups": group
        }
        browser.fill("question_en", question)
        fill_form(browser, form_data)
        browser.find_by_css(".buttons a").last.click()

        return browser.url.split('/')[-2]
    def respond_to_the_started_poll(cls, sender, message):
        SplinterWrapper.open('/router/console/')
        rows_responses = rows_of_table_by_class(cls.browser, "messages module")
        number_of_responses = len(rows_responses)

        form_data = {
            "text": message,
            "sender": sender
        }
        fill_form(cls.browser, form_data, True)
        cls.browser.find_by_css("input[type=submit]").first.click()
        return number_of_responses
    def assert_that_poll_end_date_is_none(self, poll_id):
        SplinterWrapper.open('/mypolls/%s' % poll_id)

        elements = self.browser.find_by_xpath('//*[@class="results"]')
        tbody = elements.first.find_by_tag('tbody')
        trs = tbody.find_by_tag('tr')
        view_poll_link = '/view_poll/%s/' % poll_id
        for tr in trs:
            element = tr.find_by_xpath('//*[@href="%s"]' % view_poll_link).first
            if element is not None:
                start_date = date.today().strftime("%d/%m/%Y")
                self.assertTrue(tr.find_by_value(start_date) is not None)
    def assert_that_poll_end_date_is_none(self, poll_id):
        SplinterWrapper.open('/mypolls/%s' % poll_id)

        elements = self.browser.find_by_xpath('//*[@class="results"]')
        tbody = elements.first.find_by_tag('tbody')
        trs = tbody.find_by_tag('tr')
        view_poll_link = '/view_poll/%s/' % poll_id
        for tr in trs:
            element = tr.find_by_xpath('//*[@href="%s"]' %
                                       view_poll_link).first
            if element is not None:
                start_date = date.today().strftime("%d/%m/%Y")
                self.assertTrue(tr.find_by_value(start_date) is not None)
    def test_that_a_poll_response_can_be_reassigned_to_another_poll(self):
        second_poll_id = PollBase.create_poll(self.browser,name='Second Poll',type="Yes/No Question",question="Is the first poll working?",group="groupFT")
        PollBase.start_poll(self.browser,second_poll_id)

        PollBase.respond_to_the_started_poll("0794339344", "yes")
        PollBase.close_poll(second_poll_id)

        PollBase.reassign_poll_response(second_poll_id,self.poll_id)
        time.sleep(2) #Takes a time for a poll to be reassigned
        PollBase.start_poll(self.browser,self.poll_id)

        SplinterWrapper.open('/polls/%s/report/' % self.poll_id)
        self.assert_that_number_of_responses_is(1)
Ejemplo n.º 23
0
 def create_contact(cls, browser, name, gender, backend_name, identity, group):
     SplinterWrapper.open("/admin/rapidsms/contact/add/")
     form_data = {
         "id_name": name,
         "id_gender": gender,
         "id_birthdate_0": datetime.now().strftime("%Y-%m-%d"),
         "id_birthdate_1": "00:00:00",
         "id_reporting_location": ("%s" % REPORTING_LOCATION_ID_KAMAIBA),
         "id_connection_set-0-backend": backend_name,
         "id_connection_set-0-identity": identity,
         "id_groups": group
     }
     fill_form_and_submit(browser, form_data, "_save")
    def test_that_a_poll_response_can_be_reassigned_to_another_poll(self):
        second_poll_id = PollBase.create_poll(
            self.browser,
            name='Second Poll',
            type="Yes/No Question",
            question="Is the first poll working?",
            group="groupFT")
        PollBase.start_poll(self.browser, second_poll_id)

        PollBase.respond_to_the_started_poll("0794339344", "yes")
        PollBase.close_poll(second_poll_id)

        PollBase.reassign_poll_response(second_poll_id, self.poll_id)
        time.sleep(2)  #Takes a time for a poll to be reassigned
        PollBase.start_poll(self.browser, self.poll_id)

        SplinterWrapper.open('/polls/%s/report/' % self.poll_id)
        self.assert_that_number_of_responses_is(1)
 def assert_that_poll_start_date_is_not_none(self, poll_id):
     SplinterWrapper.open('/mypolls/%s' % poll_id)
     start_date = self.browser.find_by_xpath(
         '//*[@class="results"]/tbody/tr[2]/td[3]')
     date_today = date.today().strftime("%d/%m/%Y")
     self.assertEquals(start_date.text, date_today)
 def assert_that_number_of_responses_increase_by(self, number_of_responses,
                                                 increment):
     SplinterWrapper.open('/router/console')
     rows_responses = rows_of_table_by_class(self.browser,
                                             "messages module")
     self.assertEqual(len(rows_responses), number_of_responses + increment)
 def assert_that_message_has_been_sent_out_to_ureporter(self, message):
     SplinterWrapper.open( "/router/console")
     element =self.browser.find_by_xpath("//table/tbody/tr/td[text()='%s']" % message)
     self.assertEquals(element.first.text, message)
Ejemplo n.º 28
0
 def reopen_poll(cls, browser, poll_id):
     SplinterWrapper.open("/view_poll/%s " % poll_id)
     browser.find_link_by_text('Reopen Poll').first.click()
 def test_admin_can_search_for_ureporter(self):
     group_name = "groupFT"
     self.respond_to_the_started_poll("0794339344", "yes")
     SplinterWrapper.open( '/reporter/')
     self.search_by_ureporter_group("%s" % group_name)
     self.assertEquals(True, self.browser.is_text_present("0794339344"))
 def test_that_admin_is_able_to_add_new_poll(self):
     SplinterWrapper.open('/mypolls/%s' % self.poll_id)
     self.assert_that_page_has_add_poll_button()
    def test_that_polls_can_be_responded(self):
        SplinterWrapper.open('/router/console/')
        number_of_responses = len(rows_of_table_by_class(self.browser, "messages module"))
        self.respond_to_the_started_poll("0794339344", "yes")

        self.assert_that_number_of_responses_increase_by(number_of_responses, 1)
 def assert_that_number_of_responses_increase_by(self, number_of_responses, increment):
     SplinterWrapper.open('/router/console')
     rows_responses = rows_of_table_by_class(self.browser, "messages module")
     self.assertEqual(len(rows_responses), number_of_responses + increment)
Ejemplo n.º 33
0
 def log_in_as_ureport(cls):
     SplinterWrapper.open('/accounts/login')
     if cls.browser.is_element_present_by_name("username"):
         cls.browser.fill("username", "ureport")
         cls.browser.fill("password", "ureport")
         cls.browser.find_by_css("input[type=submit]").first.click()
Ejemplo n.º 34
0
    def change_users_group(cls, group_name):
        SplinterWrapper.open("/admin/auth/user")
        cls.browser.click_link_by_text("ureport")

        fill_form_and_submit(cls.browser, {"id_groups": group_name}, "_save")
Ejemplo n.º 35
0
 def create_user(self, name, group):
     SplinterWrapper.open("/admin/auth/user/add/")
     fill_form_and_submit(self.browser, {"id_username": name, "id_password1": name, "id_password2": name}, "_save")
     fill_form_and_submit(self.browser, {"id_groups": group}, "_save")
Ejemplo n.º 36
0
 def create_group(cls, browser, name):
     SplinterWrapper.open("/admin/auth/group/add/")
     fill_form_and_submit(browser, {"id_name": name}, "_save")
Ejemplo n.º 37
0
 def get_poll_responses_ids(cls, browser, poll_id):
     SplinterWrapper.open("/%s/responses/" % poll_id)
     return browser.find_by_xpath(
         '//input[@type="checkbox" and @name="results"]')
 def test_that_poll_status_changes_when_started(self):
     SplinterWrapper.open("/poll_status/%s" % self.poll_id)
     self.assert_that_poll_start_date_is_not_none(self.poll_id)
 def assert_that_poll_start_date_is_not_none(self, poll_id):
     SplinterWrapper.open('/mypolls/%s' % poll_id)
     start_date = self.browser.find_by_xpath('//*[@class="results"]/tbody/tr[2]/td[3]')
     date_today = date.today().strftime("%d/%m/%Y")
     self.assertEquals(start_date.text, date_today)
    def test_that_polls_can_be_reopen(self):
        SplinterWrapper.open("/view_poll/%s" % self.poll_id)
        PollBase.close_poll(self.poll_id)
        self.browser.find_link_by_text('Reopen Poll').first.click()

        self.assert_that_poll_end_date_is_none(self.poll_id)
 def reopen_poll(cls,browser, poll_id):
     SplinterWrapper.open("/view_poll/%s " % poll_id)
     browser.find_link_by_text('Reopen Poll').first.click()
Ejemplo n.º 42
0
 def close_poll(cls, poll_id):
     SplinterWrapper.open("/view_poll/%s" % poll_id)
     if len(cls.browser.find_link_by_text('Close Poll')) > 0:
         cls.browser.find_link_by_text('Close Poll').first.click()
 def close_poll(cls, poll_id):
     SplinterWrapper.open("/view_poll/%s" % poll_id)
     if len(cls.browser.find_link_by_text('Close Poll')) > 0:
         cls.browser.find_link_by_text('Close Poll').first.click()
 def cleanup(cls, url):
     SplinterWrapper.open(url)
     if cls.browser.is_element_present_by_id("action-toggle"):
         fill_form(cls.browser, {"action-toggle": True})
         fill_form_and_submit(cls.browser, {"action": "delete_selected"}, "index", True, True)
         cls.browser.find_by_value("Yes, I'm sure").first.click()
 def get_poll_responses_ids(cls, browser, poll_id):
     SplinterWrapper.open("/%s/responses/" % poll_id)
     return browser.find_by_xpath('//input[@type="checkbox" and @name="results"]')
Ejemplo n.º 46
0
 def create_backend(cls, browser, name):
     SplinterWrapper.open("/admin/rapidsms/backend/add/")
     fill_form_and_submit(browser, {"id_name": name}, "_save")
 def assert_that_message_has_been_sent_out_to_ureporter(self, message):
     SplinterWrapper.open("/router/console")
     element = self.browser.find_by_xpath(
         "//table/tbody/tr/td[text()='%s']" % message)
     self.assertEquals(element.first.text, message)