def check_availability(self): availability_dict = self.instance.get_availability() purchases_dict = self.solution.get_amount_supplied().kfilter( lambda k: k[0] in self.instance.get_suppliers() ) check_dict = SuperDict.from_dict( {k: availability_dict[k] - purchases_dict[k] for k in availability_dict} ) return check_dict.vfilter(lambda v: v < 0)
def setUp(self): super().setUp() self.full_inst_path = self._get_path("./data/instance.json") self.full_inst = SuperDict.from_dict( self.import_schema(self.full_inst_path)) # Removing parameter tables self.full_inst["properties"] = self.full_inst["properties"].vfilter( lambda v: v["type"] == "array") self.one_tab_inst_path = self._get_path("./data/one_table.json") self.one_tab_inst = SuperDict.from_dict( self.import_schema(self.one_tab_inst_path)) self.app_name = "test" self.second_app_name = "test_sec" self.default_output_path = self._get_path("./data/output") self.other_output_path = self._get_path("./data/output_path") self.last_path = self.default_output_path self.all_methods = TupList( ["getOne", "getAll", "deleteOne", "deleteAll", "update", "post"])
def test_one_table_schema(self): runner = CliRunner() result = runner.invoke( generate_from_schema, [ "-p", self.one_tab_inst_path, "-a", self.app_name, "-o", self.other_output_path, ], ) self.assertEqual(result.exit_code, 0) instance = SuperDict.from_dict( {"properties": { "data": self.one_tab_inst }}) self.last_path = self.other_output_path self.check(instance=instance, output_path=self.other_output_path)
def __init__(self, data: dict): self.data = SuperDict.from_dict(data)