ppf: Add test suite for add_client_session.
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sun, 21 Aug 2011 17:35:18 +0000 (20:35 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sun, 21 Aug 2011 17:35:18 +0000 (20:35 +0300)
ppf/new/tests/test_storage.py

index 706bc9e..9766e63 100644 (file)
@@ -145,13 +145,12 @@ class TreeTextFileAccessTest(unittest.TestCase):
         shutil.rmtree(self.path)
 
     def test_add_swarm_folder_and_file_are_created(self):
-        create_numeric_subfolders_sequential(self.path)
-        expected_swarm_subfolder = 6
+        expected_swarm_subfolder = 1
 
         # Create instance of class and add swarm.
         a = storage.TreeTextFileAccess(self.path)
-        s = storage.Swarm(torrent_filename = "fedora.torrent",
-                data_size = 102400)
+        s = storage.Swarm(torrent_filename="fedora.torrent",
+                data_size=102400)
         a.add_swarm(s)
 
         expected_swarm_path = os.path.join(self.path,
@@ -162,5 +161,52 @@ class TreeTextFileAccessTest(unittest.TestCase):
                 os.path.isfile(expected_swarm_config)
         self.assertEqual(expected_true, True)
 
+    def test_add_client_session_folder_and_file_are_created(self):
+        expected_swarm_subfolder = 1
+        expected_session_subfolder = 1
+
+        a = storage.TreeTextFileAccess(self.path)
+
+        # Add swarm.
+        s = storage.Swarm(torrent_filename="fedora.torrent",
+                data_size=102400)
+        a.add_swarm(s)
+
+        # Add client session.
+        cs = storage.ClientSession(swarm_id=1, btclient="Tribler",
+                system_os="Linux", system_os_version="2.6.26",
+                system_ram=2048, system_cpu=3000, public_ip="141.85.224.201",
+                public_port="50500", ds_limit=300, us_limit=200)
+        a.add_client_session(cs)
+
+        expected_swarm_path = os.path.join(self.path,
+                str(expected_swarm_subfolder))
+        expected_session_path = os.path.join(expected_swarm_path,
+                str(expected_session_subfolder))
+        expected_session_config = os.path.join(expected_session_path,
+                "client_session.conf")
+
+        expected_true = os.path.isdir(expected_session_path) and \
+                os.path.isfile(expected_session_config)
+        self.assertEqual(expected_true, True)
+
+    def test_add_peer_status_message_file_is_created(self):
+        self.assertEqual(True, True)
+
+    def test_add_peer_status_message_number_of_lines(self):
+        self.assertEqual(True, True)
+
+    def test_add_status_message_file_is_created(self):
+        self.assertEqual(True, True)
+
+    def test_add_status_message_number_of_lines(self):
+        self.assertEqual(True, True)
+
+    def test_add_verbose_message_file_is_created(self):
+        self.assertEqual(True, True)
+
+    def test_add_verbose_message_number_of_lines(self):
+        self.assertEqual(True, True)
+
 if __name__ == "__main__":
     unittest.main()