Пример #1
0
    def test_group6(self):
        error, args, config = deploy.parse_args(["-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass", "all"])
        files, dirs = deploy.create_total_filelist(config, ["group6"])

        dst_ip = "192.168.56.101"
        src_dir = './test_data/'
        dst_dir = '/home/randomguy/testtarget/component1'
        self.assertEqual(4, len(files))

        self.assertEqual(src_dir + "file1.txt", files[0].src_path)
        self.assertEqual(dst_dir, files[0].dst_path)
        self.assertEqual(dst_ip, files[0].dst_ip)
        self.assertEqual(src_dir + "hello.xml", files[1].src_path)
        self.assertEqual(dst_dir, files[1].dst_path)
        self.assertEqual(dst_ip, files[1].dst_ip)

        dst_ip = "192.168.56.102"
        dst_dir = '/home/randomguy/testtarget'
        self.assertEqual(src_dir + "file1.txt", files[2].src_path)
        self.assertEqual(dst_dir, files[2].dst_path)
        self.assertEqual(dst_ip, files[2].dst_ip)
        self.assertEqual(src_dir + "file2.txt", files[3].src_path)
        self.assertEqual(dst_dir, files[3].dst_path)
        self.assertEqual(dst_ip, files[3].dst_ip)

        dst_ip = "192.168.56.101"
        self.assertEqual(2, len(dirs))
        self.assertEqual(src_dir, dirs[0].src_path)
        self.assertEqual(dst_dir, dirs[0].dst_path)
        self.assertEqual(dst_ip, dirs[0].dst_ip)
        self.assertEqual(22, dirs[0].dst_port)
        self.assertEqual(src_dir, dirs[1].src_path)
        self.assertEqual(dst_dir, dirs[1].dst_path)
        self.assertEqual("service1.target.example", dirs[1].dst_ip)
        self.assertEqual(22, dirs[1].dst_port)
Пример #2
0
 def test_component7(self):
     error, args, config = deploy.parse_args(["-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass", "all"])
     error, files, dirs = deploy.create_file_list(config, "component7", set())
     self.assertEqual("Directory './non-existant/' not found (or is not a directory).",
                      error)
     self.assertIsNone(files)
     self.assertIsNone(dirs)
Пример #3
0
 def test_component4(self):
     error, args, config = deploy.parse_args(["-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass", "all"])
     error, files, dirs = deploy.create_file_list(config, "component4", set())
     self.assertEqual(
         "Could not find file starting with 'file' and ending with 'json' in path './test_data/'. Skipping deployment target 'component4'.",
         error)
     self.assertIsNone(files)
     self.assertIsNone(dirs)
Пример #4
0
 def test_user_pass_target(self):
     error, args, config = deploy.parse_args([
         "-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass",
         "all"
     ])
     self.assertIsNone(error)
     self.assertEqual("test_data/test_config.ini", args.configfile)
     self.assertEqual("all", args.target)
     self.assertEqual("mypass", args.password)
     self.assertEqual("bob", args.username)
Пример #5
0
 def test_group3(self):
     error, args, config = deploy.parse_args(["-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass", "all"])
     error, files, dirs = deploy.create_file_list(config, "group3", set())
     self.assertEqual("Key '' not found in configuration.",
                      error)
     dst_ip = "www.kanstren.net"
     src_dir = './test_data/'
     dst_dir = '/home/randomguy/testtarget/component1/'
     self.assertIsNone(files)
     self.assertEqual(0, len(dirs))
Пример #6
0
 def test_component5(self):
     error, args, config = deploy.parse_args(["-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass", "all"])
     error, files, dirs = deploy.create_file_list(config, "component5", set())
     self.assertIsNone(error)
     self.assertEqual(0, len(dirs))
     dst_ip = "192.168.56.101"
     src_dir = './test_data/'
     dst_dir = '/home/randomguy/testtarget/component1'
     self.assertEqual(2, len(files))
     self.assertEqual(src_dir + "file1.txt", files[0].src_path)
     self.assertEqual(dst_dir, files[0].dst_path)
     self.assertEqual(dst_ip, files[0].dst_ip)
     self.assertEqual(src_dir + "hello.xml", files[1].src_path)
     self.assertEqual(dst_dir, files[1].dst_path)
     self.assertEqual(dst_ip, files[1].dst_ip)
Пример #7
0
 def test_group1(self):
     error, args, config = deploy.parse_args(["-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass", "all"])
     error, files, dirs = deploy.create_file_list(config, "group1", set())
     self.assertEqual("Could not find file starting with 'test_file_1' and ending with '.txt' in path './test_data'. Skipping deployment target 'component1'.", error)
     dst_ip = "192.168.56.101"
     src_dir = './test_data/'
     dst_dir = '/home/randomguy/testtarget/component1'
     self.assertEqual(2, len(files))
     self.assertEqual(0, len(dirs))
     self.assertEqual(src_dir + "file1.txt", files[0].src_path)
     self.assertEqual(dst_dir, files[0].dst_path)
     self.assertEqual(dst_ip, files[0].dst_ip)
     self.assertEqual(src_dir + "hello.xml", files[1].src_path)
     self.assertEqual(dst_dir, files[1].dst_path)
     self.assertEqual(dst_ip, files[1].dst_ip)
Пример #8
0
 def test_component2(self):
     error, args, config = deploy.parse_args(["-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass", "all"])
     error, files, dirs = deploy.create_file_list(config, "component2", set())
     self.assertIsNone(error)
     dst_ip = "192.168.56.101"
     src_dir = './test_data/'
     dst_dir = '/home/randomguy/testtarget'
     self.assertEqual(0, len(files))
     self.assertEqual(2, len(dirs))
     self.assertEqual(src_dir, dirs[0].src_path)
     self.assertEqual(dst_dir, dirs[0].dst_path)
     self.assertEqual(dst_ip, dirs[0].dst_ip)
     self.assertEqual(22, dirs[0].dst_port)
     self.assertEqual(src_dir, dirs[1].src_path)
     self.assertEqual(dst_dir, dirs[1].dst_path)
     self.assertEqual("service1.target.example", dirs[1].dst_ip)
     self.assertEqual(22, dirs[1].dst_port)
Пример #9
0
 def test_two_files(self):
     error, args, config = deploy.parse_args([
         "-c", "test_data/test_config_deploy.ini", "-u", self.USERNAME,
         "-p", self.PASSWORD, "two_files"
     ])
     deploy.deploy(args, config)
Пример #10
0
 def test_component6(self):
     error, args, config = deploy.parse_args(["-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass", "all"])
     error, files, dirs = deploy.create_file_list(config, "component6", set())
     self.assertEqual("Target 'component6' specifies both pre/postfix and 'file_names'. Remove one. Skipping target.",
                      error)
     self.assertIsNone(files)
Пример #11
0
 def test_prefixed(self):
     error, args, config = deploy.parse_args([
         "-c", "test_data/test_config_deploy.ini", "-u", self.USERNAME,
         "-p", self.PASSWORD, "prefixed"
     ])
     deploy.deploy(args, config)
Пример #12
0
 def test_nomatch(self):
     error, args, config = deploy.parse_args([
         "-c", "test_data/test_config_deploy.ini", "-u", self.USERNAME,
         "-p", self.PASSWORD, "no_match"
     ])
     deploy.deploy(args, config)
Пример #13
0
 def test_full_dir(self):
     error, args, config = deploy.parse_args([
         "-c", "test_data/test_config_deploy.ini", "-u", self.USERNAME,
         "-p", self.PASSWORD, "full_dir"
     ])
     deploy.deploy(args, config)
Пример #14
0
 def test_no_target(self):
     error, args, config = deploy.parse_args(
         ["-c", "test_data/test_config.ini", "-u", "bob", "-p", "mypass"])
     self.assertEqual("No deployment target specified. Doing nothing.",
                      error)
Пример #15
0
 def test_list_configfile(self):
     error, args, config = deploy.parse_args(
         ["-c", "test_data/test_config.ini", "-l"])
     self.assertEqual(
         "Targets found for 'test_data/test_config.ini': ['component1', 'component2', 'component3', 'component4', 'component5', 'component6', 'component7', 'component8', 'group1', 'group2', 'group3', 'group4', 'group5', 'group6', 'group7']",
         error)
Пример #16
0
 def test_invalid_configfile(self):
     error, args, config = deploy.parse_args(["-c", "missing_file", "-l"])
     self.assertEqual(
         "Unable to read content from config file 'missing_file'", error)
Пример #17
0
 def test_noargs(self):
     error, args, config = deploy.parse_args([])
     self.assertEqual(
         'You need to specify either -l/--list or both -u/--username and -p/--password',
         error)
Пример #18
0
 def test_group_of_2(self):
     error, args, config = deploy.parse_args([
         "-c", "test_data/test_config_deploy.ini", "-u", self.USERNAME,
         "-p", self.PASSWORD, "group_of_2"
     ])
     deploy.deploy(args, config)