Exemplo n.º 1
0
def test_img_list_gen_incorrect_ext():
    """test img_list_gen func but with incorrect extension."""
    m_ext = '.mp3'
    m_root = mock.Mock()
    m_file = mock.Mock()
    with mock.patch('melissa.actions.imgur_handler.os') as m_os:
        # pre run.
        m_os.walk.return_value = [(m_root, '', [m_file])]
        m_os.path.splitext.return_value = ['', m_ext]
        # run
        from melissa.actions import imgur_handler
        res = imgur_handler.img_list_gen()
        # test
        assert res == []
        m_os.assert_has_calls([
            mock.call.walk(M_IMAGES_PATH),
            mock.call.path.splitext(m_file)
        ])
Exemplo n.º 2
0
def test_img_list_gen(m_ext):
    """test img_list_gen func."""
    m_root = mock.Mock()
    m_file = mock.Mock()
    with mock.patch('melissa.profile_loader.load_profile'):
        with mock.patch('melissa.actions.imgur_handler.os') as m_os:
            # pre run.
            m_os.walk.return_value = [(m_root, '', [m_file])]
            m_os.path.splitext.return_value = ['', m_ext]
            # run
            from melissa.actions import imgur_handler
            imgur_handler.profile.data = {
                'images_path': M_IMAGES_PATH
            }
            res = imgur_handler.img_list_gen()
            # test
            m_os.assert_has_calls([
                mock.call.walk(M_IMAGES_PATH),
                mock.call.path.splitext(m_file),
                mock.call.path.join(m_root, m_file.lower.return_value)
            ])
            assert res == [m_os.path.join.return_value]