Skip to content

Commit

Permalink
Removed unnecessary tests for tests/test_ftp.py for FTP_TLS
Browse files Browse the repository at this point in the history
  • Loading branch information
fazledyn-or committed Oct 17, 2023
1 parent 099196a commit 38b338a
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions tests/test_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,7 @@ class FTPTLSTest(TestCase):
def setUp(self):
self.storage = ftp.FTPStorage(location=URL_TLS)

def test_init_no_location(self):
with self.assertRaises(ImproperlyConfigured):
ftp.FTPStorage()

@patch("storages.backends.ftp.setting", return_value=URL_TLS)
def test_init_location_from_setting(self, mock_setting):
storage = ftp.FTPStorage()
self.assertTrue(mock_setting.called)
self.assertEqual(storage.location, URL_TLS)

def test_decode_location(self):
config = self.storage._decode_location(URL_TLS)
wanted_config = {
"passwd": "b@r",
"host": "localhost",
Expand All @@ -271,22 +260,10 @@ def test_decode_location(self):
"port": 2121,
"secure": True
}
self.assertEqual(config, wanted_config)

def test_decode_location_error(self):
with self.assertRaises(ImproperlyConfigured):
self.storage._decode_location("foo")
with self.assertRaises(ImproperlyConfigured):
self.storage._decode_location("http://foo.pt")
# TODO: Cannot not provide a port
# with self.assertRaises(ImproperlyConfigured):
# self.storage._decode_location('ftp://')
self.assertEqual(self.storage._config, wanted_config)

@patch("ftplib.FTP_TLS")
def test_start_connection(self, mock_ftp):
def test_start_connection_calls_prot_p(self, mock_ftp):
self.storage._start_connection()
self.assertIsNotNone(self.storage._connection)
# Start active
storage = ftp.FTPStorage(location=URL_TLS)
storage._start_connection()
self.storage._connection.prot_p.assert_called_once()

0 comments on commit 38b338a

Please sign in to comment.