Beispiel #1
0
    def test_phone_label_save(self):
        contact_editor = self.app.main_window.go_to_add_contact()

        my_phones = []
        my_phones.append(data.Phone(type_="Home", number="(000) 000-0000"))
        my_phones.append(data.Phone(type_="Work", number="(000) 000-0001"))
        my_phones.append(data.Phone(type_="Mobile", number="(000) 000-0002"))
        my_phones.append(
            data.Phone(type_="Work Mobile", number="(000) 000-0003"))
        my_phones.append(data.Phone(type_="Other", number="(000) 000-0004"))

        test_contact = data.Contact(first_name="Sherlock",
                                    last_name="Holmes",
                                    phones=my_phones)
        contact_editor.fill_form(test_contact)

        # Save contact
        self.app.main_window.save()

        # Open contact view
        list_page = self.app.main_window.get_contact_list_page()
        view_page = list_page.open_contact(0)
        self.assertThat(view_page.visible, Eventually(Equals(True)))

        # check if we have five phones"""
        phone_group = view_page.select_single("ContactDetailGroupWithTypeView",
                                              objectName="phones")
        self.assertThat(phone_group.detailsCount, Eventually(Equals(5)))

        phones = {
            "(000) 000-0000": "Home",
            "(000) 000-0001": "Work",
            "(000) 000-0002": "Mobile",
            "(000) 000-0003": "Work Mobile",
            "(000) 000-0004": "Other"
        }

        # Check if they have the correct label
        for idx in range(5):
            phone_type = view_page.select_single(
                "UCLabel", objectName="type_phoneNumber_" + str(idx))

            phone_label = view_page.select_single(
                "UCLabel", objectName="label_phoneNumber_" + str(idx) + ".0")

            self.assertThat(phones[phone_label.text], Equals(phone_type.text))
            del phones[phone_label.text]

        self.assertThat(len(phones), Equals(0))
Beispiel #2
0
    def test_add_contact_with_name_and_phone(self):
        test_contact = data.Contact(first_name='Fulano',
                                    last_name='de Tal',
                                    phones=[data.Phone.make()])

        # execute add new contact
        contact_editor = self.app.main_window.go_to_add_contact()
        contact_editor.fill_form(test_contact)

        # Save contact
        self.app.main_window.save()

        # Check if contact was added
        list_view = self.app.main_window.get_contact_list_view()
        self.assertThat(list_view.count, Eventually(Equals(1)))
    def _get_form_values(self):
        first_name = _get_text_field(self, 'first_name').text
        last_name = _get_text_field(self, 'last_name').text
        phones = self._get_values_from_detail_group(object_name='phones')
        emails = self._get_values_from_detail_group(object_name='emails')
        social_aliases = self._get_values_from_detail_group(object_name='ims')
        addresses = self._get_values_from_detail_group(object_name='addresses')
        professional_details = self._get_values_from_detail_group(
            object_name='professionalDetails')

        return data.Contact(first_name=first_name,
                            last_name=last_name,
                            phones=phones,
                            emails=emails,
                            social_aliases=social_aliases,
                            addresses=addresses,
                            professional_details=professional_details)
Beispiel #4
0
    def test_email_label_save(self):
        contact_editor = self.app.main_window.go_to_add_contact()

        my_emails = []
        my_emails.append(data.Email(type_="Home", address="*****@*****.**"))
        my_emails.append(data.Email(type_="Work", address="*****@*****.**"))
        my_emails.append(data.Email(type_="Other", address="*****@*****.**"))

        test_contact = data.Contact(first_name="Sherlock",
                                    last_name="Holmes",
                                    emails=my_emails)
        contact_editor.fill_form(test_contact)

        # Save contact
        self.app.main_window.save()

        list_page = self.app.main_window.get_contact_list_page()
        view_page = list_page.open_contact(0)
        self.assertThat(view_page.visible, Eventually(Equals(True)))

        # check if we have 3 emails"""
        email_group = view_page.select_single("ContactDetailGroupWithTypeView",
                                              objectName="emails")
        self.assertThat(email_group.detailsCount, Eventually(Equals(3)))

        emails = {
            "*****@*****.**": "Home",
            "*****@*****.**": "Work",
            "*****@*****.**": "Other"
        }

        # Check if they have the correct label
        for idx in range(3):
            email_type = view_page.select_single("UCLabel",
                                                 objectName="type_email_" +
                                                 str(idx))

            email_label = view_page.select_single(
                "UCLabel", objectName="label_emailAddress_" + str(idx) + ".0")

            self.assertThat(emails[email_label.text], Equals(email_type.text))
            del emails[email_label.text]

        self.assertThat(len(emails), Equals(0))
Beispiel #5
0
    def test_add_new_contact_from_log(self):
        """Ensure tapping on 'add new contact' item of a call log opens
        the address-book app to allow adding new contact.

        """
        delegate = self.main_view.wait_select_single(
            ListItemWithActions.HistoryDelegate, objectName='historyDelegate0')
        delegate.add_contact()

        contacts_page = self.main_view.contacts_page
        self.assertThat(
            contacts_page.phoneToAdd, Eventually(Equals('800')))

        # click add new button
        contacts_page.click_add_new()

        # wait page be ready for edit
        contact_editor_page = self.main_view.contact_editor_page
        self.main_view.contact_editor_page.wait_get_focus('phones')

        # fill contact name
        test_contact = data.Contact('FirstName', 'LastName')
        test_contact.professional_details = []
        contact_editor_page.fill_form(test_contact)

        # save contact
        contact_editor_page.save()

        # contact view will appear with the new contact data
        contact_view_page = contacts_page.open_contact(3)
        self.assertThat(contact_view_page.visible, Eventually(Equals(True)))

        # check if contact contains the new phone number
        phone_group = contact_view_page.select_single(
            'ContactDetailGroupWithTypeView',
            objectName='phones')
        self.assertThat(phone_group.detailsCount, Eventually(Equals(1)))

        # check if the new value is correct
        phone_label_1 = contact_view_page.select_single(
            "UCLabel",
            objectName="label_phoneNumber_0.0")
        self.assertThat(phone_label_1.text, Eventually(Equals('800')))