Пример #1
0
 def test_find_iphone_raise_failed_login(self):
     """test find iphone but raise failed login error."""
     m_text = mock.Mock()
     from melissa.actions.find_iphone import find_iphone
     with mock.patch('melissa.actions.find_iphone.PyiCloudService') \
             as m_pc_service, \
             mock.patch('melissa.actions.find_iphone.tts') as m_tts:
         m_pc_service.side_effect = PyiCloudFailedLoginException()
         # run
         find_iphone(m_text)
         # testing
         m_pc_service.assert_called_once_with(M_USERNAME, M_PASSWORD)
         m_tts.assert_called_once_with('Invalid Username & Password')
Пример #2
0
    def test_find_iphone_raise_failed_login(self):
        """test find iphone but raise failed login error."""
        m_text = mock.Mock()
        from melissa.actions.find_iphone import find_iphone

        with mock.patch("melissa.actions.find_iphone.PyiCloudService") as m_pc_service, mock.patch(
            "melissa.actions.find_iphone.tts"
        ) as m_tts:
            m_pc_service.side_effect = PyiCloudFailedLoginException()
            # run
            find_iphone(m_text)
            # testing
            m_pc_service.assert_called_once_with(M_USERNAME, M_PASSWORD)
            m_tts.assert_called_once_with("Invalid Username & Password")
Пример #3
0
 def test_find_iphone_with_a_phone(self):
     """test find_iphone func."""
     m_text = mock.Mock()
     m_device = mock.Mock()
     m_device.status.return_value = {'deviceDisplayName': 'iPhone'}
     from melissa.actions.find_iphone import find_iphone
     with mock.patch('melissa.actions.find_iphone.PyiCloudService') \
             as m_pc_service, \
             mock.patch('melissa.actions.find_iphone.tts') as m_tts:
         m_pc_service.return_value.devices = [m_device]
         # run the func
         find_iphone(m_text)
         # testing.
         m_pc_service.assert_called_once_with(M_USERNAME, M_PASSWORD)
         m_tts.assert_called_once_with(
             'Sending ring command to the phone now')
         m_device.status.assert_called_once_with()
         m_device.play_sound.assert_called_once_with()
Пример #4
0
    def test_find_iphone_with_a_phone(self):
        """test find_iphone func."""
        m_text = mock.Mock()
        m_device = mock.Mock()
        m_device.status.return_value = {"deviceDisplayName": "iPhone"}
        from melissa.actions.find_iphone import find_iphone

        with mock.patch("melissa.actions.find_iphone.PyiCloudService") as m_pc_service, mock.patch(
            "melissa.actions.find_iphone.tts"
        ) as m_tts:
            m_pc_service.return_value.devices = [m_device]
            # run the func
            find_iphone(m_text)
            # testing.
            m_pc_service.assert_called_once_with(M_USERNAME, M_PASSWORD)
            m_tts.assert_called_once_with("Sending ring command to the phone now")
            m_device.status.assert_called_once_with()
            m_device.play_sound.assert_called_once_with()