test_configuration.py 908 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python3
  2. # coding=utf-8
  3. from unittest.mock import MagicMock
  4. import pytest
  5. from bdfr.configuration import Configuration
  6. @pytest.mark.parametrize('arg_dict', (
  7. {'directory': 'test_dir'},
  8. {
  9. 'directory': 'test_dir',
  10. 'no_dupes': True,
  11. },
  12. ))
  13. def test_process_click_context(arg_dict: dict):
  14. test_config = Configuration()
  15. test_context = MagicMock()
  16. test_context.params = arg_dict
  17. test_config.process_click_arguments(test_context)
  18. test_config = vars(test_config)
  19. assert all([test_config[arg] == arg_dict[arg] for arg in arg_dict.keys()])
  20. def test_yaml_file_read():
  21. file = './tests/yaml_test_configuration.yaml'
  22. test_config = Configuration()
  23. test_config.parse_yaml_options(file)
  24. assert test_config.subreddit == ['EarthPorn', 'TwoXChromosomes', 'Mindustry']
  25. assert test_config.sort == 'new'
  26. assert test_config.limit == 10