コード例 #1
0
 def test_parse_output_swapped_order(self):
     """Test output with changed order."""
     self.assertEqual(
         parse_output(
             'Upload: 5.88 bit/s\nPing: 10.331 ms\nDownload: 40.53 bit/s'
         ),
         (10.331, 40.53, 5.88)
     )
コード例 #2
0
 def test_parse_output_mixed_bit(self):
     """Test output that contains bit/s and Gbit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.53 Gbit/s\nUpload: 5.88 bit/s'
         ),
         (10.331, 43518756126.72, 5.88)
     )
コード例 #3
0
 def test_parse_output_gbit(self):
     """Test output that contains only Gbit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.53 Gbit/s\nUpload: 5.88 gbit/s'
         ),
         (10.331, 43518756126.72, 6313601925.12)
     )
コード例 #4
0
 def test_parse_output_mbit(self):
     """Test output that contains only Mbit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.53 mbit/s\nUpload: 5.88 Mbit/s'
         ),
         (10.331, 42498785.28, 6165626.88)
     )
コード例 #5
0
 def test_parse_output_kbit(self):
     """Test output that contains only Kbit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.53 Kbit/s\nUpload: 5.88 kbit/s'
         ),
         (10.331, 41502.72, 6021.12)
     )
コード例 #6
0
 def test_parse_output_bit(self):
     """Test output that contains only bit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.5 bit/s\nUpload: 5.88 Bit/s'
         ),
         (10.331, 40.5, 5.88)
     )
コード例 #7
0
    def test_parse_output_not_matching(self):
        """Test whether default values are returned when unable to parse."""
        # Silence logging, as we expect to produce exceptions within tests and
        # do not want to clutter the output:
        old_log_level = self.logger.getEffectiveLevel()
        self.logger.setLevel(logging.CRITICAL)

        self.assertEqual(
            parse_output(
                'Ping: 10.331 s\nDownload: 40.xx bit/s\nUpload: 5.88 m/s'),
            (-1, -1, -1))

        # Restore to default log level:
        self.logger.setLevel(old_log_level)
コード例 #8
0
    def test_parse_output_not_matching(self):
        """Test whether default values are returned when unable to parse."""
        # Silence logging, as we expect to produce exceptions within tests and
        # do not want to clutter the output:
        old_log_level = self.logger.getEffectiveLevel()
        self.logger.setLevel(logging.CRITICAL)

        self.assertEqual(
            parse_output(
                'Ping: 10.331 s\nDownload: 40.xx bit/s\nUpload: 5.88 m/s'
            ),
            (-1, -1, -1)
        )

        # Restore to default log level:
        self.logger.setLevel(old_log_level)
コード例 #9
0
 def test_parse_output_swapped_order(self):
     """Test output with changed order."""
     self.assertEqual(
         parse_output(
             'Upload: 5.88 bit/s\nPing: 10.331 ms\nDownload: 40.53 bit/s'),
         (10.331, 40.53, 5.88))
コード例 #10
0
 def test_parse_output_mixed_bit(self):
     """Test output that contains bit/s and Gbit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.53 Gbit/s\nUpload: 5.88 bit/s'),
         (10.331, 43518756126.72, 5.88))
コード例 #11
0
 def test_parse_output_gbit(self):
     """Test output that contains only Gbit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.53 Gbit/s\nUpload: 5.88 gbit/s'
         ), (10.331, 43518756126.72, 6313601925.12))
コード例 #12
0
 def test_parse_output_mbit(self):
     """Test output that contains only Mbit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.53 mbit/s\nUpload: 5.88 Mbit/s'
         ), (10.331, 42498785.28, 6165626.88))
コード例 #13
0
 def test_parse_output_kbit(self):
     """Test output that contains only Kbit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.53 Kbit/s\nUpload: 5.88 kbit/s'
         ), (10.331, 41502.72, 6021.12))
コード例 #14
0
 def test_parse_output_bit(self):
     """Test output that contains only bit/s."""
     self.assertEqual(
         parse_output(
             'Ping: 10.331 ms\nDownload: 40.5 bit/s\nUpload: 5.88 Bit/s'),
         (10.331, 40.5, 5.88))