def test_get_requirement_params(self):
        """
        This @statmicmethod should return a dictionary.
        The function should work both with and without and application context.
        It retreives the relevant parameters from postgres, for consul.
        """

        consul_mock = Mock(running_port=8500)
        postgres_mock = Mock(running_host='localhost', running_port=5437)
        redis_mock = Mock(running_host='localhost', running_port=6739)

        P = ConsulProvisioner(container=consul_mock,
                              services=['adsws'],
                              requirements={
                                  'postgres': postgres_mock,
                                  'redis': redis_mock
                              })

        db_params = P.get_db_params()
        self.assertEqual(db_params['HOST'], '172.17.42.1')
        self.assertEqual(db_params['PORT'], 5437)

        cache_params = P.get_cache_params()
        self.assertEqual(cache_params['HOST'], '172.17.42.1')
        self.assertEqual(cache_params['PORT'], 6739)
    def test_get_database_params(self):
        """
        This @statmicmethod should return a dictionary.
        The function should work both with and without and application context.
        It retreives the relevant parameters from postgres, for consul.
        """

        db = ConsulProvisioner.get_db_params()
        self.assertIsInstance(db, dict)

        with create_app().app_context():
            self.assertEqual(db, ConsulProvisioner.get_db_params())
            # Delete the requires config value to see if the method tries to
            # access it. Expect KeyError
            with self.assertRaises(KeyError):
                del current_app.config["DEPENDENCIES"]["POSTGRES"]
                ConsulProvisioner.get_db_params()
    def test_get_requirement_params(self):
        """
        This @statmicmethod should return a dictionary.
        The function should work both with and without and application context.
        It retreives the relevant parameters from postgres, for consul.
        """

        consul_mock = Mock(running_port=8500)
        postgres_mock = Mock(running_host='localhost', running_port=5437)
        redis_mock = Mock(running_host='localhost', running_port=6739)

        P = ConsulProvisioner(container=consul_mock,
                              services=['adsws'],
                              requirements={'postgres': postgres_mock, 'redis': redis_mock}
                              )

        db_params = P.get_db_params()
        self.assertEqual(db_params['HOST'], '172.17.42.1')
        self.assertEqual(db_params['PORT'], 5437)

        cache_params = P.get_cache_params()
        self.assertEqual(cache_params['HOST'], '172.17.42.1')
        self.assertEqual(cache_params['PORT'], 6739)