root/_test_ftp_sync.py @ 838:1ada264aac33

Revision 838:1ada264aac33, 2.7 kB (checked in by Stefan Schwarzer <sschwarzer@…>, 7 months ago)
Fixed copyright notice.
Line 
1# Copyright (C) 2007-2010, Stefan Schwarzer
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7#
8# - Redistributions of source code must retain the above copyright
9#   notice, this list of conditions and the following disclaimer.
10#
11# - Redistributions in binary form must reproduce the above copyright
12#   notice, this list of conditions and the following disclaimer in the
13#   documentation and/or other materials provided with the distribution.
14#
15# - Neither the name of the above author nor the names of the
16#   contributors to the software may be used to endorse or promote
17#   products derived from this software without specific prior written
18#   permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
24# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32# $Id$
33
34import os
35import shutil
36import sys
37import unittest
38
39import ftp_sync
40
41
42# assume the test subdirectories are or will be in the current directory
43TEST_ROOT = os.getcwd()
44
45
46class TestLocalToLocal(unittest.TestCase):
47    def setUp(self):
48        if not os.path.exists("test_empty"):
49            os.mkdir("test_empty")
50        if os.path.exists("test_target"):
51            shutil.rmtree("test_target")
52        os.mkdir("test_target")
53
54    def test_sync_empty_dir(self):
55        source = ftp_sync.LocalHost()
56        target = ftp_sync.LocalHost()
57        syncer = ftp_sync.Syncer(source, target)
58        source_dir = os.path.join(TEST_ROOT, "test_empty")
59        target_dir = os.path.join(TEST_ROOT, "test_target")
60        syncer.sync(source_dir, target_dir)
61
62    def test_source_with_and_target_without_slash(self):
63        source = ftp_sync.LocalHost()
64        target = ftp_sync.LocalHost()
65        syncer = ftp_sync.Syncer(source, target)
66        source_dir = os.path.join(TEST_ROOT, "test_source/")
67        target_dir = os.path.join(TEST_ROOT, "test_target")
68        syncer.sync(source_dir, target_dir)
69
70
71if __name__ == '__main__':
72    unittest.main()
Note: See TracBrowser for help on using the browser.