id = storage.find_last_numeric_subfolder(self.path)
self.assertEqual(id, 1401)
+
+class TreeTextFileAccessTest(unittest.TestCase):
+ """
+ Test suite for TreeTextFileAccess class in storage.py.
+ """
+
+ # Class specific variables. Initialized in setUp, used throughout tests.
+ path = "/tmp/ttfa-test"
+
+ def setUp(self):
+ """Create folder. Initialize object. """
+ os.mkdir(self.path)
+
+ def tearDown(self):
+ """Remove base folder."""
+ shutil.rmtree(self.path)
+
+ def test_add_swarm_folder_and_file_are_created(self):
+ create_numeric_subfolders_sequential(self.path)
+ expected_swarm_subfolder = 6
+
+ # Create instance of class and add swarm.
+ a = storage.TreeTextFileAccess(self.path)
+ s = storage.Swarm(torrent_filename = "fedora.torrent",
+ data_size = 102400)
+ a.add_swarm(s)
+
+ expected_swarm_path = os.path.join(self.path,
+ str(expected_swarm_subfolder))
+ expected_swarm_config = os.path.join(expected_swarm_path, "swarm.conf")
+
+ expected_true = os.path.isdir(expected_swarm_path) and \
+ os.path.isfile(expected_swarm_config)
+ self.assertEqual(expected_true, True)
+
if __name__ == "__main__":
unittest.main()