Skip to content
Snippets Groups Projects
Select Git revision
  • b15492ecb57d90adafe304ec8f85c37e2c2479eb
  • 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

Configuration.java

Blame
  • test_unit_rest_client.py 1.29 KiB
    import os
    from unittest import TestCase, mock, main
    
    from dbrepo.RestClient import RestClient
    
    
    class DatabaseUnitTest(TestCase):
    
        def test_constructor_succeeds(self):
            # test
            client = RestClient()
            self.assertEqual("http://gateway-service", client.endpoint)
            self.assertIsNone(client.username)
            self.assertIsNone(client.password)
            self.assertTrue(client.secure)
    
        @mock.patch.dict(os.environ, {
            "REST_API_ENDPOINT": "https://test.dbrepo.tuwien.ac.at",
            "REST_API_USERNAME": "foo",
            "REST_API_PASSWORD": "bar",
            "REST_API_SECURE": "false",
        })
        def test_constructor_environment_succeeds(self):
            # test
            client = RestClient()
            self.assertEqual("https://test.dbrepo.tuwien.ac.at", client.endpoint)
            self.assertEqual("foo", client.username)
            self.assertEqual("bar", client.password)
            self.assertFalse(client.secure)
    
        def test_constructor_credentials_succeeds(self):
            # test
            client = RestClient(username='admin', password='pass')
            self.assertEqual("http://gateway-service", client.endpoint)
            self.assertEqual('admin', client.username)
            self.assertEqual('pass', client.password)
            self.assertTrue(client.secure)
    
    
    if __name__ == "__main__":
        main()