test_indexes_equal.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Copyright (c) 2017, Open Source Robotics Foundation
  2. # All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions are met:
  6. #
  7. # * Redistributions of source code must retain the above copyright
  8. # notice, this list of conditions and the following disclaimer.
  9. # * Redistributions in binary form must reproduce the above copyright
  10. # notice, this list of conditions and the following disclaimer in the
  11. # documentation and/or other materials provided with the distribution.
  12. # * Neither the name of the Willow Garage, Inc. nor the names of its
  13. # contributors may be used to endorse or promote products derived from
  14. # this software without specific prior written permission.
  15. #
  16. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  20. # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  23. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  24. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  25. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  26. # POSSIBILITY OF SUCH DAMAGE.
  27. import os
  28. from rosdistro import get_index
  29. from .fold_block import Fold
  30. INDEX_V3_YAML = os.path.normpath(os.path.join(
  31. os.path.dirname(os.path.abspath(__file__)), '..', 'index.yaml'))
  32. INDEX_V4_YAML = os.path.normpath(os.path.join(
  33. os.path.dirname(os.path.abspath(__file__)), '..', 'index-v4.yaml'))
  34. def test_build_caches():
  35. with Fold():
  36. print('Checking that the index.yaml and index-v4.yaml files contain '
  37. 'the same information expect additional metadata in the v4.')
  38. index_v3 = get_index('file://' + os.path.abspath(INDEX_V3_YAML))
  39. index_v4 = get_index('file://' + os.path.abspath(INDEX_V4_YAML))
  40. dist_names_v3 = list(sorted(index_v3.distributions.keys()))
  41. dist_names_v4 = list(sorted(index_v4.distributions.keys()))
  42. assert dist_names_v3 == dist_names_v4, \
  43. 'Different set of distribution names'
  44. for dist_name in dist_names_v3:
  45. dist_v3_data = index_v3.distributions[dist_name]
  46. dist_v4_data = index_v4.distributions[dist_name]
  47. for key, value in dist_v3_data.items():
  48. assert key in dist_v4_data, \
  49. "For distribution '%s' index.yaml contains the key '%s' " \
  50. "but v4 doesn't contain it" % (dist_name, key)
  51. assert dist_v4_data[key] == value, \
  52. "For distribution '%s' both yaml files contains the key " \
  53. "'%s' but with different values" % (dist_name, key)