def create_one(self, cls, datum): if datum['id'] in self.db_conn: status = self.MSG_UPDATED else: status = self.MSG_CREATED datum_key = str(getattr(datum, self.api_id)) self.db_conn[datum_key] = to_native(cls, datum) return (status, datum)
def test_to_native(): m = M(primitives) output = m.to_native() assert type(output) is dict assert output == natives assert to_native(M, natives) == natives
def update_one(self, cls, datum): datum_key = str(getattr(datum, self.api_id)) self.db_conn[datum_key] = to_native(cls, datum) return (self.MSG_UPDATED, datum)