Ejemplo n.º 1
0
 def test_active_transfer_state_fails_on_queued(self):
     status = LftpJobStatus(job_id=-1,
                            job_type=LftpJobStatus.Type.MIRROR,
                            state=LftpJobStatus.State.QUEUED,
                            name="",
                            flags="")
     with self.assertRaises(TypeError) as context:
         status.add_active_file_transfer_state(
             "filename", LftpJobStatus.TransferState(10, 20, 50, 0, 0))
     self.assertTrue("Cannot set transfer state on job of type queue" in
                     str(context.exception))
Ejemplo n.º 2
0
 def test_active_transfer_state(self):
     status = LftpJobStatus(job_id=-1,
                            job_type=LftpJobStatus.Type.MIRROR,
                            state=LftpJobStatus.State.RUNNING,
                            name="",
                            flags="")
     status.add_active_file_transfer_state(
         "a", LftpJobStatus.TransferState(10, 20, 50, 0, 0))
     status.add_active_file_transfer_state(
         "b", LftpJobStatus.TransferState(25, 100, 25, 0, 0))
     self.assertEqual(
         {("a", LftpJobStatus.TransferState(10, 20, 50, 0, 0)),
          ("b", LftpJobStatus.TransferState(25, 100, 25, 0, 0))},
         set(status.get_active_file_transfer_states()))
Ejemplo n.º 3
0
    def test_equality_operator(self):
        s1 = LftpJobStatus(job_id=3,
                           job_type=LftpJobStatus.Type.MIRROR,
                           state=LftpJobStatus.State.RUNNING,
                           name="name",
                           flags="flags")
        s1.total_transfer_state = LftpJobStatus.TransferState(10, 20, 50, 1, 2)
        s1.add_active_file_transfer_state(
            "aa", LftpJobStatus.TransferState(1, 2, 3, 4, 5))
        s1.add_active_file_transfer_state(
            "ab", LftpJobStatus.TransferState(6, 7, 8, 9, 0))

        # test equality
        s2 = LftpJobStatus(job_id=3,
                           job_type=LftpJobStatus.Type.MIRROR,
                           state=LftpJobStatus.State.RUNNING,
                           name="name",
                           flags="flags")
        s2.total_transfer_state = LftpJobStatus.TransferState(10, 20, 50, 1, 2)
        s2.add_active_file_transfer_state(
            "aa", LftpJobStatus.TransferState(1, 2, 3, 4, 5))
        s2.add_active_file_transfer_state(
            "ab", LftpJobStatus.TransferState(6, 7, 8, 9, 0))
        self.assertTrue(s1 == s2)

        # test equality - different order of active file transfer state
        s2 = LftpJobStatus(job_id=3,
                           job_type=LftpJobStatus.Type.MIRROR,
                           state=LftpJobStatus.State.RUNNING,
                           name="name",
                           flags="flags")
        s2.total_transfer_state = LftpJobStatus.TransferState(10, 20, 50, 1, 2)
        s2.add_active_file_transfer_state(
            "ab", LftpJobStatus.TransferState(6, 7, 8, 9, 0))
        s2.add_active_file_transfer_state(
            "aa", LftpJobStatus.TransferState(1, 2, 3, 4, 5))
        self.assertTrue(s1 == s2)

        # inequality - job id
        s2 = LftpJobStatus(job_id=2,
                           job_type=LftpJobStatus.Type.MIRROR,
                           state=LftpJobStatus.State.RUNNING,
                           name="name",
                           flags="flags")
        s2.total_transfer_state = LftpJobStatus.TransferState(10, 20, 50, 1, 2)
        s2.add_active_file_transfer_state(
            "aa", LftpJobStatus.TransferState(1, 2, 3, 4, 5))
        s2.add_active_file_transfer_state(
            "ab", LftpJobStatus.TransferState(6, 7, 8, 9, 0))
        self.assertFalse(s1 == s2)

        # inequality - job type
        s2 = LftpJobStatus(job_id=3,
                           job_type=LftpJobStatus.Type.PGET,
                           state=LftpJobStatus.State.RUNNING,
                           name="name",
                           flags="flags")
        s2.total_transfer_state = LftpJobStatus.TransferState(10, 20, 50, 1, 2)
        s2.add_active_file_transfer_state(
            "aa", LftpJobStatus.TransferState(1, 2, 3, 4, 5))
        s2.add_active_file_transfer_state(
            "ab", LftpJobStatus.TransferState(6, 7, 8, 9, 0))
        self.assertFalse(s1 == s2)

        # inequality - job state
        s1_q = LftpJobStatus(job_id=3,
                             job_type=LftpJobStatus.Type.MIRROR,
                             state=LftpJobStatus.State.QUEUED,
                             name="name",
                             flags="flags")
        s2 = LftpJobStatus(job_id=3,
                           job_type=LftpJobStatus.Type.MIRROR,
                           state=LftpJobStatus.State.RUNNING,
                           name="name",
                           flags="flags")
        self.assertFalse(s1_q == s2)

        # inequality - job total transfer state
        s2 = LftpJobStatus(job_id=3,
                           job_type=LftpJobStatus.Type.MIRROR,
                           state=LftpJobStatus.State.RUNNING,
                           name="name",
                           flags="flags")
        s2.total_transfer_state = LftpJobStatus.TransferState(10, 20, 50, 1, 3)
        s2.add_active_file_transfer_state(
            "aa", LftpJobStatus.TransferState(1, 2, 3, 4, 5))
        s2.add_active_file_transfer_state(
            "ab", LftpJobStatus.TransferState(6, 7, 8, 9, 0))
        self.assertFalse(s1 == s2)

        # inequality - active file transfer state
        s2 = LftpJobStatus(job_id=3,
                           job_type=LftpJobStatus.Type.MIRROR,
                           state=LftpJobStatus.State.RUNNING,
                           name="name",
                           flags="flags")
        s2.total_transfer_state = LftpJobStatus.TransferState(10, 20, 50, 1, 2)
        s2.add_active_file_transfer_state(
            "aa", LftpJobStatus.TransferState(1, 2, 3, 4, 5))
        s2.add_active_file_transfer_state(
            "ab", LftpJobStatus.TransferState(6, 7, 8, 9, 10))
        self.assertFalse(s1 == s2)