def test_find_iphone(self):
        """test find_iphone func.

        when given with all mocked dependencies,
        find_iphone will only give warning
        about there is no iphone in the given account.
        """
        m_text = mock.Mock()
        from melissa.actions 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:
            # run the func
            find_iphone.find_iphone(m_text)
            # testing.
            m_pc_service.assert_called_once_with(M_USERNAME, M_PASSWORD)
            m_tts.assert_called_once_with('No iPhones found in your account')
    def test_find_iphone(self):
        """test find_iphone func.

        when given with all mocked dependencies,
        find_iphone will only give warning
        about there is no iphone in the given account.
        """
        m_text = mock.Mock()
        from melissa.actions 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:
            # run the func
            find_iphone.find_iphone(m_text)
            # testing.
            m_pc_service.assert_called_once_with(M_USERNAME, M_PASSWORD)
            m_tts.assert_called_once_with("No iPhones found in your account")
def test_find_iphone():
    """test find_iphone func.

    when given with all mocked dependencies,
    find_iphone will only give warning
    about there is no iphone in the given account.
    """
    m_text = mock.Mock()
    with mock.patch('melissa.profile_loader.load_profile'):
        from melissa import profile
        profile.data = {
            'icloud': {'username': M_USERNAME, 'password': M_PASSWORD}}
        with mock.patch('melissa.actions.find_iphone.PyiCloudService') \
                as m_pc_service, \
                mock.patch('melissa.actions.find_iphone.tts') as m_tts:
            from melissa.actions import find_iphone
            find_iphone.profile.data = {
                'icloud': {'username': M_USERNAME, 'password': M_PASSWORD}}
            # run the func
            find_iphone.find_iphone(m_text)
            # testing.
            m_pc_service.assert_called_once_with(M_USERNAME, M_PASSWORD)
            m_tts.assert_called_once_with('No iPhones found in your account')
def test_find_iphone():
    """test find_iphone func.

    when given with all mocked dependencies,
    find_iphone will only give warning
    about there is no iphone in the given account.
    """
    m_text = mock.Mock()
    with mock.patch("melissa.profile_loader.load_profile"):
        from melissa import profile

        profile.data = {"icloud": {"username": M_USERNAME, "password": M_PASSWORD}}
        with mock.patch("melissa.actions.find_iphone.PyiCloudService") as m_pc_service, mock.patch(
            "melissa.actions.find_iphone.tts"
        ) as m_tts:
            from melissa.actions import find_iphone

            find_iphone.profile.data = {"icloud": {"username": M_USERNAME, "password": M_PASSWORD}}
            # run the func
            find_iphone.find_iphone(m_text)
            # testing.
            m_pc_service.assert_called_once_with(M_USERNAME, M_PASSWORD)
            m_tts.assert_called_once_with("No iPhones found in your account")