コード例 #1
0
ファイル: test_main.py プロジェクト: pirtim/task_manage_zfb
class TestMain(unittest.TestCase):
    def setUp(self):
        self.my_master_config = MasterConfig(master_configfile_path)
        self.my_worker_config = WorkerConfig(worker_configfile_path)
        help_set_up()

    def test__on_worker(self):
        self.assertFalse(_on_worker(test_folder_path))
        self.my_master_config.write_configfile()
        self.assertFalse(_on_worker(test_folder_path))
        self.my_worker_config.write_configfile()
        self.assertTrue(_on_worker(test_folder_path))

    def test_makeBucket_on_master(self):
        self.my_master_config.write_configfile()
        my_bucket = Bucket('raz', test_folder_path)
        self.assertIsInstance(my_bucket, mb.MasterBucket)

    def test_makeBucket_on_master_local_test(self):
        self.my_master_config.write_configfile()
        my_bucket = Bucket('raz', test_folder_path, True)
        self.assertIsInstance(my_bucket, wb.Bucket)

    def test_makeBucket_on_worker(self):
        self.my_worker_config.write_configfile()
        my_bucket = Bucket('raz', test_folder_path)
        self.assertIsInstance(my_bucket, wb.Bucket)

    def tearDown(self):
        help_tear_down()
コード例 #2
0
ファイル: test_config.py プロジェクト: pirtim/task_manage_zfb
class TestWorkerConfig(unittest.TestCase):
    def setUp(self):
        help_set_up()
        self.my_config = WorkerConfig(test_configfile_path)

    def test_WorkerConfig_write_configfile(self):
        self.assertFalse(os.path.isfile(test_configfile_path))
        self.my_config.write_configfile()
        self.assertTrue(os.path.isfile(test_configfile_path))
        with open(test_configfile_path, 'rb') as configfile:
            self.assertEqual(configfile.read(), '# -*- task_manage_zfb: worker -*-\n')
        self.assertEqual(os.path.getsize(test_configfile_path), 34L)

    def test_WorkerConfig_is_config_file(self):
        self.my_config.write_configfile()
        self.assertFalse(WorkerConfig.is_config_file(normalfile_path))
        self.assertTrue(WorkerConfig.is_config_file(test_configfile_path))

    def tearDown(self):
        help_tear_down()