CI for the TripleO project
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.

test_get_dlrn_hash.py 1.4KB

1234567891011121314151617181920212223242526272829303132333435
  1. from emit_releases_file import get_dlrn_hash
  2. import mock
  3. import pytest
  4. @mock.patch('requests.get')
  5. def test_get_dlrn_hash(mock_get):
  6. mock_response = mock.Mock()
  7. mock_response.content = ('[delorean]\nname=delorean-openstack-nova-81c23c04'
  8. '7e8e0fc03b54164921f49fdb4103202c\nbaseurl=https:/'
  9. '/trunk.rdoproject.org/centos7/81/c2/81c23c047e8e0'
  10. 'fc03b54164921f49fdb4103202c_b333f915\nenabled=1\n'
  11. 'gpgcheck=0\npriority=1')
  12. release = 'master'
  13. hash_name = 'current-tripleo'
  14. repo_url = ('https://trunk.rdoproject.org/centos7-%s/%s/delorean.repo'
  15. % (release, hash_name))
  16. mock_get.return_value = mock_response
  17. assert (get_dlrn_hash(release, hash_name) ==
  18. '81c23c047e8e0fc03b54164921f49fdb4103202c_b333f915')
  19. mock_get.assert_called_once_with(repo_url, timeout=(3.05, 27))
  20. @mock.patch('requests.get')
  21. def test_null_response_raises_runtimeerror(mock_get):
  22. release = 'master'
  23. hash_name = 'current-tripleo'
  24. repo_url = ('https://trunk.rdoproject.org/centos7-%s/%s/delorean.repo' %
  25. (release, hash_name))
  26. mock_get.return_value = None
  27. with pytest.raises(RuntimeError):
  28. get_dlrn_hash(release, hash_name)
  29. mock_get.assert_called_with(repo_url, timeout=(3.05, 27))
  30. assert (10 == mock_get.call_count)