# Path: test/stub_environment.py
# class StubEnvironment(object):
#     def __init__(self):
#         self.cwd = None
#         self.tree = None
#         self.argument = None
# 
# Path: test/stub_config.py
# 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: googkit/commands/lint.py
# class LintCommand(Command):
#     @classmethod
#     def needs_project_config(cls):
#         return True
# 
#     def _sources(self):
#         js_dev = self.config.js_dev_dir()
#         deps_js = self.config.deps_js()
# 
#         pattern = os.path.join(js_dev, '*.js')
#         paths = glob.glob(pattern)
# 
#         if deps_js in paths:
#             paths.remove(deps_js)
#         return paths
# 
#     def lint(self):
#         """Lints project resouces by using Closure Linter.
#         """
#         if googkit.lib.file.which('gjslint') is None:
#             raise GoogkitError(_('Required command not found: gjslint'))
# 
#         paths = self._sources()
#         args = OptionBuilder()
# 
#         flagfile = self.config.linter_flagfile()
#         if os.path.exists(flagfile):
#             args.add('--flagfile', flagfile)
# 
#         cmd = ['gjslint'] + [str(arg) for arg in args] + paths
# 
#         popen_args = {
#             'stdout': subprocess.PIPE,
#             'stderr': subprocess.PIPE
#         }
# 
#         proc = subprocess.Popen(cmd, **popen_args)
#         result = proc.communicate()
# 
#         logging.info(result[0].decode())
# 
#     def run_internal(self):
#         project_root = googkit.lib.path.project_root(self.env.cwd)
#         with working_directory(project_root):
#             self.lint()


import unittest
import subprocess
import os.path
from test.stub_environment import StubEnvironment
from test.stub_config import StubConfigOnStubProject
from googkit.compat.unittest import mock
from googkit.commands.lint import LintCommand


class TestLintCommand(unittest.TestCase):
    def setUp(self):
        self.env = StubEnvironment()
        self.cmd = LintCommand(self.env)
        self.cmd.config = StubConfigOnStubProject()

    def test_needs_project_config(self):

# Path: test/stub_environment.py
# class StubEnvironment(object):
#     def __init__(self):
#         self.cwd = None
#         self.tree = None
#         self.argument = None
# 
# Path: test/stub_config.py
# 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: googkit/commands/lint.py
# class LintCommand(Command):
#     @classmethod
#     def needs_project_config(cls):
#         return True
# 
#     def _sources(self):
#         js_dev = self.config.js_dev_dir()
#         deps_js = self.config.deps_js()
# 
#         pattern = os.path.join(js_dev, '*.js')
#         paths = glob.glob(pattern)
# 
#         if deps_js in paths:
#             paths.remove(deps_js)
#         return paths
# 
#     def lint(self):
#         """Lints project resouces by using Closure Linter.
#         """
#         if googkit.lib.file.which('gjslint') is None:
#             raise GoogkitError(_('Required command not found: gjslint'))
# 
#         paths = self._sources()
#         args = OptionBuilder()
# 
#         flagfile = self.config.linter_flagfile()
#         if os.path.exists(flagfile):
#             args.add('--flagfile', flagfile)
# 
#         cmd = ['gjslint'] + [str(arg) for arg in args] + paths
# 
#         popen_args = {
#             'stdout': subprocess.PIPE,
#             'stderr': subprocess.PIPE
#         }
# 
#         proc = subprocess.Popen(cmd, **popen_args)
#         result = proc.communicate()
# 
#         logging.info(result[0].decode())
# 
#     def run_internal(self):
#         project_root = googkit.lib.path.project_root(self.env.cwd)
#         with working_directory(project_root):
#             self.lint()


# Path: test/commands/test_lint.py
import unittest
import subprocess
import os.path
from test.stub_environment import StubEnvironment
from test.stub_config import StubConfigOnStubProject
from googkit.compat.unittest import mock
from googkit.commands.lint import LintCommand



class TestLintCommand(unittest.TestCase):
    def setUp(self):
        self.env = StubEnvironment()
        self.cmd = LintCommand(self.env)
        self.cmd.config = StubConfigOnStubProject()

    def test_needs_project_config(self):

        self.assertTrue(LintCommand.needs_project_config())