# Path: bugwarrior/config/data.py
# def get_data_path(taskrc):
#     def __init__(self, data_path):
#     def get_data(self):
#     def get(self, key):
#     def set(self, key, value):
# class BugwarriorData:
# 
# Path: bugwarrior/config/load.py
# BUGWARRIORRC = "BUGWARRIORRC"
# def configure_logging(logfile, loglevel):
# def get_config_path():
# def remove_inactive_flavors(rawconfig, main_section):
# def load_config(main_section, interactive):
#     def __init__(self, *args, allow_no_value=True, **kwargs):
#     def getint(self, section, option):
#     def optionxform(option):
# class BugwarriorConfigParser(configparser.ConfigParser):
# 
# Path: bugwarrior/config/schema.py
# class StrippedTrailingSlashUrl(pydantic.AnyUrl):
# class UrlSchemeError(pydantic.errors.UrlSchemeError):
# class NoSchemeUrl(StrippedTrailingSlashUrl):
# class ConfigList(frozenset):
# class ExpandedPath(type(pathlib.Path())):  # type: ignore
# class LoggingPath(ExpandedPath):
# class TaskrcPath(ExpandedPath):
# class PydanticConfig(pydantic.BaseConfig):
# class MainSectionConfig(pydantic.BaseModel):
#     class Config(PydanticConfig):
# class Hooks(pydantic.BaseModel):
# class Notifications(pydantic.BaseModel):
# class SchemaBase(pydantic.BaseSettings):
# class ValidationErrorEnhancedMessages(list):
# class ServiceConfigMetaclass(pydantic.main.ModelMetaclass):
#             class PydanticServiceConfig(PydanticConfig):
# class ServiceConfig(_ServiceConfig,  # type: ignore  # (dynamic base class)
#                     metaclass=ServiceConfigMetaclass, prefix=None):
#     def validate(cls, value, field, config):
#     def validate_parts(
#             cls, parts: typing.Dict[str, str]) -> typing.Dict[str, str]:
#     def __get_validators__(cls):
#     def validate(cls, value):
#     def __get_validators__(cls):
#     def validate(cls, path):
#     def validate(cls, path):
#     def validate(cls, path):
#         def alias_generator(string: str) -> str:
#     def __init__(self, error: pydantic.ValidationError, targets, main_section):
#     def __str__(self):
#     def display_error_loc(e):
#     def display_error(self, e, error, model):
#     def flatten(self, err, loc=None):
# def raise_validation_error(msg, config_path, no_errors=1):
# def validate_config(config, main_section, config_path):
#     def __new__(mcs, name, bases, namespace, prefix, **kwargs):
#                 def alias_generator(string: str) -> str:
#     DEFAULT: dict  # configparser feature
# 
# Path: tests/base.py
# class ConfigTest(unittest.TestCase):
#     """
#     Creates config files, configures the environment, and cleans up afterwards.
#     """
#     def setUp(self):
#         self.old_environ = os.environ.copy()
#         self.tempdir = tempfile.mkdtemp(prefix='bugwarrior')
# 
#         # Create temporary config files.
#         self.taskrc = os.path.join(self.tempdir, '.taskrc')
#         self.lists_path = os.path.join(self.tempdir, 'lists')
#         os.mkdir(self.lists_path)
#         with open(self.taskrc, 'w+') as fout:
#             fout.write('data.location=%s\n' % self.lists_path)
# 
#         # Configure environment.
#         os.environ['HOME'] = self.tempdir
#         os.environ.pop(config.BUGWARRIORRC, None)
#         os.environ.pop('TASKRC', None)
#         os.environ.pop('XDG_CONFIG_HOME', None)
#         os.environ.pop('XDG_CONFIG_DIRS', None)
# 
#     def tearDown(self):
#         shutil.rmtree(self.tempdir, ignore_errors=True)
#         os.environ = self.old_environ
# 
#     @pytest.fixture(autouse=True)
#     def inject_fixtures(self, caplog):
#         self.caplog = caplog
# 
#     def validate(self):
#         conf = schema.validate_config(self.config, 'general', 'configpath')
#         conf['general'].data = data.BugwarriorData(self.lists_path)
#         conf['general'].interactive = False
#         return conf
# 
#     def assertValidationError(self, expected):
# 
#         with self.assertRaises(SystemExit):
#             self.validate()
# 
#         # Only one message should be logged.
#         self.assertEqual(len(self.caplog.records), 1)
# 
#         self.assertIn(expected, self.caplog.records[0].message)


import os
import json
from bugwarrior.config import data, load, schema
from ..base import ConfigTest
        super().setUp()
        self.data = data.BugwarriorData(self.lists_path)

    def assert0600(self):
        permissions = oct(os.stat(self.data.datafile).st_mode & 0o777)
        # python2 -> 0600, python3 -> 0o600
        self.assertIn(permissions, ['0600', '0o600'])

    def test_get_set(self):
        # "touch" data file.
        with open(self.data.datafile, 'w+') as handle:
            json.dump({'old': 'stuff'}, handle)

        self.data.set('key', 'value')

        self.assertEqual(self.data.get('key'), 'value')
        self.assertEqual(
            self.data.get_data(), {'old': 'stuff', 'key': 'value'})
        self.assert0600()

    def test_set_first_time(self):
        self.data.set('key', 'value')

        self.assertEqual(self.data.get('key'), 'value')
        self.assert0600()

    def test_path_attribute(self):
        self.assertEqual(self.data.path, self.lists_path)



# Path: bugwarrior/config/data.py
# def get_data_path(taskrc):
#     def __init__(self, data_path):
#     def get_data(self):
#     def get(self, key):
#     def set(self, key, value):
# class BugwarriorData:
# 
# Path: bugwarrior/config/load.py
# BUGWARRIORRC = "BUGWARRIORRC"
# def configure_logging(logfile, loglevel):
# def get_config_path():
# def remove_inactive_flavors(rawconfig, main_section):
# def load_config(main_section, interactive):
#     def __init__(self, *args, allow_no_value=True, **kwargs):
#     def getint(self, section, option):
#     def optionxform(option):
# class BugwarriorConfigParser(configparser.ConfigParser):
# 
# Path: bugwarrior/config/schema.py
# class StrippedTrailingSlashUrl(pydantic.AnyUrl):
# class UrlSchemeError(pydantic.errors.UrlSchemeError):
# class NoSchemeUrl(StrippedTrailingSlashUrl):
# class ConfigList(frozenset):
# class ExpandedPath(type(pathlib.Path())):  # type: ignore
# class LoggingPath(ExpandedPath):
# class TaskrcPath(ExpandedPath):
# class PydanticConfig(pydantic.BaseConfig):
# class MainSectionConfig(pydantic.BaseModel):
#     class Config(PydanticConfig):
# class Hooks(pydantic.BaseModel):
# class Notifications(pydantic.BaseModel):
# class SchemaBase(pydantic.BaseSettings):
# class ValidationErrorEnhancedMessages(list):
# class ServiceConfigMetaclass(pydantic.main.ModelMetaclass):
#             class PydanticServiceConfig(PydanticConfig):
# class ServiceConfig(_ServiceConfig,  # type: ignore  # (dynamic base class)
#                     metaclass=ServiceConfigMetaclass, prefix=None):
#     def validate(cls, value, field, config):
#     def validate_parts(
#             cls, parts: typing.Dict[str, str]) -> typing.Dict[str, str]:
#     def __get_validators__(cls):
#     def validate(cls, value):
#     def __get_validators__(cls):
#     def validate(cls, path):
#     def validate(cls, path):
#     def validate(cls, path):
#         def alias_generator(string: str) -> str:
#     def __init__(self, error: pydantic.ValidationError, targets, main_section):
#     def __str__(self):
#     def display_error_loc(e):
#     def display_error(self, e, error, model):
#     def flatten(self, err, loc=None):
# def raise_validation_error(msg, config_path, no_errors=1):
# def validate_config(config, main_section, config_path):
#     def __new__(mcs, name, bases, namespace, prefix, **kwargs):
#                 def alias_generator(string: str) -> str:
#     DEFAULT: dict  # configparser feature
# 
# Path: tests/base.py
# class ConfigTest(unittest.TestCase):
#     """
#     Creates config files, configures the environment, and cleans up afterwards.
#     """
#     def setUp(self):
#         self.old_environ = os.environ.copy()
#         self.tempdir = tempfile.mkdtemp(prefix='bugwarrior')
# 
#         # Create temporary config files.
#         self.taskrc = os.path.join(self.tempdir, '.taskrc')
#         self.lists_path = os.path.join(self.tempdir, 'lists')
#         os.mkdir(self.lists_path)
#         with open(self.taskrc, 'w+') as fout:
#             fout.write('data.location=%s\n' % self.lists_path)
# 
#         # Configure environment.
#         os.environ['HOME'] = self.tempdir
#         os.environ.pop(config.BUGWARRIORRC, None)
#         os.environ.pop('TASKRC', None)
#         os.environ.pop('XDG_CONFIG_HOME', None)
#         os.environ.pop('XDG_CONFIG_DIRS', None)
# 
#     def tearDown(self):
#         shutil.rmtree(self.tempdir, ignore_errors=True)
#         os.environ = self.old_environ
# 
#     @pytest.fixture(autouse=True)
#     def inject_fixtures(self, caplog):
#         self.caplog = caplog
# 
#     def validate(self):
#         conf = schema.validate_config(self.config, 'general', 'configpath')
#         conf['general'].data = data.BugwarriorData(self.lists_path)
#         conf['general'].interactive = False
#         return conf
# 
#     def assertValidationError(self, expected):
# 
#         with self.assertRaises(SystemExit):
#             self.validate()
# 
#         # Only one message should be logged.
#         self.assertEqual(len(self.caplog.records), 1)
# 
#         self.assertIn(expected, self.caplog.records[0].message)


# Path: tests/config/test_data.py
import os
import json
from bugwarrior.config import data, load, schema
from ..base import ConfigTest

        super().setUp()
        self.data = data.BugwarriorData(self.lists_path)

    def assert0600(self):
        permissions = oct(os.stat(self.data.datafile).st_mode & 0o777)
        # python2 -> 0600, python3 -> 0o600
        self.assertIn(permissions, ['0600', '0o600'])

    def test_get_set(self):
        # "touch" data file.
        with open(self.data.datafile, 'w+') as handle:
            json.dump({'old': 'stuff'}, handle)

        self.data.set('key', 'value')

        self.assertEqual(self.data.get('key'), 'value')
        self.assertEqual(
            self.data.get_data(), {'old': 'stuff', 'key': 'value'})
        self.assert0600()

    def test_set_first_time(self):
        self.data.set('key', 'value')

        self.assertEqual(self.data.get('key'), 'value')
        self.assert0600()

    def test_path_attribute(self):
        self.assertEqual(self.data.path, self.lists_path)



class TestGetDataPath(ConfigTest):