# Path: test/stub_config.py
# class StubConfig(object):
#     def __init__(self):
#         pass
# 
#     def development_dir(self):
#         return StubConfig.DEVELOPMENT_DIR
# 
#     def debug_dir(self):
#         return StubConfig.DEBUG_DIR
# 
#     def production_dir(self):
#         return StubConfig.PRODUCTION_DIR
# 
#     def compiled_js_ext(self):
#         return StubConfig.COMPILED_JS_EXT
# 
#     def test_file_pattern(self):
#         return StubConfig.TEST_FILE_PATTERN
# 
#     def library_root(self):
#         return StubConfig.LIBRARRY_ROOT
# 
#     def closurebuilder(self):
#         return StubConfig.CLOSUREBUILDER
# 
#     def depswriter(self):
#         return StubConfig.DEPSWRITER
# 
#     def compiler_root(self):
#         return StubConfig.COMPILER_ROOT
# 
#     def base_js(self):
#         return StubConfig.BASE_JS
# 
#     def multitestrunner_css(self):
#         return StubConfig.MULTI_TEST_RUNNER_CSS
# 
#     def js_dev_dir(self):
#         return StubConfig.JS_DEV_DIR
# 
#     def deps_js(self):
#         return StubConfig.DEPS_JS
# 
#     def testrunner(self):
#         return StubConfig.TESTRUNNER
# 
#     def compiler(self):
#         return StubConfig.COMPILER
# 
#     def compilation_level(self):
#         return StubConfig.COMPILATION_LEVEL
# 
#     def compiler_zip(self):
#         return StubConfig.COMPILER_LATEST_ZIP
# 
#     def library_repos(self):
#         return StubConfig.LIBRARY_GIT_REPOS
# 
#     def compiler_flagfile(self):
#         return StubConfig.COMPILER_FLAGFILE
# 
#     def compiler_flagfile_for_debug(self):
#         return StubConfig.COMPILER_FLAGFILE_FOR_DEBUG
# 
#     def linter_flagfile(self):
#         return StubConfig.LINTER_FLAGFILE
# 
# class StubConfigOnStubProject(object):
#     def __init__(self):
#         pass
# 
#     def development_dir(self):
#         return StubConfigOnStubProject.DEVELOPMENT_DIR
# 
#     def debug_dir(self):
#         return StubConfigOnStubProject.DEBUG_DIR
# 
#     def production_dir(self):
#         return StubConfigOnStubProject.PRODUCTION_DIR
# 
#     def compiled_js_ext(self):
#         return StubConfigOnStubProject.COMPILED_JS_EXT
# 
#     def test_file_pattern(self):
#         return StubConfigOnStubProject.TEST_FILE_PATTERN
# 
#     def library_root(self):
#         return StubConfigOnStubProject.LIBRARRY_ROOT
# 
#     def closurebuilder(self):
#         return StubConfigOnStubProject.CLOSUREBUILDER
# 
#     def depswriter(self):
#         return StubConfigOnStubProject.DEPSWRITER
# 
#     def compiler_root(self):
#         return StubConfigOnStubProject.COMPILER_ROOT
# 
#     def base_js(self):
#         return StubConfigOnStubProject.BASE_JS
# 
#     def multitestrunner_css(self):
#         return StubConfigOnStubProject.MULTI_TEST_RUNNER_CSS
# 
#     def js_dev_dir(self):
#         return StubConfigOnStubProject.JS_DEV_DIR
# 
#     def deps_js(self):
#         return StubConfigOnStubProject.DEPS_JS
# 
#     def testrunner(self):
#         return StubConfigOnStubProject.TESTRUNNER
# 
#     def compiler(self):
#         return StubConfigOnStubProject.COMPILER
# 
#     def compilation_level(self):
#         return StubConfigOnStubProject.COMPILATION_LEVEL
# 
#     def compiler_zip(self):
#         return StubConfigOnStubProject.COMPILER_LATEST_ZIP
# 
#     def library_repos(self):
#         return StubConfigOnStubProject.LIBRARY_GIT_REPOS
# 
#     def compiler_flagfile(self):
#         return StubConfigOnStubProject.COMPILER_FLAGFILE
# 
#     def compiler_flagfile_for_debug(self):
#         return StubConfigOnStubProject.COMPILER_FLAGFILE_FOR_DEBUG
# 
#     def linter_flagfile(self):
#         return StubConfigOnStubProject.LINTER_FLAGFILE
# 
# Path: test/stub_environment.py
# class StubEnvironment(object):
#     def __init__(self):
#         self.cwd = None
#         self.tree = None
#         self.argument = None


import unittest
import doctest
import os
import subprocess
import googkit.lib.strutil
import googkit.commands.build
from googkit.compat.unittest import mock
from test.stub_config import StubConfig, StubConfigOnStubProject
from test.stub_environment import StubEnvironment

        # Read lines has "\n" at each last
        mock_fp.__iter__.return_value = iter([(line + '\n') for line in read_data.split('\n')])

        # Switch to the mock_open from the original open
        with mock.patch('os.sep', new='/'), \
                mock.patch('googkit.commands.build.open', mock_open, create=True):
            self.cmd.compile_resource(tgt_path)

        # Expected the target file was opened twice for reading and writing
        mock_open.assert_any_call(tgt_path)
        mock_open.assert_any_call(tgt_path, 'w')

        # Expected correct data was wrote
        self.assertEqual(
            mock_fp.write.call_args_list,
            [mock.call(line + '\n',) for line in expected.split('\n')])

    def test_setup_files(self):
        self.cmd.config = StubConfigOnStubProject()
        self.cmd.compile_resource = mock.MagicMock()

        with mock.patch.object(BuildCommand, 'ignore_dirs') as mock_ignore_dirs, \
                mock.patch('googkit.lib.file.copytree') as mock_copytree:
            mock_ignore_dirs.return_value = 'IGNORE'

            self.cmd.setup_files(StubConfigOnStubProject.PRODUCTION_DIR, False)

        mock_copytree.assert_called_once_with(
            StubConfigOnStubProject.DEVELOPMENT_DIR,

# Path: test/stub_config.py
# class StubConfig(object):
#     def __init__(self):
#         pass
# 
#     def development_dir(self):
#         return StubConfig.DEVELOPMENT_DIR
# 
#     def debug_dir(self):
#         return StubConfig.DEBUG_DIR
# 
#     def production_dir(self):
#         return StubConfig.PRODUCTION_DIR
# 
#     def compiled_js_ext(self):
#         return StubConfig.COMPILED_JS_EXT
# 
#     def test_file_pattern(self):
#         return StubConfig.TEST_FILE_PATTERN
# 
#     def library_root(self):
#         return StubConfig.LIBRARRY_ROOT
# 
#     def closurebuilder(self):
#         return StubConfig.CLOSUREBUILDER
# 
#     def depswriter(self):
#         return StubConfig.DEPSWRITER
# 
#     def compiler_root(self):
#         return StubConfig.COMPILER_ROOT
# 
#     def base_js(self):
#         return StubConfig.BASE_JS
# 
#     def multitestrunner_css(self):
#         return StubConfig.MULTI_TEST_RUNNER_CSS
# 
#     def js_dev_dir(self):
#         return StubConfig.JS_DEV_DIR
# 
#     def deps_js(self):
#         return StubConfig.DEPS_JS
# 
#     def testrunner(self):
#         return StubConfig.TESTRUNNER
# 
#     def compiler(self):
#         return StubConfig.COMPILER
# 
#     def compilation_level(self):
#         return StubConfig.COMPILATION_LEVEL
# 
#     def compiler_zip(self):
#         return StubConfig.COMPILER_LATEST_ZIP
# 
#     def library_repos(self):
#         return StubConfig.LIBRARY_GIT_REPOS
# 
#     def compiler_flagfile(self):
#         return StubConfig.COMPILER_FLAGFILE
# 
#     def compiler_flagfile_for_debug(self):
#         return StubConfig.COMPILER_FLAGFILE_FOR_DEBUG
# 
#     def linter_flagfile(self):
#         return StubConfig.LINTER_FLAGFILE
# 
# class StubConfigOnStubProject(object):
#     def __init__(self):
#         pass
# 
#     def development_dir(self):
#         return StubConfigOnStubProject.DEVELOPMENT_DIR
# 
#     def debug_dir(self):
#         return StubConfigOnStubProject.DEBUG_DIR
# 
#     def production_dir(self):
#         return StubConfigOnStubProject.PRODUCTION_DIR
# 
#     def compiled_js_ext(self):
#         return StubConfigOnStubProject.COMPILED_JS_EXT
# 
#     def test_file_pattern(self):
#         return StubConfigOnStubProject.TEST_FILE_PATTERN
# 
#     def library_root(self):
#         return StubConfigOnStubProject.LIBRARRY_ROOT
# 
#     def closurebuilder(self):
#         return StubConfigOnStubProject.CLOSUREBUILDER
# 
#     def depswriter(self):
#         return StubConfigOnStubProject.DEPSWRITER
# 
#     def compiler_root(self):
#         return StubConfigOnStubProject.COMPILER_ROOT
# 
#     def base_js(self):
#         return StubConfigOnStubProject.BASE_JS
# 
#     def multitestrunner_css(self):
#         return StubConfigOnStubProject.MULTI_TEST_RUNNER_CSS
# 
#     def js_dev_dir(self):
#         return StubConfigOnStubProject.JS_DEV_DIR
# 
#     def deps_js(self):
#         return StubConfigOnStubProject.DEPS_JS
# 
#     def testrunner(self):
#         return StubConfigOnStubProject.TESTRUNNER
# 
#     def compiler(self):
#         return StubConfigOnStubProject.COMPILER
# 
#     def compilation_level(self):
#         return StubConfigOnStubProject.COMPILATION_LEVEL
# 
#     def compiler_zip(self):
#         return StubConfigOnStubProject.COMPILER_LATEST_ZIP
# 
#     def library_repos(self):
#         return StubConfigOnStubProject.LIBRARY_GIT_REPOS
# 
#     def compiler_flagfile(self):
#         return StubConfigOnStubProject.COMPILER_FLAGFILE
# 
#     def compiler_flagfile_for_debug(self):
#         return StubConfigOnStubProject.COMPILER_FLAGFILE_FOR_DEBUG
# 
#     def linter_flagfile(self):
#         return StubConfigOnStubProject.LINTER_FLAGFILE
# 
# Path: test/stub_environment.py
# class StubEnvironment(object):
#     def __init__(self):
#         self.cwd = None
#         self.tree = None
#         self.argument = None


# Path: test/commands/test_build.py
import unittest
import doctest
import os
import subprocess
import googkit.lib.strutil
import googkit.commands.build
from googkit.compat.unittest import mock
from test.stub_config import StubConfig, StubConfigOnStubProject
from test.stub_environment import StubEnvironment


        # Read lines has "\n" at each last
        mock_fp.__iter__.return_value = iter([(line + '\n') for line in read_data.split('\n')])

        # Switch to the mock_open from the original open
        with mock.patch('os.sep', new='/'), \
                mock.patch('googkit.commands.build.open', mock_open, create=True):
            self.cmd.compile_resource(tgt_path)

        # Expected the target file was opened twice for reading and writing
        mock_open.assert_any_call(tgt_path)
        mock_open.assert_any_call(tgt_path, 'w')

        # Expected correct data was wrote
        self.assertEqual(
            mock_fp.write.call_args_list,
            [mock.call(line + '\n',) for line in expected.split('\n')])

    def test_setup_files(self):
        self.cmd.config = StubConfigOnStubProject()
        self.cmd.compile_resource = mock.MagicMock()

        with mock.patch.object(BuildCommand, 'ignore_dirs') as mock_ignore_dirs, \
                mock.patch('googkit.lib.file.copytree') as mock_copytree:
            mock_ignore_dirs.return_value = 'IGNORE'

            self.cmd.setup_files(StubConfigOnStubProject.PRODUCTION_DIR, False)

        mock_copytree.assert_called_once_with(
            StubConfigOnStubProject.DEVELOPMENT_DIR,

            StubConfigOnStubProject.PRODUCTION_DIR,