Exemple #1
0
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()
class TestMasterConfig(unittest.TestCase):
    def setUp(self):
        help_set_up()
        self.my_config = MasterConfig(test_configfile_path)

    def test_MasterConfig_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.readline(), '# -*- task_manage_zfb: master -*-\n')
            self.assertEqual(configfile.readline(), '[SSH]\n')
        self.assertEqual(os.path.getsize(test_configfile_path), 273L)

    def test_MasterConfig_ready(self):
        pass

    def test_MasterConfig_is_config_file(self):
        self.my_config.write_configfile()
        self.assertFalse(MasterConfig.is_config_file(normalfile_path))
        self.assertTrue(MasterConfig.is_config_file(test_configfile_path))

    def tearDown(self):
        help_tear_down()