Exemple #1
0
    def test_mkzip(self):
        p = os.path.join(self.results_path, "testcase")
        t = os.path.join(self.results_path, "testcase.zip")
        ZipUtils.mkzip(p, t)

        self.assertEqual(os.path.isfile(t), True)
        FileSystemUtils.force_delete_file(t)
Exemple #2
0
    def test_getFileSize(self):
        f = os.path.join(self.results_path, 'md5test.txt')
        with open(f, 'w') as fn:
            fn.write(u"千山鸟飞绝,万径人踪灭")

        self.assertEqual(FileSystemUtils.getFileSize(f), 22)
        FileSystemUtils.force_delete_file(f)
Exemple #3
0
    def test_add_unique_postfix(self):
        f = os.path.join(self.results_path, 'md5test.txt')
        with open(f, 'w') as fn:
            fn.write(u"千山鸟飞绝,万径人踪灭")

        self.assertNotEqual(FileSystemUtils.add_unique_postfix(f),
                            'md5test_2.txt')
        FileSystemUtils.force_delete_file(f)
Exemple #4
0
    def test_getFileMd5(self):
        f = os.path.join(self.results_path, 'md5test.txt')
        with open(f, 'w') as fn:
            fn.write(u"千山鸟飞绝,万径人踪灭")

        self.assertEqual(FileSystemUtils.getFileMd5(f),
                         "92e5a625b232d4c52ceb9d9330e02e44")
        FileSystemUtils.force_delete_file(f)
Exemple #5
0
    def test_unzip(self):
        p = os.path.join(self.results_path, "testcase")
        fzip = os.path.join(self.results_path, "testcase.zip")
        ZipUtils.mkzip(p, fzip)

        t = os.path.join(self.results_path, "test-unzip")
        ZipUtils.unzip(fzip, t)

        self.assertEqual(os.path.isfile(fzip), True)
        self.assertEqual(os.path.isdir(t), True)

        FileSystemUtils.force_delete_file(fzip)
        shutil.rmtree(t)
Exemple #6
0
    def test_get_value_from_cfg(self):
        results_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    "test_tmp")
        fn = os.path.join(results_path, "test.conf")
        with open(fn, 'w') as f:
            f.write("""
[device-1]
dut_ip = 192.168.1.1
user = admin
passwd = 123456

[device-2]
dut_ip = 192.168.1.2
user = admin
passwd = 123456
 
            """)

        conf = CommonUtils.get_value_from_cfg(fn)
        self.assertEqual(conf["device-1"]["dut_ip"], "192.168.1.1")
        self.assertEqual(conf["device-2"]["passwd"], "123456")
        FileSystemUtils.force_delete_file(fn)
Exemple #7
0
 def tearDown(self):
     FileSystemUtils.force_delete_file(self.file_module)