Skip to content
Snippets Groups Projects
Select Git revision
  • 165f38439fbb6251fd720a0ad3dab4a10118b2e3
  • master default protected
  • replication_test
  • dev protected
  • release-1.10 protected
  • release-1.9 protected
  • 551-init-broker-service-permissions
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • 518-spark-doesn-t-map-the-headers-correct
  • 485-fixity-checks
  • 530-various-schema-problems-with-subsets
  • release-1.7 protected
  • v1.10.2 protected
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
  • v1.9.2 protected
  • v1.9.2-rc0 protected
41 results

test_unit_image.py

Blame
  • Martin Weise's avatar
    165f3843
    History
    test_unit_image.py 923 B
    import unittest
    
    import requests_mock
    
    from dbrepo.RestClient import RestClient
    from dbrepo.api.dto import ImageBrief
    
    
    class ImageUnitTest(unittest.TestCase):
    
        def test_get_images_empty_succeeds(self):
            with requests_mock.Mocker() as mock:
                # mock
                mock.get('/api/image', json=[])
                # test
                response = RestClient().get_images()
                self.assertEqual([], response)
    
        def test_get_images_succeeds(self):
            with requests_mock.Mocker() as mock:
                exp = [ImageBrief(id="5d065194-2196-42e3-83e6-d8fc658c4b66",
                                  name="mariadb",
                                  version="11.1.3")]
                # mock
                mock.get('/api/image', json=[exp[0].model_dump()])
                # test
                response = RestClient().get_images()
                self.assertEqual(exp, response)
    
    
    if __name__ == "__main__":
        unittest.main()