# Path: jirafs/constants.py
# TICKET_DETAILS = "fields.jira"
# TICKET_COMMENTS = "comments.read_only.jira"
# TICKET_NEW_COMMENT = "new_comment.jira"
# TICKET_LINKS = "links.jira"
# TICKET_FILE_FIELD_TEMPLATE = u"{field_name}.jira"
# LOCAL_ONLY_FILE = ".jirafs_local"
# REMOTE_IGNORE_FILE = ".jirafs_remote_ignore"
# GIT_IGNORE_FILE_PARTIAL = ".jirafs_ignore"
# GIT_IGNORE_FILE = ".jirafs/combined_ignore"
# GIT_EXCLUDE_FILE = ".jirafs/git/info/exclude"
# TICKET_OPERATION_LOG = "operation.log"
# METADATA_DIR = ".jirafs"
# GLOBAL_CONFIG = ".jirafs_config"
# TEMP_GENERATED_FILES = ".jirafs/temp-generated"
# GIT_AUTHOR = "Jirafs %s <jirafs@localhost>" % (version)
# DEFAULT_BRANCH = "master"
# CONFIG_JIRA = "jira"
# CONFIG_MAIN = "main"
# CONFIG_PLUGINS = "plugins"
# NO_DETAIL_FIELDS = ["comment", "watches", "attachment"]
# FILE_FIELDS = [
#     "description",
# ]
# FILE_FIELD_BLACKLIST = [
#     "new_comment",
#     "fields",
#     "links",
# ]
# ALLOW_USER_INPUT = True
# DEFAULT_DATE_FORMAT = "%Y-%m-%d at %H:%M:%S %Z"
# CURRENT_REPO_VERSION = 17
# 
# Path: tests/integration/base.py
# class IntegrationTestBase(TestCase):
#     def setUp(self):
#         super(IntegrationTestBase, self).setUp()
# 
#         self.jira_configured = True
# 
#         jira_env_settings = {
#             "username": "INTEGRATION_TESTING_USERNAME",
#             "url": "INTEGRATION_TESTING_URL",
#             "project": "INTEGRATION_TESTING_PROJECT",
#             "password": "INTEGRATION_TESTING_PASSWORD",
#         }
#         self.jira_env = {}
#         for key, env_var in jira_env_settings.items():
#             try:
#                 self.jira_env[key] = os.environ[env_var]
#             except KeyError:
#                 raise SkipTest(
#                     "Integration tests require the following environment "
#                     "variables to be set: %s"
#                     % (", ".join([v for k, v in jira_env_settings.items()]))
#                 )
# 
#         self.jira = JIRA(
#             {"server": self.jira_env["url"]},
#             basic_auth=(
#                 self.jira_env["username"],
#                 self.jira_env["password"],
#             ),
#         )
# 
#         self.created_issues = []
#         self.path = tempfile.mkdtemp()
# 
#     def get_jira(self, *args, **kwargs):
#         return self.jira
# 
#     def get_ticket_folder_for_path(self, path):
#         return TicketFolder(
#             path,
#             self.get_jira,
#         )
# 
#     def _get_default_fields(self):
#         return {
#             "project": {
#                 "key": self.jira_env["project"],
#             },
#             "issuetype": {"name": "Task"},
#         }
# 
#     def tearDown(self):
#         for issue in self.created_issues:
#             issue.delete()
# 
#         shutil.rmtree(self.path, ignore_errors=True)
# 
#     def create_issue(self, fields, *args, **kwargs):
#         issue_fields = self._get_default_fields()
#         issue_fields.update(fields)
# 
#         issue = self.jira.create_issue(issue_fields, *args, **kwargs)
#         self.created_issues.append(issue)
# 
#         return issue
# 
#     def run_command(self, name, **kwargs):
#         return run_command_method_with_kwargs(name, **kwargs)
# 
#     def run_from_shell(self, *args, **kwargs):
#         if "path" not in kwargs:
#             path = self.path
#         else:
#             path = kwargs["path"]
# 
#         return subprocess.Popen(
#             args,
#             stdin=subprocess.PIPE,
#             stdout=subprocess.PIPE,
#             stderr=subprocess.PIPE,
#             cwd=path,
#         )


import os
from jirafs import constants
from .base import IntegrationTestBase

        folder = self.get_ticket_folder_for_path(issue_path)
        fields = folder.get_fields()

        # Assert that the field data is on-disk as expected
        for key, value in data.items():
            self.assertEqual(value, fields.get(key))

    def test_cloning_issue_files_exist(self):
        issue_path = os.path.join(self.path, "issue")
        data = {
            "description": "This is a test description",
            "summary": "This is a test summary",
        }

        issue = self.create_issue(data)

        self.run_command(
            "clone", path=issue_path, url=issue.permalink(), jira=self.get_jira
        )

        folder = self.get_ticket_folder_for_path(issue_path)

        description_filename = constants.TICKET_FILE_FIELD_TEMPLATE.format(
            field_name="description"
        )
        expected_files = [
            constants.TICKET_DETAILS,
            constants.TICKET_COMMENTS,
            constants.TICKET_NEW_COMMENT,

# Path: jirafs/constants.py
# TICKET_DETAILS = "fields.jira"
# TICKET_COMMENTS = "comments.read_only.jira"
# TICKET_NEW_COMMENT = "new_comment.jira"
# TICKET_LINKS = "links.jira"
# TICKET_FILE_FIELD_TEMPLATE = u"{field_name}.jira"
# LOCAL_ONLY_FILE = ".jirafs_local"
# REMOTE_IGNORE_FILE = ".jirafs_remote_ignore"
# GIT_IGNORE_FILE_PARTIAL = ".jirafs_ignore"
# GIT_IGNORE_FILE = ".jirafs/combined_ignore"
# GIT_EXCLUDE_FILE = ".jirafs/git/info/exclude"
# TICKET_OPERATION_LOG = "operation.log"
# METADATA_DIR = ".jirafs"
# GLOBAL_CONFIG = ".jirafs_config"
# TEMP_GENERATED_FILES = ".jirafs/temp-generated"
# GIT_AUTHOR = "Jirafs %s <jirafs@localhost>" % (version)
# DEFAULT_BRANCH = "master"
# CONFIG_JIRA = "jira"
# CONFIG_MAIN = "main"
# CONFIG_PLUGINS = "plugins"
# NO_DETAIL_FIELDS = ["comment", "watches", "attachment"]
# FILE_FIELDS = [
#     "description",
# ]
# FILE_FIELD_BLACKLIST = [
#     "new_comment",
#     "fields",
#     "links",
# ]
# ALLOW_USER_INPUT = True
# DEFAULT_DATE_FORMAT = "%Y-%m-%d at %H:%M:%S %Z"
# CURRENT_REPO_VERSION = 17
# 
# Path: tests/integration/base.py
# class IntegrationTestBase(TestCase):
#     def setUp(self):
#         super(IntegrationTestBase, self).setUp()
# 
#         self.jira_configured = True
# 
#         jira_env_settings = {
#             "username": "INTEGRATION_TESTING_USERNAME",
#             "url": "INTEGRATION_TESTING_URL",
#             "project": "INTEGRATION_TESTING_PROJECT",
#             "password": "INTEGRATION_TESTING_PASSWORD",
#         }
#         self.jira_env = {}
#         for key, env_var in jira_env_settings.items():
#             try:
#                 self.jira_env[key] = os.environ[env_var]
#             except KeyError:
#                 raise SkipTest(
#                     "Integration tests require the following environment "
#                     "variables to be set: %s"
#                     % (", ".join([v for k, v in jira_env_settings.items()]))
#                 )
# 
#         self.jira = JIRA(
#             {"server": self.jira_env["url"]},
#             basic_auth=(
#                 self.jira_env["username"],
#                 self.jira_env["password"],
#             ),
#         )
# 
#         self.created_issues = []
#         self.path = tempfile.mkdtemp()
# 
#     def get_jira(self, *args, **kwargs):
#         return self.jira
# 
#     def get_ticket_folder_for_path(self, path):
#         return TicketFolder(
#             path,
#             self.get_jira,
#         )
# 
#     def _get_default_fields(self):
#         return {
#             "project": {
#                 "key": self.jira_env["project"],
#             },
#             "issuetype": {"name": "Task"},
#         }
# 
#     def tearDown(self):
#         for issue in self.created_issues:
#             issue.delete()
# 
#         shutil.rmtree(self.path, ignore_errors=True)
# 
#     def create_issue(self, fields, *args, **kwargs):
#         issue_fields = self._get_default_fields()
#         issue_fields.update(fields)
# 
#         issue = self.jira.create_issue(issue_fields, *args, **kwargs)
#         self.created_issues.append(issue)
# 
#         return issue
# 
#     def run_command(self, name, **kwargs):
#         return run_command_method_with_kwargs(name, **kwargs)
# 
#     def run_from_shell(self, *args, **kwargs):
#         if "path" not in kwargs:
#             path = self.path
#         else:
#             path = kwargs["path"]
# 
#         return subprocess.Popen(
#             args,
#             stdin=subprocess.PIPE,
#             stdout=subprocess.PIPE,
#             stderr=subprocess.PIPE,
#             cwd=path,
#         )


# Path: tests/integration/test_clone_issue.py
import os
from jirafs import constants
from .base import IntegrationTestBase


        folder = self.get_ticket_folder_for_path(issue_path)
        fields = folder.get_fields()

        # Assert that the field data is on-disk as expected
        for key, value in data.items():
            self.assertEqual(value, fields.get(key))

    def test_cloning_issue_files_exist(self):
        issue_path = os.path.join(self.path, "issue")
        data = {
            "description": "This is a test description",
            "summary": "This is a test summary",
        }

        issue = self.create_issue(data)

        self.run_command(
            "clone", path=issue_path, url=issue.permalink(), jira=self.get_jira
        )

        folder = self.get_ticket_folder_for_path(issue_path)

        description_filename = constants.TICKET_FILE_FIELD_TEMPLATE.format(
            field_name="description"
        )
        expected_files = [
            constants.TICKET_DETAILS,
            constants.TICKET_COMMENTS,
            constants.TICKET_NEW_COMMENT,

            constants.TICKET_LINKS,