Tools used by OpenStack Documentation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 lines
1.3 KiB

  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  2. # not use this file except in compliance with the License. You may obtain
  3. # a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations
  11. # under the License.
  12. import mock
  13. from os_doc_tools import index
  14. import unittest
  15. class TestGenerateIndex(unittest.TestCase):
  16. def test_dir_created(self):
  17. path = 'path'
  18. with mock.patch.object(index, 'open'):
  19. with mock.patch.object(index.os, 'mkdir') as mock_mkdir:
  20. index.generate_index_file(path)
  21. self.assertTrue(mock_mkdir.called)
  22. def test_dir_not_created_when_exists(self):
  23. path = 'path'
  24. with mock.patch.object(index, 'open'):
  25. with mock.patch.object(index.os, 'mkdir') as mock_mkdir:
  26. with mock.patch.object(index.os.path, 'isdir',
  27. returned_value=True):
  28. index.generate_index_file(path)
  29. self.assertFalse(mock_mkdir.called)
  30. if __name__ == '__main__':
  31. unittest.main()