def test_no_input(self):
        """test no input when main func called.

        program will exit for this case.
        """
        with pytest.raises(SystemExit):
            redditdownload.main()
    def test_update_flag(self, mock_get_items, mock_download_func):
        """test update flag.
        
        it test if update flag is raised properly and if get_items func will call twice,
        because download_func only raise FileExistsException."""
        test_argv = ['redditdl.py', 'cats', '--num', '2', '--update']
        with patch.object(sys, 'argv', test_argv):
            # run the main function.
            redditdownload.main()

            # assert the call count
            assert mock_get_items.call_count == 1
            assert mock_download_func.call_count == 2

            # change side effect to raise error
            err_txt = 'Expected Error on testing'
            mock_download_func.side_effect = redditdownload.FileExistsException(
                err_txt)
            # run the main func.
            redditdownload.main()

            # assert the call count
            assert mock_get_items.call_count == 2
            # one further download attempt is made, stopped by FileExistsException
            assert mock_download_func.call_count == 3
Example #3
0
#!/usr/bin/env python
# coding: utf8
"""
Repo-root entry script.

Not named 'redditdownload.py' because it would horribly conflict with
the package name.
"""

from redditdownload.redditdownload import main

if __name__ == '__main__':
    main()
Example #4
0
#!/usr/bin/env python
# coding: utf8
"""
Repo-root entry script.

Not named 'redditdownload.py' because it would horribly conflict with
the package name.
"""

from redditdownload.redditdownload import main


if __name__ == '__main__':
    main()
Example #5
0
#!/usr/bin/env python
# coding: utf8
"""
Repo-root entry script.

Not named 'redditdownload.py' because it would horribly conflict with
the package name.
"""

from redditdownload.redditdownload import main

if __name__ == '__main__':
    main("")