# Path: gen_manifest/gen_manifest.py
# ALL_LANGS = ["python", "java", "csharp", "nodejs", "ruby", "php", "go"]
# BASEPATH_KEY = 'basepath'
# BASEPATH_DEFAULT = '.'
# BIN_KEY = 'bin'
# INVOCATION_KEY = 'invocation'
# def emit_manifest_v3(tags, sample_globs, flat):
# def create_factored_manifest_v3(tags, sample_globs):
# def create_flat_manifest_v3(tags, sample_globs):
# def emit_manifest_v2(tags, sample_globs, flat):
# def create_manifest_v2(tags, sample_globs):
# def path_sample_pairs_v2(sample_globs):
# def forbid_names(tags, *forbidden_names):
# def escape(text):
# def get_region_tag(sample_file_path):
# def glob_non_yaml(all_patterns):
# def dict_representer(dumper, data):
# def dump(manifest):
# def parse_files_and_tags(params: List[str]) -> (List[str], List[str]):
# def main(schema_version: str, output: str, flat: bool, files_and_tags: List[str]):
# class GenManifestError(Exception):
# class TagNameError(GenManifestError):
# class RegionTagError(GenManifestError):
# class NotRegularFileError(GenManifestError):
# class UnrecognizedLanguageError(GenManifestError):


from glob import glob
from click.testing import CliRunner
from collections import OrderedDict
from gen_manifest import gen_manifest
from textwrap import dedent
import unittest
import os

  def test_generation_v3_factored(self):
    self.maxDiff = None
    BIN = '/my/bin/'
    INVOCATION = 'call this way'
    CHDIR = '@/this/working/path/'
    ENVIRONMENT = 'python'

    gen_manifest_cwd = os.path.abspath(os.path.join(_ABS_DIR, '..', '..'))
    sample_relative_path = os.path.join('tests','testdata','gen_manifest')
    sample_path = os.path.abspath(os.path.join(gen_manifest_cwd, sample_relative_path))
    manifest_string = gen_manifest.emit_manifest_v3(
        tags = [('environment', ENVIRONMENT),
                ('bin', BIN),
                ('invocation', INVOCATION),
                ('chdir', CHDIR)],
        sample_globs = [os.path.join(sample_relative_path, 'readbook.py'),
                        os.path.join(sample_relative_path, 'getbook.py')],
        flat = False)

    expected_string = dedent(f"""\
      type: manifest/samples
      schema_version: 3
      base: &common
        environment: '{ENVIRONMENT}'
        bin: '{BIN}'
        invocation: '{INVOCATION}'
        chdir: '{CHDIR}'
        basepath: '.'
      samples:

# Path: gen_manifest/gen_manifest.py
# ALL_LANGS = ["python", "java", "csharp", "nodejs", "ruby", "php", "go"]
# BASEPATH_KEY = 'basepath'
# BASEPATH_DEFAULT = '.'
# BIN_KEY = 'bin'
# INVOCATION_KEY = 'invocation'
# def emit_manifest_v3(tags, sample_globs, flat):
# def create_factored_manifest_v3(tags, sample_globs):
# def create_flat_manifest_v3(tags, sample_globs):
# def emit_manifest_v2(tags, sample_globs, flat):
# def create_manifest_v2(tags, sample_globs):
# def path_sample_pairs_v2(sample_globs):
# def forbid_names(tags, *forbidden_names):
# def escape(text):
# def get_region_tag(sample_file_path):
# def glob_non_yaml(all_patterns):
# def dict_representer(dumper, data):
# def dump(manifest):
# def parse_files_and_tags(params: List[str]) -> (List[str], List[str]):
# def main(schema_version: str, output: str, flat: bool, files_and_tags: List[str]):
# class GenManifestError(Exception):
# class TagNameError(GenManifestError):
# class RegionTagError(GenManifestError):
# class NotRegularFileError(GenManifestError):
# class UnrecognizedLanguageError(GenManifestError):


# Path: tests/gen_manifest/gen_manifest_test.py
from glob import glob
from click.testing import CliRunner
from collections import OrderedDict
from gen_manifest import gen_manifest
from textwrap import dedent
import unittest
import os


  def test_generation_v3_factored(self):
    self.maxDiff = None
    BIN = '/my/bin/'
    INVOCATION = 'call this way'
    CHDIR = '@/this/working/path/'
    ENVIRONMENT = 'python'

    gen_manifest_cwd = os.path.abspath(os.path.join(_ABS_DIR, '..', '..'))
    sample_relative_path = os.path.join('tests','testdata','gen_manifest')
    sample_path = os.path.abspath(os.path.join(gen_manifest_cwd, sample_relative_path))
    manifest_string = gen_manifest.emit_manifest_v3(
        tags = [('environment', ENVIRONMENT),
                ('bin', BIN),
                ('invocation', INVOCATION),
                ('chdir', CHDIR)],
        sample_globs = [os.path.join(sample_relative_path, 'readbook.py'),
                        os.path.join(sample_relative_path, 'getbook.py')],
        flat = False)

    expected_string = dedent(f"""\
      type: manifest/samples
      schema_version: 3
      base: &common
        environment: '{ENVIRONMENT}'
        bin: '{BIN}'
        invocation: '{INVOCATION}'
        chdir: '{CHDIR}'
        basepath: '.'
      samples:

      - <<: *common