def test_getting_instance_count_for_valid_hours_and_valid_max_price_returns_proper_output(self): self.assertEqual(instance_allocator.instances_for_given_price(self.region_dict, 3, 5), [{'region': 'us-east', 'total_cost': '$4.8', 'servers': [ ('large', 2), ('xlarge', 2), ( '2xlarge', 2)]}])
def test_getting_instance_count_for_negative_price_returns_error(self): self.assertEqual( instance_allocator.instances_for_given_price( self.region_dict, 5, -1), [{ 'ERROR': "Hours and/or " "cost must be " "greater than " "zero" }])
def get_costs(n_cpu=None, n_hours=1, max_price=None): region_dict = read_cost('cost_file.json') if n_cpu is not None: if max_price is not None: print("CPU + Max prize combo") result = instance_allocator.instances_for_given_cpu_and_price( region_dict, n_hours, n_cpu, max_price) else: print("CPU + H hours combo") result = instance_allocator.instances_for_given_cpu_count( region_dict, n_hours, n_cpu) elif max_price is not None: print("Max price + H hours combo") result = instance_allocator.instances_for_given_price( region_dict, n_hours, max_price) else: print("Invalid input combo") result = [{'ERROR': 'Invalid input combination'}] pretty_result(result)