Exemplo n.º 1
0
    def test_one_dir(self):
        # ls directory
        testargs = ['mc', 'ls', self.dirs[0]]
        with captured_output(wd=self.proj_path) as (sout, serr):
            ls_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertEqual(out[2].split()[i_l_type], 'file')
        self.assertEqual(out[2].split()[i_r_type], '-')
        self.assertEqual(out[3].split()[i_l_type], 'file')
        self.assertEqual(out[3].split()[i_r_type], '-')
        self.assertEqual(out[4].split()[i_l_type], 'dir')
        self.assertEqual(out[4].split()[i_r_type], '-')

        testargs = ['mc', 'up', self.files[2][0], self.files[3][0]]
        with captured_output(wd=self.proj_path) as (sout, serr):
            up_subcommand(testargs)
        #print_stringIO(sout)

        testargs = ['mc', 'ls', self.dirs[0]]
        with captured_output(wd=self.proj_path) as (sout, serr):
            ls_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertEqual(out[2].split()[i_l_type], 'file')
        self.assertNotEqual(out[2].split()[i_r_type], '-')
        self.assertEqual(out[3].split()[i_l_type], 'file')
        self.assertNotEqual(out[3].split()[i_r_type], '-')
        self.assertEqual(out[4].split()[i_l_type], 'dir')
        self.assertEqual(out[4].split()[i_r_type], '-')
Exemplo n.º 2
0
    def test_one_file(self):
        # ls 1 file (in top directory)
        testargs = ['mc', 'ls', self.files[2][0]]
        with captured_output(wd=self.proj_path) as (sout, serr):
            ls_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertEqual(out[1].split()[i_l_type], 'file')
        self.assertEqual(out[1].split()[i_r_size], '-')
        self.assertEqual(out[1].split()[i_r_type], '-')
        self.assertEqual(out[1].split()[i_name], 'level_1/file_A.txt')
        self.assertEqual(out[1].split()[i_id], '-')

        testargs = ['mc', 'up', self.files[2][0]]
        with captured_output(wd=self.proj_path) as (sout, serr):
            up_subcommand(testargs)
        #print_stringIO(sout)

        testargs = ['mc', 'ls', self.files[2][0]]
        with captured_output(wd=self.proj_path) as (sout, serr):
            ls_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertEqual(out[1].split()[i_l_type], 'file')
        self.assertNotEqual(out[1].split()[i_r_size], '-')
        self.assertEqual(out[1].split()[i_r_type], 'file')
        self.assertEqual(out[1].split()[i_name], 'level_1/file_A.txt')
        self.assertNotEqual(out[1].split()[i_id], '-')
Exemplo n.º 3
0
 def test_one_in_top(self):
     # upload 1 file (in top directory)
     testargs = ['mc', 'up', self.files[0][0]]
     with captured_output(wd=self.proj_path) as (sout, serr):
         up_subcommand(testargs)
     #print_stringIO(sout)
     out = sout.getvalue().splitlines()
     proj = self.get_proj()
     
     file = proj.get_by_local_path(self.files[0][0])
     self.assertTrue(isinstance(file, mcapi.File))
     self.assertEqual(file.name, os.path.basename(self.files[0][0]))
     self.assertEqual(file._directory_id, proj.get_top_directory().id)
Exemplo n.º 4
0
 def test_one_with_intermediate(self):
     # upload 1 file (in level_2 directory)
     testargs = ['mc', 'up', self.files[4][0]]
     with captured_output(wd=self.proj_path) as (sout, serr):
         up_subcommand(testargs)
     #print_stringIO(sout)
     out = sout.getvalue().splitlines()
     proj = self.get_proj()
     
     file = proj.get_by_local_path(self.files[4][0])
     parent = proj.get_directory_by_id(file._directory_id)
     self.assertTrue(isinstance(file, mcapi.File))
     self.assertEqual(file.name, os.path.basename(self.files[4][0]))
     self.assertEqual(file._directory_id, parent.id)
     self.assertEqual(parent.path, "CLITest/level_1/level_2")
Exemplo n.º 5
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_test_files()

        testargs = ['mc', 'up', '-r', '.']
        with captured_output(wd=cls.proj_path) as (sout, serr):
            up_subcommand(testargs)

        cls.remove_test_files()
Exemplo n.º 6
0
 def test_recursive(self):
     # upload files in level_1 and level_2
     testargs = ['mc', 'up', '-r', self.dirs[0]]
     with captured_output(wd=self.proj_path) as (sout, serr):
         up_subcommand(testargs)
     #print_stringIO(sout)
     out = sout.getvalue().splitlines()
     proj = self.get_proj()
     
     for d in self.dirs:
         dir = proj.get_by_local_path(d)
         self.assertTrue(isinstance(dir, mcapi.Directory))
 
     for f in self.files[2:]:
         file = proj.get_by_local_path(f[0])
         self.assertTrue(isinstance(file, mcapi.File))
Exemplo n.º 7
0
    def test_two_dir(self):
        # ls two directories
        testargs = ['mc', 'ls', self.dirs[0], self.dirs[1]]
        with captured_output(wd=self.proj_path) as (sout, serr):
            ls_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertEqual(out[2].split()[i_l_type], 'file')
        self.assertEqual(out[2].split()[i_r_type], '-')
        self.assertEqual(out[3].split()[i_l_type], 'file')
        self.assertEqual(out[3].split()[i_r_type], '-')
        self.assertEqual(out[4].split()[i_l_type], 'dir')
        self.assertEqual(out[4].split()[i_r_type], '-')
        self.assertEqual(out[8].split()[i_l_type], 'file')
        self.assertEqual(out[8].split()[i_r_type], '-')
        self.assertEqual(out[9].split()[i_l_type], 'file')
        self.assertEqual(out[9].split()[i_r_type], '-')

        testargs = ['mc', 'up', self.dirs[1]]
        with captured_output(wd=self.proj_path) as (sout, serr):
            up_subcommand(testargs)
        #print_stringIO(sout)

        testargs = ['mc', 'ls', self.dirs[0], self.dirs[1], '--checksum']
        with captured_output(wd=self.proj_path) as (sout, serr):
            ls_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertEqual(out[2].split()[i_l_type], 'file')
        self.assertEqual(out[2].split()[i_r_type], '-')
        self.assertEqual(out[3].split()[i_l_type], 'file')
        self.assertEqual(out[3].split()[i_r_type], '-')
        self.assertEqual(out[4].split()[i_l_type], 'dir')
        self.assertNotEqual(out[4].split()[i_r_size], '-')
        self.assertEqual(out[4].split()[i_r_type], 'dir')

        self.assertEqual(out[8].split()[i_l_type], 'file')
        self.assertNotEqual(out[8].split()[i_r_size], '-')
        self.assertEqual(out[8].split()[i_r_type], 'file')
        self.assertEqual(out[8].split()[i_eq], 'True')
        self.assertEqual(out[9].split()[i_l_type], 'file')
        self.assertNotEqual(out[9].split()[i_r_size], '-')
        self.assertEqual(out[9].split()[i_r_type], 'file')

        # test equivalence check
        with open(self.files[4][0], 'w') as f:
            f.write("changed")

        testargs = ['mc', 'ls', self.dirs[0], self.dirs[1], '--checksum']
        with captured_output(wd=self.proj_path) as (sout, serr):
            ls_subcommand(testargs)
        #print_stringIO(sout)
        out = sout.getvalue().splitlines()
        self.assertEqual(out[8].split()[i_eq], 'False')

        # test json
        testargs = ['mc', 'ls', self.dirs[0], self.dirs[1], '--checksum']
        with captured_output(wd=self.proj_path) as (sout, serr):
            ls_subcommand(testargs)
        #print_stringIO(sout)
        self.assertTrue(True)