def test_task_run_all_tasks(self, d): os.chdir(d.path) file_content = """ file = open("test-target-file.txt", "w") file.write("{0}") file.close() """ file_content = file_content.format(Constants.PROJECT_NAME) file_path = os.path.join(d.path, 'test-file.py') target_file_path = os.path.join(d.path, 'test-target-file.txt') d.write(file_path, file_content.encode('utf-8')) task = Task(task_type=Task.TYPE_RUN, task_name='Sample run task - run all tasks', task_params={'args': ['python', file_path]}) process_data = ProcessData() template_data = {} task.parse(process_data) Task.run_all_tasks([task], process_data=process_data, template_data=template_data, working_dir=d.path) content = FileUtil.read_file(target_file_path) self.assertEqual(Constants.PROJECT_NAME, content)
def test_target_github_parse_file(self, d): os.chdir(d.path) project_file_data = """ config: name: EzoRed targets: - name: github-test repository: name: ezored/target-github-test type: github version: b:master dependencies: - repository: name: ezored/dependency-github-test type: github version: b:master """ d.write(Constants.PROJECT_FILE, project_file_data.encode('utf-8')) output = popen(['ezored', 'dependency', 'update', '-d'], stdout=PIPE).communicate()[0] output = str(output) print(output) output = popen(['ezored', 'target', 'build', 'github-test', '-d'], stdout=PIPE).communicate()[0] output = str(output) print(output) required = 'Build finished for target: github-test' self.assertTrue(required in output) file_to_read = os.path.join('vendor', 'target-github-test-master', 'file-to-parse.txt') self.assertTrue(os.path.exists(file_to_read)) content = FileUtil.read_file(file_to_read) self.assertEqual(content, Constants.PROJECT_NAME)
def test_task_parse_file(self, d): os.chdir(d.path) file_path = os.path.join(d.path, '*.txt') d.write(file_path, '{{ name }}'.encode('utf-8')) task = Task(task_type=Task.TYPE_PARSE_FILE, task_name='Sample parse file task', task_params={'file': file_path}) process_data = ProcessData() template_data = {'name': Constants.PROJECT_NAME} task.parse(process_data) task.run(process_data=process_data, template_data=template_data, working_dir=d.path) content = FileUtil.read_file(file_path) self.assertEqual(Constants.PROJECT_NAME, content)