Rev 122 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 25-Mar-2010@author: ashish'''from shop2020.config.client.ConfigClient import ConfigClientfrom thrift.transport import TSocketfrom thrift.transport.TTransport import TFramedTransportfrom thrift.protocol.TBinaryProtocol import TBinaryProtocolfrom shop2020.thriftpy.model.v1.catalog import CatalogServicefrom shop2020.thriftpy.model.v1.catalog.ttypes import CatalogServiceException,\Category, Vendorclass TestClient:def __init__(self):config_client = ConfigClient()self.host = config_client.get_property('catalog_service_server_host')self.port = config_client.get_property('catalog_service_server_port')self.start()def start(self):try:self.transport = TSocket.TSocket(self.host, self.port)self.transport = TFramedTransport(self.transport)self.protocol = TBinaryProtocol(self.transport)self.client = CatalogService.Client(self.protocol)self.transport.open()except:raise CatalogServiceException(101, 'unable to load the client')def addCategory(self):cat = Category()cat.name = 'Entertainment'cat.addedOn = 12345678self.client.addCategory(cat)cats = self.client.getAllCategories()for category in cats:print category.namedef addVendor(self):vend = Vendor()vend.name = 'Nokia'self.client.addVendor(vend)if __name__=='__main__':test = TestClient()test.addCategory()