Example #1
0
def test_settings_from_file_with_DEFAULT():
    with patch('oops.conf.load_source', return_value=Mock(rules=conf.DEFAULT_RULES + ['test'],
                                                             wait_command=10,
                                                             require_confirmation=True,
                                                             no_colors=True)), \
         patch('oops.conf.os.environ', new_callable=lambda: {}):
        settings = conf.get_settings(Mock())
        assert settings.rules == conf.DEFAULT_RULES + ['test']
Example #2
0
def test_settings_from_file_with_DEFAULT():
    with patch('oops.conf.load_source', return_value=Mock(rules=conf.DEFAULT_RULES + ['test'],
                                                             wait_command=10,
                                                             require_confirmation=True,
                                                             no_colors=True)), \
         patch('oops.conf.os.environ', new_callable=lambda: {}):
        settings = conf.get_settings(Mock())
        assert settings.rules == conf.DEFAULT_RULES + ['test']
Example #3
0
def test_settings_from_env():
    with patch('oops.conf.load_source', return_value=Mock(rules=['test'],
                                                             wait_command=10)), \
         patch('oops.conf.os.environ',
               new_callable=lambda: {'oops_RULES': 'bash:lisp',
                                     'oops_WAIT_COMMAND': '55',
                                     'oops_REQUIRE_CONFIRMATION': 'true',
                                     'oops_NO_COLORS': 'false'}):
        settings = conf.get_settings(Mock())
        assert settings.rules == ['bash', 'lisp']
        assert settings.wait_command == 55
        assert settings.require_confirmation is True
        assert settings.no_colors is False
Example #4
0
def test_settings_from_env():
    with patch('oops.conf.load_source', return_value=Mock(rules=['test'],
                                                             wait_command=10)), \
         patch('oops.conf.os.environ',
               new_callable=lambda: {'oops_RULES': 'bash:lisp',
                                     'oops_WAIT_COMMAND': '55',
                                     'oops_REQUIRE_CONFIRMATION': 'true',
                                     'oops_NO_COLORS': 'false'}):
        settings = conf.get_settings(Mock())
        assert settings.rules == ['bash', 'lisp']
        assert settings.wait_command == 55
        assert settings.require_confirmation is True
        assert settings.no_colors is False
Example #5
0
def test_settings_from_env_with_DEFAULT():
    with patch('oops.conf.load_source', return_value=Mock()), \
         patch('oops.conf.os.environ', new_callable=lambda: {'oops_RULES': 'DEFAULT_RULES:bash:lisp'}):
        settings = conf.get_settings(Mock())
        assert settings.rules == conf.DEFAULT_RULES + ['bash', 'lisp']
Example #6
0
def test_settings_defaults():
    with patch('oops.conf.load_source', return_value=object()), \
         patch('oops.conf.os.environ', new_callable=lambda: {}):
        for key, val in conf.DEFAULT_SETTINGS.items():
            assert getattr(conf.get_settings(Mock()), key) == val
Example #7
0
def test_settings_from_env_with_DEFAULT():
    with patch('oops.conf.load_source', return_value=Mock()), \
         patch('oops.conf.os.environ', new_callable=lambda: {'oops_RULES': 'DEFAULT_RULES:bash:lisp'}):
        settings = conf.get_settings(Mock())
        assert settings.rules == conf.DEFAULT_RULES + ['bash', 'lisp']
Example #8
0
def test_settings_defaults():
    with patch('oops.conf.load_source', return_value=object()), \
         patch('oops.conf.os.environ', new_callable=lambda: {}):
        for key, val in conf.DEFAULT_SETTINGS.items():
            assert getattr(conf.get_settings(Mock()), key) == val