import client.api import client.models from common import Config, Service from common.matcher import be_valid_port, raise_api_exception CONFIG = Config(os.path.join(os.path.dirname(__file__), os.environ.get('MAMBA_CONFIG', 'config.yaml'))) with description('Ports,', 'ports') as self: with description('REST API,'): with before.all: service = Service(CONFIG.service()) self.process = service.start() self.api = client.api.PortsApi(service.client()) with description('list,'): with description('unfiltered,'): with it('returns valid ports'): ports = self.api.list_ports() expect(ports).not_to(be_empty) for port in ports: expect(port).to(be_valid_port) with description('filtered,'): with description('known existing kind,'): with it('returns valid ports of that kind'): ports = self.api.list_ports(kind='dpdk') expect(ports).not_to(be_empty)
be_valid_cpu_generator_result, be_valid_dynamic_results) CONFIG = Config(os.path.join(os.path.dirname(__file__), os.environ.get('MAMBA_CONFIG', 'config.yaml'))) def approximately_equal(a, b): return abs(a - b) < 0.01 with description('CPU Generator Module', 'cpu') as self: with before.all: service = Service(CONFIG.service()) self._process = service.start() self._api = client.api.CpuGeneratorApi(service.client()) if not check_modules_exists(service.client(), 'cpu'): self.skip() with after.all: try: for gen in self._api.list_cpu_generators(): if gen.running: self._api.stop_cpu_generator(gen.id) self._api.delete_cpu_generator(gen.id) self._process.terminate() self._process.wait() except AttributeError: pass