def test_config_not_found(caplog):
    appmap._implementation.initialize(
        env={  # pylint: disable=protected-access
            'APPMAP': 'true',
            'APPMAP_CONFIG': 'notfound.yml'
        })
    assert Config().name is None
    assert not Config().file_present
    assert not Config().file_valid

    assert not appmap.enabled()
    not_found = Path('notfound.yml').resolve()
    assert not not_found.exists()
    assert f'"{not_found}" is missing' in caplog.text
def test_reports_invalid():
    """
    Test that a parse error keeps recording from being enabled, and
    indicates that the config is not valid.
    """
    assert not appmap.enabled()
    assert not Config().file_valid
 def test_skipped_when_overridden(self):
     appmap._implementation.initialize(
         env={  # pylint: disable=protected-access
             'APPMAP': 'true',
             'APPMAP_CONFIG': '/tmp/appmap.yml'
         })
     assert not Config().name
     assert not appmap.enabled()
def test_config_no_message(caplog):
    """
    Messages about a missing config should only be logged when
    recording is enabled
    """

    assert Config().name is None
    assert not appmap.enabled()
    assert caplog.text is ""
def test_can_be_configured():
    """
    Test the happy path: APPMAP is true, appmap.yml is found, and the
    YAML is valid.
    """
    assert appmap.enabled()

    c = Config()
    assert c.file_present
    assert c.file_valid
    def check_default_config(self, expected_name):
        assert appmap.enabled()

        default_config = Config()
        assert default_config.name == expected_name
        assert len(default_config.packages) == 2
        assert sorted(default_config.packages, key=lambda p: p['path']) == [{
            'path':
            'package'
        }, {
            'path':
            'test'
        }]
def test_is_disabled_with_valid_config():
    c = Config()
    assert c.file_present
    assert c.file_valid

    assert not appmap.enabled()