Exemplo n.º 1
0
    def test_mc_expt(self):
        testargs = ['mc', 'init']
        with captured_output(wd=self.proj_path) as (sout, serr):
            init_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        remote = mcapi.use_remote()
        url = remote.config.mcurl
        self.assertEqual(out[0], "Created new project at: " + url)

        testargs = ['mc', 'expt', '-c', 'test_A']
        with captured_output(wd=self.proj_path) as (sout, serr):
            expt_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertTrue(re.match("Created experiment: test_A", out[0]))
        self.assertTrue(re.match("Set current experiment: 'test_A'", out[1]))

        testargs = ['mc', 'expt', '-c', 'test_B']
        with captured_output(wd=self.proj_path) as (sout, serr):
            expt_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertTrue(re.match("Created experiment: test_B", out[0]))
        self.assertTrue(re.match("Set current experiment: 'test_B'", out[1]))

        proj_list = mcapi.get_all_projects()
        proj_dict = {p.name: p for p in proj_list}
        expts_list = proj_dict['CLITest'].get_all_experiments()
        expts_dict = {e.name: e for e in expts_list}
        self.assertEqual(len(expts_list), 2)
        self.assertTrue('test_A' in expts_dict)
        self.assertTrue('test_B' in expts_dict)

        testargs = ['mc', 'expt', '-d', 'test_B', '-n']
        with captured_output(wd=self.proj_path) as (sout, serr):
            expt_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()

        proj_list = mcapi.get_all_projects()
        proj_dict = {p.name: p for p in proj_list}
        expts_list = proj_dict['CLITest'].get_all_experiments()
        expts_dict = {e.name: e for e in expts_list}
        self.assertEqual(len(expts_list), 2)
        self.assertTrue('test_A' in expts_dict)
        self.assertTrue('test_B' in expts_dict)

        testargs = ['mc', 'expt', '-d', 'test_B']
        with captured_output(wd=self.proj_path) as (sout, serr):
            expt_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()

        proj_list = mcapi.get_all_projects()
        proj_dict = {p.name: p for p in proj_list}
        expts_list = proj_dict['CLITest'].get_all_experiments()
        expts_dict = {e.name: e for e in expts_list}
        self.assertEqual(len(expts_list), 1)
        self.assertTrue('test_A' in expts_dict)
Exemplo n.º 2
0
 def test_mc_init(self):
     proj_list = mcapi.get_all_projects()
     proj_dict = {p.name:p for p in proj_list}
     self.assertFalse('CLITest' in proj_dict)
     
     testargs = ['mc', 'init']
     with captured_output(wd=self.proj_path) as (sout, serr):
         init_subcommand(testargs)
     #print_stringIO(sout)
     out = sout.getvalue().splitlines()
     remote = mcapi.use_remote()
     url = remote.config.mcurl
     self.assertEqual(out[0], "Created new project at: " + url)
     
     testargs = ['mc', 'init']
     with captured_output(wd=self.proj_path) as (sout, serr):
         init_subcommand(testargs)
     #print_stringIO(sout)
     out = sout.getvalue().splitlines()
     self.assertTrue(re.match("Already in project.  name: CLITest", out[0]))
     
     proj_list = mcapi.get_all_projects()
     proj_dict = {p.name:p for p in proj_list}
     self.assertTrue('CLITest' in proj_dict)
     
     with working_dir(self.proj_path):
         proj = make_local_project()
         self.assertEqual(proj.name, 'CLITest')
Exemplo n.º 3
0
    def test_mc_clone(self):
        proj_list = mcapi.get_all_projects()
        proj_dict = {p.name: p for p in proj_list}
        self.assertFalse('CLITest' in proj_dict)

        mkdir_if(self.cli_test_project_path)
        mkdir_if(self.proj_path)
        testargs = ['mc', 'init']
        with captured_output(wd=self.proj_path) as (sout, serr):
            init_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        remote = mcapi.use_remote()
        url = remote.config.mcurl
        self.assertEqual(out[0], "Created new project at: " + url)

        proj_list = mcapi.get_all_projects()
        proj_dict = {p.name: p for p in proj_list}

        self.clean_files()
        mkdir_if(self.cli_test_project_path)
        testargs = ['mc', 'clone', proj_dict['CLITest'].id]
        with captured_output(wd=self.cli_test_project_path) as (sout, serr):
            clone_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertTrue(re.match("Cloned project", out[0]))
        self.assertEqual('CLITest', out[3].split()[0])
Exemplo n.º 4
0
 def init(cls):
     mkdir_if(cls.cli_test_project_path)
     mkdir_if(cls.proj_path)
     testargs = ['mc', 'init']
     with captured_output(wd=cls.proj_path) as (sout, serr):
         init_subcommand(testargs)
     #print_stringIO(sout)
     out = sout.getvalue().splitlines()
     
     cls.make_processes()