66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright 2016 Mirantis, Inc.
|
|
#
|
|
# Licensed 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.
|
|
|
|
"""
|
|
Integration test for bareon allocation system.
|
|
|
|
Checks that high level abstraction works together
|
|
including the solver.
|
|
"""
|
|
|
|
import glob
|
|
import os
|
|
|
|
import six
|
|
import yaml
|
|
|
|
from bareon_dynamic_allocator.allocators import DynamicAllocator
|
|
from bareon_dynamic_allocator.tests import base
|
|
|
|
fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures', '*.yaml')
|
|
|
|
|
|
class TestGeneratorMeta(type):
|
|
"""Autogenerate tests from fixtures."""
|
|
|
|
def __new__(mcs, name, bases, cls_dict):
|
|
|
|
def gen_test(hw_info, dynamic_schema, expected):
|
|
def test(self):
|
|
result = DynamicAllocator(
|
|
hw_info,
|
|
dynamic_schema).generate_static()
|
|
self.assertEqual(expected, result)
|
|
return test
|
|
|
|
for f in glob.glob(fixtures_path):
|
|
with open(f, 'r') as fd:
|
|
data = yaml.load(fd)
|
|
|
|
method_name = data['name'].replace(' ', '_').lower()
|
|
test_name = 'test_{0}'.format(method_name)
|
|
cls_dict[test_name] = gen_test(
|
|
data['hw_info'],
|
|
data['dynamic_schema'],
|
|
data['expected'])
|
|
|
|
return type.__new__(mcs, name, bases, cls_dict)
|
|
|
|
|
|
@six.add_metaclass(TestGeneratorMeta)
|
|
class TestAllocatorIntegration(base.TestCase):
|
|
pass
|