<commit_before># Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import inspect
import unittest

from libcloudcore.driver import Driver
from libcloudcore.auth.basic_auth import BasicAuth
from libcloudcore.backend import Driver as RequestsBackend
from libcloudcore.validation import Validation
from libcloudcore.serializers import JsonSerializer
from libcloudcore.layer import Layer
from ..request import Request


class TestDriver(unittest.TestCase):

    def setUp(self):
        from libcloudcore.drivers.bigv import Driver
        self.Driver = Driver
        self.driver = Driver('username', 'password')
        self.model = self.driver.model
        self.operation = self.model.get_operation("list_virtual_machines")

    def test_mro(self):
        self.assertEqual(inspect.getmro(self.Driver), (
            self.Driver,
            Driver,
            RequestsBackend,
            Validation,
            BasicAuth,
            JsonSerializer,
            Layer,
            object,
        ))

    def test_build_request(self):
        request = Request()
        self.driver.before_call(
            request,
            self.operation,
            account_id=1,
            group_id=2
        )

        self.assertEqual(
            request.uri,
            'accounts/1/groups/2/virtual_machines',
        )<commit_msg>End to end test of making a http request via requests<commit_after># Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import inspect
import unittest

from libcloudcore.driver import Driver
from libcloudcore.auth.basic_auth import BasicAuth
from libcloudcore.backend import Driver as RequestsBackend
from libcloudcore.validation import Validation
from libcloudcore.serializers import JsonSerializer
from libcloudcore.layer import Layer
from ..request import Request

from . import httpbin


class TestDriver(unittest.TestCase):

    def setUp(self):
        from libcloudcore.drivers.bigv import Driver
        self.Driver = Driver
        self.driver = Driver('username', 'password')
        self.model = self.driver.model
        self.operation = self.model.get_operation("list_virtual_machines")

    def test_mro(self):
        self.assertEqual(inspect.getmro(self.Driver), (
            self.Driver,
            Driver,
            RequestsBackend,
            Validation,
            BasicAuth,
            JsonSerializer,
            Layer,
            object,
        ))

    def test_build_request(self):
        request = Request()
        self.driver.before_call(
            request,
            self.operation,
            account_id=1,
            group_id=2
        )

        self.assertEqual(
            request.uri,
            'accounts/1/groups/2/virtual_machines',
        )


class TestActualRequests(httpbin.HttpBinTestCase):

    def test_simple_get(self):
        from libcloudcore.drivers.httpbin import Driver
        driver = Driver()
        driver.model._model['metadata']['http'] = {
            'host': 'localhost',
            'port': self.server.port,
            'scheme': 'http',
        }
        self.assertTrue('origin' in driver.ip())
{'fraction_non_alphanumeric': 0.07092819614711034, 'fraction_numerical': 0.0035026269702276708, 'mean_word_length': 2.7358953393295176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '799141', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1136, 'n_words': 407}