# -*- coding: utf-8 -*-
"""
Tests for pyftpsync
"""
from __future__ import print_function

import platform
import unittest
from unittest.case import SkipTest

from ftpsync import targets
from ftpsync.ftp_target import FtpTarget
from ftpsync.synchronizers import DownloadSynchronizer
from ftpsync.compat import urlparse
from test.fixture_tools import PYFTPSYNC_TEST_FTP_URL

on_windows = platform.system() == "Windows"


# ===============================================================================
# FtpTest
# ===============================================================================
class RegressionTest(unittest.TestCase):
    """Test basic ftplib.FTP functionality."""
    def setUp(self):
        # Remote URL, e.g. "ftps://user:password@example.com/my/test/folder"
        ftp_url = PYFTPSYNC_TEST_FTP_URL
        if not ftp_url:
            raise SkipTest("Must configure an FTP target "
                           "(environment variable PYFTPSYNC_TEST_FTP_URL)")

        parts = urlparse(ftp_url, allow_fragments=False)
        # self.assertIn(parts.scheme.lower(), ["ftp", "ftps"])
        self.host = parts.netloc.split("@", 1)[1]
        self.path = parts.path
        self.username = parts.username
        self.password = parts.password
        self.remote = None

    def tearDown(self):
        if self.remote:
            self.remote.close()
            self.remote = None

    def test_issue_5(self):
        """issue #5: Unable to navigate to working directory '' (Windows)"""
        if not on_windows:
            raise SkipTest("Windows only.")
        local = targets.FsTarget("c:/temp")
        remote = FtpTarget("/", "www.example.com", None, self.username, self.password)
        opts = {
            "resolve": "remote",
            "verbose": 3,
            "dry_run": True,
            }
        s = DownloadSynchronizer(local, remote, opts)
        s.run()


# ===============================================================================
# Main
# ===============================================================================
if __name__ == "__main__":
    unittest.main()

@@ -156,132 +156,8 @@
 st%0A%0A
-from ftpsync import targets%0Afrom ftpsync.ftp_target import FtpTarget%0Afrom ftpsync.synchronizers import DownloadSynchronizer%0A
 from
@@ -1268,24 +1268,26 @@
  = None%0A%0A   
+ #
  def test_is
@@ -1298,24 +1298,26 @@
 5(self):%0A   
+ #
      %22%22%22issu
@@ -1377,24 +1377,26 @@
 dows)%22%22%22%0A   
+ #
      if not 
@@ -1407,32 +1407,33 @@
 indows:%0A    
+#
         
 raise SkipTe
@@ -1412,32 +1412,33 @@
 s:%0A    #        
+ 
 raise SkipTest(%22
@@ -1452,24 +1452,26 @@
  only.%22)%0A   
+ #
      local =
@@ -1498,24 +1498,26 @@
 :/temp%22)%0A   
+ #
      remote 
@@ -1592,20 +1592,22 @@
 rd)%0A    
+#
     
+ 
 opts = %7B
@@ -1606,24 +1606,26 @@
 opts = %7B%0A   
+ #
          %22re
@@ -1646,24 +1646,25 @@
 e%22,%0A    
+#
         
 %22verbose
@@ -1655,16 +1655,17 @@
         
+ 
 %22verbose
@@ -1669,24 +1669,26 @@
 ose%22: 3,%0A   
+ #
          %22dr
@@ -1700,24 +1700,26 @@
 %22: True,%0A   
+ #
          %7D%0A 
@@ -1716,24 +1716,26 @@
        %7D%0A   
+ #
      s = Dow
@@ -1772,24 +1772,26 @@
 e, opts)%0A   
+ #
      s.run()

Fix another Windows test