1
0

test___main__.py 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. # Copyright 2021 The Matrix.org Foundation C.I.C.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from synapse.config.__main__ import main
  15. from tests.config.utils import ConfigFileTestCase
  16. class ConfigMainFileTestCase(ConfigFileTestCase):
  17. def test_executes_without_an_action(self):
  18. self.generate_config()
  19. main(["", "-c", self.config_file])
  20. def test_read__error_if_key_not_found(self):
  21. self.generate_config()
  22. with self.assertRaises(SystemExit):
  23. main(["", "read", "foo.bar.hello", "-c", self.config_file])
  24. def test_read__passes_if_key_found(self):
  25. self.generate_config()
  26. main(["", "read", "server.server_name", "-c", self.config_file])