Send the specific directory that needs to be copied in the startCopy message.
[htsworkflow.git] / test / test_copier.py
index f34be14159a83e41d51f2673231dabb7859a1551..da4834010d17c18d06226fa9070ac6a3c8f295c6 100644 (file)
@@ -16,7 +16,7 @@ class testCopier(unittest.TestCase):
 something: unrelated
 """)
         bot = copier.CopierBot('fake', configfile=cfg)
-        self.failUnlessRaises(KeyError, bot.read_config)
+        self.failUnlessRaises(RuntimeError, bot.read_config)
         
     def test_full_config(self):
         cfg = StringIO("""[copier]        
@@ -24,7 +24,7 @@ jid: copier@example.fake
 password: badpassword
 authorized_users: user1@example.fake user2@example.fake
 rsync_password_file: ~/.sequencer
-rsync_sources: /tmp/sequencer_source
+rsync_sources: rsync://localhost/tmp/sequencer_source
 rsync_destination: /tmp/sequencer_destination
 notify_users: user3@example.fake
 # who to run to
@@ -39,10 +39,24 @@ notify_users: user3@example.fake
         self.failUnlessEqual(c.authorized_users[0], 'user1@example.fake')
         self.failUnlessEqual(c.authorized_users[1], 'user2@example.fake')
         self.failUnlessEqual(c.rsync.source_base_list[0], 
-                             '/tmp/sequencer_source/')
+                             'rsync://localhost/tmp/sequencer_source/')
         self.failUnlessEqual(c.rsync.dest_base, '/tmp/sequencer_destination')
         self.failUnlessEqual(len(c.notify_users), 1)
         self.failUnlessEqual(c.notify_users[0], 'user3@example.fake')
+        self.failUnlessEqual(c.validate_url('rsync://other/tmp'), None)
+        self.failUnlessEqual(c.validate_url('http://localhost/tmp'), None)
+        # In the rsync process the URL gets a trailing '/' added to it
+        # But in the bot config its still slash-less. 
+        # It is debatable when to add the trailing slash.
+        self.failUnlessEqual(
+          c.validate_url('rsync://localhost/tmp/sequencer_source'), 
+          'rsync://localhost/tmp/sequencer_source') 
+        self.failUnlessEqual(
+          c.validate_url('rsync://localhost/tmp/sequencer_source/'), 
+          'rsync://localhost/tmp/sequencer_source/')
+        self.failUnlessEqual(
+          c.validate_url('rsync://localhost/tmp/sequencer_source/bleem'), 
+          'rsync://localhost/tmp/sequencer_source/bleem')
 
     def test_dirlist_filter(self):
        """