# Path: project_generator/commands/generate.py
# def _setup_logging(args):
# def _generate_project(project, args):
# def run(args):
# def _get_default_jobs():
# def setup(subparser):
# 
# Path: project_generator/commands/clean.py
# def run(args):
# def setup(subparser):
# 
# Path: tests/test_commands/simple_project.py



import argparse
import os
import yaml
import shutil
from unittest import TestCase
from project_generator.commands import generate, clean
from .simple_project import project_1_yaml, projects_yaml, project_2_yaml
class TestCleanCommand(TestCase):

    """test clean command"""

    def setUp(self):
        if not os.path.exists('test_workspace'):
            os.makedirs('test_workspace')
        # write project file
        with open(os.path.join(os.getcwd(), 'test_workspace/project_1.yaml'), 'wt') as f:
            f.write(yaml.dump(project_1_yaml, default_flow_style=False))
        # write project file
        with open(os.path.join(os.getcwd(), 'test_workspace/project_2.yaml'), 'wt') as f:
            f.write(yaml.dump(project_2_yaml, default_flow_style=False))
        # write projects file
        with open(os.path.join(os.getcwd(), 'test_workspace/projects.yaml'), 'wt') as f:
            f.write(yaml.dump(projects_yaml, default_flow_style=False))

        self.parser = argparse.ArgumentParser()
        subparsers = self.parser.add_subparsers(help='commands')
        self.export_subparser = subparsers.add_parser('generate', help=generate.help)
        self.clean_subparser = subparsers.add_parser('clean', help=clean.help)

    def tearDown(self):
        # remove created directory
        shutil.rmtree('test_workspace', ignore_errors=True)
        shutil.rmtree('generated_projects', ignore_errors=True)


    def test_clean_one_project(self):
        # We first generate project, then clean it

# Path: project_generator/commands/generate.py
# def _setup_logging(args):
# def _generate_project(project, args):
# def run(args):
# def _get_default_jobs():
# def setup(subparser):
# 
# Path: project_generator/commands/clean.py
# def run(args):
# def setup(subparser):
# 
# Path: tests/test_commands/simple_project.py



# Path: tests/test_commands/test_clean.py
import argparse
import os
import yaml
import shutil
from unittest import TestCase
from project_generator.commands import generate, clean
from .simple_project import project_1_yaml, projects_yaml, project_2_yaml

class TestCleanCommand(TestCase):

    """test clean command"""

    def setUp(self):
        if not os.path.exists('test_workspace'):
            os.makedirs('test_workspace')
        # write project file
        with open(os.path.join(os.getcwd(), 'test_workspace/project_1.yaml'), 'wt') as f:
            f.write(yaml.dump(project_1_yaml, default_flow_style=False))
        # write project file
        with open(os.path.join(os.getcwd(), 'test_workspace/project_2.yaml'), 'wt') as f:
            f.write(yaml.dump(project_2_yaml, default_flow_style=False))
        # write projects file
        with open(os.path.join(os.getcwd(), 'test_workspace/projects.yaml'), 'wt') as f:
            f.write(yaml.dump(projects_yaml, default_flow_style=False))

        self.parser = argparse.ArgumentParser()
        subparsers = self.parser.add_subparsers(help='commands')
        self.export_subparser = subparsers.add_parser('generate', help=generate.help)
        self.clean_subparser = subparsers.add_parser('clean', help=clean.help)

    def tearDown(self):
        # remove created directory
        shutil.rmtree('test_workspace', ignore_errors=True)
        shutil.rmtree('generated_projects', ignore_errors=True)


    def test_clean_one_project(self):
        # We first generate project, then clean it

        generate.setup(self.export_subparser)