test_generate.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 OpenMarket Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import os.path
  16. import shutil
  17. import tempfile
  18. from synapse.config.homeserver import HomeServerConfig
  19. from tests import unittest
  20. class ConfigGenerationTestCase(unittest.TestCase):
  21. def setUp(self):
  22. self.dir = tempfile.mkdtemp()
  23. print self.dir
  24. self.file = os.path.join(self.dir, "homeserver.yaml")
  25. def tearDown(self):
  26. shutil.rmtree(self.dir)
  27. def test_generate_config_generates_files(self):
  28. HomeServerConfig.load_config("", [
  29. "--generate-config",
  30. "-c", self.file,
  31. "--report-stats=yes",
  32. "-H", "lemurs.win"
  33. ])
  34. self.assertSetEqual(
  35. set([
  36. "homeserver.yaml",
  37. "lemurs.win.log.config",
  38. "lemurs.win.signing.key",
  39. "lemurs.win.tls.crt",
  40. "lemurs.win.tls.dh",
  41. "lemurs.win.tls.key",
  42. ]),
  43. set(os.listdir(self.dir))
  44. )