@@ -0,0 +1,2284 @@
+# -*- coding: UTF-8 -*-%0D%0A%22%22%22%0D%0ATests for pyftpsync%0D%0A%22%22%22%0D%0Afrom __future__ import print_function%0D%0A%0D%0Aimport os%0D%0Aimport sys%0Aimport unittest%0D%0A%0D%0Afrom ftpsync import pyftpsync, __version__%0Afrom test.fixture_tools import _SyncTestBase, PYFTPSYNC_TEST_FOLDER%0D%0A%0D%0A%0Atry:%0A    from io import StringIO%0Aexcept ImportError:%0A    from cStringIO import StringIO%0A%0A%0Aclass Capturing(list):%0A    def __enter__(self):%0A        self._stdout = sys.stdout%0A        sys.stdout = self._stringio = StringIO()%0A        return self%0A    def __exit__(self, *args):%0A        self.extend(self._stringio.getvalue().splitlines())%0A        del self._stringio    # free up some memory%0A        sys.stdout = self._stdout%0A%0A%0Adef run_script(*args, expect_code=0, **kw):%0A    %22%22%22Run %60pyftpsync args%60 and return (errcode, output).%22%22%22%0A    pyftpsync.sys.argv = %5B%22pyftpsync_dummy%22%5D + list(args)%0A    # print(%22S%22, sys.argv)%0A    errcode = 0%0A    out = %5B%5D%0A    try:%0A        with Capturing() as out:%0A            pyftpsync.run()%0A    except SystemExit as e:%0A        errcode = e.code%0A%0A    if expect_code is not None:%0A        assert errcode == expect_code%0A%0A    return %22%5Cn%22.join(out).strip()%0A%0A%0D%0A#===============================================================================%0D%0A# ScriptTest%0D%0A#===============================================================================%0D%0A%0D%0Aclass ScriptTest(_SyncTestBase):%0D%0A    %22%22%22Test command line script interface.%22%22%22%0D%0A%0D%0A    def setUp(self):%0D%0A        # Call self._prepare_initial_synced_fixture():%0D%0A        super(ScriptTest, self).setUp()%0D%0A%0D%0A    def tearDown(self):%0D%0A        super(ScriptTest, self).tearDown()%0D%0A%0D%0A    def test_basic(self):%0A        out = run_script(%22--version%22)%0A        # self.assertEqual(errcode, 0)%0D%0A        self.assertEqual(out, __version__)%0A%0A        out = run_script(%22--help%22)%0A        assert %22usage: pyftpsync%22 in out%0A%0A        out = run_script(%22foobar%22, expect_code=2)%0A%0A    def test_scan_list(self):%0A        out = run_script(%22scan%22, os.path.join(PYFTPSYNC_TEST_FOLDER, %22local%22), %22--list%22)%0A        assert %22file1.txt                                2014-01-01 13:00:00%22 in out%0A%0D%0A%0D%0A#===============================================================================%0D%0A# Main%0D%0A#===============================================================================%0D%0Aif __name__ == %22__main__%22:%0D%0A    unittest.main()%0D%0A

Add tests for command line script