Esempio n. 1
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')
Esempio n. 2
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)
Esempio 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])
Esempio n. 4
0
    def test_delete_all_projects(self):
        self.helper = aid.AssertHelper(self)

        self._build_project()

        projects = get_all_projects()
        self.assertTrue(len(projects) > 0)

        for project in projects:
            project.delete()

        projects = get_all_projects()
        self.assertEqual(len(projects), 0)
Esempio n. 5
0
 def does_project_exist(self):
     projects = get_all_projects()
     project = None
     for p in projects:
         if p.name == self.project_name:
             project = p
     return not not project
Esempio n. 6
0
 def get_existing_project(self):
     projects = get_all_projects()
     project = None
     for p in projects:
         if p.name == self.project_name:
             project = p
     return project
Esempio n. 7
0
 def _get_project(self, project_name):
     projects = get_all_projects()
     project = None
     for p in projects:
         if p.name == project_name:
             project = p
     return project
Esempio n. 8
0
 def test_list_projects_object(self):
     projects = get_all_projects()
     project = projects[0]
     self.assertIsNotNone(project.name)
     self.assertTrue(isinstance(project, Project))
     self.assertIsNotNone(project.description)
     self.assertIsNotNone(project.id)
     self.assertNotEqual(project.name, "")
Esempio n. 9
0
 def _get_or_create_project(self, project_name, project_description):
     projects = get_all_projects()
     project = None
     for p in projects:
         if p.name == project_name:
             project = p
     if not project:
         project = create_project(name=project_name,
                                  description=project_description)
     return project
Esempio n. 10
0
 def clean(cls):
     proj_list = mcapi.get_all_projects()
     proj_dict = {p.name: p for p in proj_list}
     if 'CLITest' in proj_dict:
         proj_dict['CLITest'].delete()
     mc = os.path.join(cls.proj_path, ".mc")
     config = os.path.join(mc, "config.json")
     remove_if(config)
     rmdir_if(mc)
     rmdir_if(cls.proj_path)
 def _projects_exists(self, name):
     projects = get_all_projects()
     for p in projects:
         if p.name == name:
             return True
     return False
Esempio n. 12
0
 def clean_proj(cls):
     proj_list = mcapi.get_all_projects()
     proj_dict = {p.name:p for p in proj_list}
     if 'CLITest' in proj_dict:
         proj_dict['CLITest'].delete()
Esempio n. 13
0
from mcapi import get_all_projects
import sys

if len(sys.argv) < 2:
    print "supply project_id as command line argument"
    sys.exit(1)

project_id = sys.argv[1]

found_project = None

for project in get_all_projects():
    if project.id == project_id:
        found_project = project

if found_project:
    project = found_project
    print "deleting project: " + project.name + "..."
    project.delete()
    print "done."
else:
    print "no project found: " + project_id