示例#1
0
文件: base.py 项目: j2labs/tobin
 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)
示例#2
0
 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)
示例#3
0
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
示例#4
0
文件: base.py 项目: j2labs/tobin
 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)
示例#5
0
 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)