Пример #1
0
  def DeleteNote(self, version_info, session_info, screen_info, note):
    version_info, session_info, screen_info, _ = self.SelectNote(version_info, session_info, screen_info, note)
    
    # Click on Delete image.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=['note_frame', 'delete_image'], method=fase.ON_CLICK_METHOD,
                                   device=self.device),
        version_info, session_info, screen_info)
    version_info = response.version_info
    session_info = response.session_info
    screen_info = response.screen_info
    screen = response.screen
    # Check present of main elements.
    screen.GetElement(id_=fase.ALERT_ID)
    # Click on Yes.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=[fase.ALERT_ID, 'ok_id'], method=fase.ON_CLICK_METHOD, device=self.device),
        version_info, session_info, screen_info)
    version_info = response.version_info
    session_info = response.session_info
    screen_info = response.screen_info
    screen = response.screen
    # Check present of main elements.
    screen.GetElement(id_='notes_frame')

    return version_info, session_info, screen_info, screen
Пример #2
0
  def AddNote(self, version_info, session_info, screen_info, note):
    # Click on New button.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=[fase.MAIN_BUTTON_ID], method=fase.ON_CLICK_METHOD, device=self.device),
        version_info, session_info, screen_info)
    version_info = response.screen_info
    session_info = response.session_info
    screen_info = response.screen_info
    screen = response.screen
    # Check present of main elements.
    screen.GetElement(id_='note_frame')

    # Enter note.
    elements_update=fase_model.ElementsUpdate([['note_frame', 'header_text'],
                                               ['note_frame', 'text_text']], [note.header,
                                                                              note.text])
    screen_update = fase_model.ScreenUpdate(elements_update=elements_update, device=self.device)
    fase_server.FaseServer.Get().ScreenUpdate(screen_update, version_info, session_info, screen_info)

    # Click on Save button.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=[fase.NEXT_STEP_BUTTON_ID], method=fase.ON_CLICK_METHOD, device=self.device),
        version_info, session_info, screen_info)
    version_info = response.screen_info
    session_info = response.session_info
    screen_info = response.screen_info
    screen = response.screen
    # Check present of main elements.
    screen.GetElement(id_='notes_frame')

    return version_info, session_info, screen_info, screen
Пример #3
0
    def testService(self):
        device = fase_model.Device(device_type='MockType',
                                   device_id='MockDeviceID')
        response = self._GetService(device)
        session_info = response.session_info
        screen_info = response.screen_info
        service_prog = fase_database.FaseDatabaseInterface.Get(
        ).GetServiceProg(session_info.session_id)
        expected_screen = ApplicationTest._GetEnterNameScreen(
            service_prog.service)
        expected_screen._screen_id = screen_info.screen_id
        self.assertEqual(expected_screen, response.screen)
        response = self._GetScreen(device, session_info)
        self.assertEqual(expected_screen, response.screen)

        elements_update = fase_model.ElementsUpdate([['text_name_id']],
                                                    ['Hanry Ford'])
        screen_update = fase_model.ScreenUpdate(
            elements_update=elements_update, device=device)
        response = self._ScreenUpdate(screen_update, session_info, screen_info)
        expected_screen = ApplicationTest._GetEnterNameScreen(
            service_prog.service, name='Hanry Ford')
        expected_screen._screen_id = screen_info.screen_id
        self.assertIsNone(response.screen)
        response = self._GetScreen(device, session_info)
        self.assertEqual(expected_screen, response.screen)

        element_callback = (fase_model.ElementCallback(
            id_list=['next_button_id'],
            method=fase.ON_CLICK_METHOD,
            device=device))
        response = self._ElementCallback(element_callback, session_info,
                                         screen_info)
        screen_info = response.screen_info
        expected_screen = ApplicationTest._GetGreetingScreen(
            service_prog.service, name='Hanry Ford')
        expected_screen._screen_id = screen_info.screen_id
        self.assertEqual(expected_screen, response.screen)
        response = self._GetScreen(device, session_info)
        self.assertEqual(expected_screen, response.screen)

        element_callback = (fase_model.ElementCallback(
            id_list=['reset_button_id'],
            method=fase.ON_CLICK_METHOD,
            device=device))
        response = self._ElementCallback(element_callback, session_info,
                                         screen_info)
        screen_info = response.screen_info
        expected_screen = ApplicationTest._GetEnterNameScreen(
            service_prog.service)
        expected_screen._screen_id = screen_info.screen_id
        self.assertEqual(expected_screen, response.screen)
        response = self._GetScreen(device, session_info)
        self.assertEqual(expected_screen, response.screen)
Пример #4
0
    def testServiceElementCallbackDeviceVersionObsolete(self):
        previous_version = ServerTestService.version
        ServerTestService.version = '2'

        device = fase_model.Device(device_type='MockType',
                                   device_id='MockDeviceID')
        version_info, session_info, screen_info_entered_name = self._GetServiceAndAssert(
            device)
        self._EnterNameAndAssert('Henry Ford', device, version_info,
                                 session_info, screen_info_entered_name)
        screen_info_clicked_next = self._EnterNextAndAssert(
            'Henry Ford', device, version_info, session_info,
            screen_info_entered_name)

        version_info = fase_model.VersionInfo(version=previous_version)

        element_callback = (fase_model.ElementCallback(
            id_list=['next_button_id'],
            method=fase.ON_CLICK_METHOD,
            device=device))
        response_updated = fase_server.FaseServer.Get().ElementCallback(
            element_callback, version_info, session_info,
            screen_info_entered_name)
        self._AssertDeviceUpdateScreen(response_updated, session_info,
                                       screen_info_clicked_next)

        ServerTestService.version = previous_version
Пример #5
0
    def testServiceElementCallbackScreenInfoObsolete(self):
        device = fase_model.Device(device_type='MockType',
                                   device_id='MockDeviceID')
        version_info, session_info, screen_info_entered_name = self._GetServiceAndAssert(
            device)
        self._EnterNameAndAssert('Henry Ford', device, version_info,
                                 session_info, screen_info_entered_name)
        screen_info_clicked_next = self._EnterNextAndAssert(
            'Henry Ford', device, version_info, session_info,
            screen_info_entered_name)

        screen_prog_clicked_next = fase_database.FaseDatabaseInterface.Get(
        ).GetScreenProg(session_info.session_id)
        screen_clicked_next = screen_prog_clicked_next.screen

        element_callback = (fase_model.ElementCallback(
            id_list=['next_button_id'],
            method=fase.ON_CLICK_METHOD,
            device=device))
        response_click_again = fase_server.FaseServer.Get().ElementCallback(
            element_callback, version_info, session_info,
            screen_info_entered_name)
        self.assertEqual(screen_clicked_next, response_click_again.screen)
        expected_resources = fase_model.Resources(
            resource_list=[fase_model.Resource(filename=self.hello_filename)])
        self.assertEqual(set(expected_resources.resource_list),
                         set(response_click_again.resources.resource_list))
        self.assertIsNone(response_click_again.elements_update)
        self.assertEqual(session_info, response_click_again.session_info)
        self.assertEqual(screen_info_clicked_next,
                         response_click_again.screen_info)
Пример #6
0
  def testNotes_Start_SignIn_Navigation(self):
    version_info, session_info, screen_info, screen = self.Start()
    self.AssertNotes([], screen)

    # Sign In.
    version_info, session_info, screen_info, screen = (
        fase_sign_in_test_util.SignInProcedure(
            version_info, session_info, screen_info,
            sign_in_id_list=[fase.NAVIGATION_ID, 'sign_in_button'], sign_in=True, phone_number='+13216549870'))
    self.AssertNotes([self.note_1, self.note_2, self.note_3], screen)

    # Click on Notes button.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=[fase.NAVIGATION_ID, 'notes_button'], method=fase.ON_CLICK_METHOD,
                                   device=self.device),
        version_info, session_info, screen_info)
    screen_info = response.screen_info
    screen = response.screen
    self.AssertNotes([self.note_1, self.note_2, self.note_3], screen)

    # Click on Favourites button.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=[fase.NAVIGATION_ID, 'favourites_button'], method=fase.ON_CLICK_METHOD,
                                   device=self.device),
        version_info, session_info, screen_info)
    screen_info = response.screen_info
    screen = response.screen
    self.AssertNotes([self.note_2], screen)

    # Click on Recent button.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=[fase.NAVIGATION_ID, 'recent_button'], method=fase.ON_CLICK_METHOD,
                                   device=self.device),
        version_info, session_info, screen_info)
    screen_info = response.screen_info
    screen = response.screen
    self.AssertNotes([self.note_1, self.note_3, self.note_2], screen)

    # Click on Notes button again.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=[fase.NAVIGATION_ID, 'notes_button'], method=fase.ON_CLICK_METHOD,
                                   device=self.device),
        version_info, session_info, screen_info)
    screen_info = response.screen_info
    screen = response.screen
    self.AssertNotes([self.note_1, self.note_2, self.note_3], screen)
Пример #7
0
 def ElementCallback(self, element_callback, session_info, screen_info):
   self.element_callback_calls += 1
   expected_element_callback = fase_model.ElementCallback(
       elements_update=self.expected_elements_update, id_list=self.expected_id_list, method=fase.ON_CLICK_METHOD,
       device=self.device)
   self.test_obj.assertEqual(expected_element_callback, element_callback)
   self.test_obj.assertEqual(self.session_info, session_info)
   self.test_obj.assertEqual(self.screen_info, screen_info)
   return fase_model.Response(screen=self.element_callback_screen,
                              resources=self.element_callback_resources,
                              elements_update=self.element_callback_elements_update,
                              session_info=self.element_callback_session_info,
                              screen_info=self.element_callback_screen_info)
Пример #8
0
  def ReverseFavouriteNote(self, version_info, session_info, screen_info, note):
    version_info, session_info, screen_info, _ = self.SelectNote(version_info, session_info, screen_info, note)

    # Click on Favourite image.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=['note_frame', 'favourite_image'], method=fase.ON_CLICK_METHOD,
                                   device=self.device),
        version_info, session_info, screen_info)
    version_info = response.version_info
    session_info = response.session_info
    screen_info = response.screen_info

    # Click on Save button.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=[fase.NEXT_STEP_BUTTON_ID], method=fase.ON_CLICK_METHOD, device=self.device),
        version_info, session_info, screen_info)
    version_info = response.version_info
    session_info = response.session_info
    screen_info = response.screen_info
    screen = response.screen
    # Check present of main elements.
    screen.GetElement(id_='notes_frame')

    return version_info, session_info, screen_info, screen
Пример #9
0
  def SelectNote(self, version_info, session_info, screen_info, note):
    # Click on the Note.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(
            id_list=['notes_frame', 'note_frame_%s' % note.note_id], method=fase.ON_CLICK_METHOD, device=self.device),
        version_info, session_info, screen_info)
    version_info = response.version_info
    session_info = response.session_info
    screen_info = response.screen_info
    screen = response.screen
    # Check present of main elements and content.
    screen.GetElement(id_='note_frame')
    self.assertEqual(note.header, screen.GetElement(id_='note_frame').GetElement(id_='header_text').GetText())
    self.assertEqual(note.text, screen.GetElement(id_='note_frame').GetElement(id_='text_text').GetText())

    return version_info, session_info, screen_info, screen
Пример #10
0
    def testServiceElementCallbackWithElementsUpdate(self):
        device = fase_model.Device(device_type='MockType',
                                   device_id='MockDeviceID')
        version_info, session_info, screen_info = self._GetServiceAndAssert(
            device)

        elements_update = fase_model.ElementsUpdate([['text_name_id']],
                                                    ['Henry Ford'])
        element_callback = fase_model.ElementCallback(
            elements_update=elements_update,
            id_list=['next_button_id'],
            method=fase.ON_CLICK_METHOD,
            device=device)
        response = fase_server.FaseServer.Get().ElementCallback(
            element_callback, version_info, session_info, screen_info)
        screen_info = response.screen_info
        service_prog = fase_database.FaseDatabaseInterface.Get(
        ).GetServiceProg(session_info.session_id)
        expected_screen = FaseServerTest._GetGreetingScreen(
            service_prog.service, 'Henry Ford')
        expected_screen._screen_id = screen_info.screen_id
        self.assertEqual(expected_screen, response.screen)
        expected_resources = fase_model.Resources(
            resource_list=[fase_model.Resource(filename=self.hello_filename)])
        self.assertEqual(set(expected_resources.resource_list),
                         set(response.resources.resource_list))
        self.assertFalse(response.resources.reset_resources)
        self.assertIsNone(response.elements_update)
        self.assertEqual(session_info, response.session_info)

        self._GetScreenProgAndAssert(session_info,
                                     expected_screen=expected_screen,
                                     expected_device=device)
        self._GetScreenAndAssert(device,
                                 version_info,
                                 session_info,
                                 screen_info,
                                 expected_screen=expected_screen,
                                 expected_resources=expected_resources)

        self._EnterResetAndAssert(device, version_info, session_info,
                                  screen_info)
Пример #11
0
 def ProcessResponse(self, response):
   if response.resources:
     self.resource_manager.PreloadResources(response.resources)
   while response.screen is not None and response.screen.HasElement(id_=fase.ALERT_ID):
     alert = response.screen.PopElement(id_=fase.ALERT_ID)
     id_list, method = self.ui.ShowAlert(alert)
     element_callback = fase_model.ElementCallback(id_list=id_list, method=method, device=self.device)
     response = self.http_client.ElementCallback(element_callback, response.session_info, response.screen_info)
     if response.resources:
       self.resource_manager.PreloadResources(response.resources)
   self.session_info = response.session_info
   self.screen_info = response.screen_info
   SaveSessionInfoIfNeeded(self.session_info_filepath, response.session_info)
   if response.screen:
     self.screen = response.screen
     self.ui.DrawScreen(response.screen)
     return True  # Screen has been updated.
   elif response.elements_update:
     self.elements_update = response.elements_update 
     self._ElementsUpdateReceived(fase_model.ElementsUpdateToDict(response.elements_update))
   return False  # Screen is the same.
Пример #12
0
    def _EnterNextAndAssert(self,
                            name,
                            device,
                            version_info,
                            session_info,
                            screen_info,
                            get_screen_and_assert=True):
        element_callback = (fase_model.ElementCallback(
            id_list=['next_button_id'],
            method=fase.ON_CLICK_METHOD,
            device=device))
        response = fase_server.FaseServer.Get().ElementCallback(
            element_callback, version_info, session_info, screen_info)
        screen_info = response.screen_info
        service_prog = fase_database.FaseDatabaseInterface.Get(
        ).GetServiceProg(session_info.session_id)
        expected_screen = FaseServerTest._GetGreetingScreen(
            service_prog.service, name)
        expected_screen._screen_id = screen_info.screen_id
        self.assertEqual(expected_screen, response.screen)
        expected_resources = fase_model.Resources(
            resource_list=[fase_model.Resource(filename=self.hello_filename)])
        self.assertEqual(set(expected_resources.resource_list),
                         set(response.resources.resource_list))
        self.assertFalse(response.resources.reset_resources)
        self.assertIsNone(response.elements_update)
        self.assertEqual(session_info, response.session_info)

        self._GetScreenProgAndAssert(session_info,
                                     expected_screen=expected_screen,
                                     expected_device=device)
        if get_screen_and_assert:
            self._GetScreenAndAssert(device,
                                     version_info,
                                     session_info,
                                     screen_info,
                                     expected_screen=expected_screen,
                                     expected_resources=expected_resources)
        return screen_info
Пример #13
0
  def testNotes_Start_SignIn_EditNote_Cancel(self):
    version_info, session_info, screen_info, screen = self.Start()
    self.AssertNotes([], screen)

    # Sign In.
    version_info, session_info, screen_info, screen = (
        fase_sign_in_test_util.SignInProcedure(
            version_info, session_info, screen_info,
            sign_in_id_list=[fase.NAVIGATION_ID, 'sign_in_button'], sign_in=True, phone_number='+13216549870'))
    self.AssertNotes([self.note_1, self.note_2, self.note_3], screen)

    # Copy and edit Note.
    note_2_edited = copy.copy(self.note_2)
    note_2_edited.header = 'Note 2 Header edited'
    note_2_edited.text = 'Note 2 text edited'

    version_info, session_info, screen_info, screen = self.SelectNote(
        version_info, session_info, screen_info, self.note_2)

    # Edit Note.
    elements_update=fase_model.ElementsUpdate([['note_frame', 'header_text'],
                                               ['note_frame', 'text_text']], [note_2_edited.header,
                                                                              note_2_edited.text])
    screen_update = fase_model.ScreenUpdate(elements_update=elements_update, device=self.device)
    fase_server.FaseServer.Get().ScreenUpdate(screen_update, version_info, session_info, screen_info)

    # Click on Cancel button.
    response = fase_server.FaseServer.Get().ElementCallback(
        fase_model.ElementCallback(id_list=[fase.PREV_STEP_BUTTON_ID], method=fase.ON_CLICK_METHOD, device=self.device),
        version_info, session_info, screen_info)
    version_info = response.version_info 
    session_info = response.session_info
    screen_info = response.screen_info
    screen = response.screen
    # Check present of main elements.
    screen.GetElement(id_='notes_frame')
    self.AssertNotes([self.note_1, self.note_2, self.note_3], screen)
Пример #14
0
 def _GetElementCallback(self, elements_update, id_list, method):
   element = fase_model.GetScreenElement(self.screen, id_list)
   locale = fase.Locale(country_code=COUNTRY_CODE) if element.GetRequestLocale() else None
   return fase_model.ElementCallback(
       elements_update=elements_update, id_list=id_list, method=method, device=self.device, locale=locale)