Example #1
0
    def test_host_tuple(self):
        upstream_hosts_single = 'localhost:8080'
        result = [host_tuple(host) for host in
                  split_and_strip(upstream_hosts_single, ',')]
        self.assertEqual(result, [('localhost', 8080)])

        upstream_hosts_multiple = '127.0.0.1:1,127.0.0.2:2,127.0.0.3:3'
        result = [host_tuple(host) for host in
                  split_and_strip(upstream_hosts_multiple, ',')]
        self.assertEqual(result, [('127.0.0.1', 1),
                                  ('127.0.0.2', 2),
                                  ('127.0.0.3', 3)])

        upstream_hosts_multiple_with_spaces = \
            '127.0.0.1:1, 127.0.0.2:2, 127.0.0.3:3'
        result = [host_tuple(host) for host in
                  split_and_strip(upstream_hosts_multiple_with_spaces, ',')]
        self.assertEqual(result, [('127.0.0.1', 1),
                                  ('127.0.0.2', 2),
                                  ('127.0.0.3', 3)])
Example #2
0
 def test_host_tuple_no_port(self):
     upstream_host = 'localhost'
     result = [host_tuple(host) for host in
               split_and_strip(upstream_host, ',')]
     self.assertEqual(result, [('localhost', 80)])
Example #3
0
 def test_split_and_strip_single_path(self):
     values_str = '/usr/share/project/python'
     split_on = ','
     path_list = split_and_strip(values_str, split_on)
     self.assertEqual(path_list[0], '/usr/share/project/python')
Example #4
0
 def test_split_and_strip_multiple_paths(self):
     values_str = '/usr/share/project/python,/usr/share/other/python'
     split_on = ','
     path_list = [path for path in split_and_strip(values_str, split_on)]
     self.assertEqual(path_list[0], '/usr/share/project/python')
     self.assertEqual(path_list[1], '/usr/share/other/python')