Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
python3-dmapi / usr / lib / python3.6 / site-packages / dmapi / tests / functional / api_paste_fixture.py
Size: Mime:
# Copyright 2018 TrilioData Inc.
# All Rights Reserved.

import os

import fixtures

import dmapi.conf
from dmapi.conf import paths


CONF = dmapi.conf.CONF


class ApiPasteV2Fixture(fixtures.Fixture):

    def _replace_line(self, target_file, line):
        # TODO(johnthetubaguy) should really point the tests at /v2
        target_file.write(line.replace(
            "/v2: dmapi_v2"))

    def setUp(self):
        super(ApiPasteV2Fixture, self).setUp()
        CONF.set_default('api_paste_config',
                         paths.state_path_def('etc/dmapi/api-paste.ini'),
                         group='wsgi')
        tmp_api_paste_dir = self.useFixture(fixtures.TempDir())
        tmp_api_paste_file_name = os.path.join(tmp_api_paste_dir.path,
                                               'fake_api_paste.ini')
        with open(CONF.wsgi.api_paste_config, 'r') as orig_api_paste:
            with open(tmp_api_paste_file_name, 'w') as tmp_file:
                for line in orig_api_paste:
                    self._replace_line(tmp_file, line)
        CONF.set_override('api_paste_config', tmp_api_paste_file_name,
                          group='wsgi')


class ApiPasteNoProjectId(ApiPasteV2Fixture):

    def _replace_line(self, target_file, line):
        line = line.replace(
            "paste.filter_factory = dmapi.api.openstack.auth:"
            "NoAuthMiddleware.factory",
            "paste.filter_factory = dmapi.api.openstack.auth:"
            "NoAuthMiddlewareV2_18.factory")
        target_file.write(line)