def process_request(self, api_handler, test_mode = False): ''' Processes the client's request and returns the resulting json message to send back to the client. @return: The response to send back to the client. ''' service = ServiceFactory.create_service(self.client_json, api_handler) return service.process_service(test_mode)
def testRaisesTypeErrorOnInvalidType(self): data = { 'type': 'awgwaegfaewf', 'data': { 'user': { 'username': '******', 'password': '******', 'email': '*****@*****.**', 'steamid': 1 }, 'steamid': 2, 'game': { 'steamid': 3, 'onsaleselected': True, 'targetprice': 5.0, 'targetpriceselected': True } } } with self.assertRaises(TypeError): ServiceFactory.create_service(data, None)
def testMakesWatchlistGameFetcher(self): data = { 'type': 'fetch_watchlist', 'data': { 'user': { 'username': '******', 'password': '******', 'email': '*****@*****.**', 'steamid': 1 }, 'steamid': 2, 'game': { 'steamid': 3, 'onsaleselected': True, 'targetprice': 5.0, 'targetpriceselected': True } } } service = ServiceFactory.create_service(data, None) self.assertTrue(isinstance(service, WatchlistGameFetcher))
def testMakesUserLogin(self): data = { 'type': 'authenticate', 'data': { 'user': { 'username': '******', 'password': '******', 'email': '*****@*****.**', 'steamid': 1 }, 'steamid': 2, 'game': { 'steamid': 3, 'onsaleselected': True, 'targetprice': 5.0, 'targetpriceselected': True } } } service = ServiceFactory.create_service(data, None) self.assertTrue(isinstance(service, UserLogin))
def testMakesSteamWishlistLink(self): data = { 'type': 'link_steam', 'data': { 'user': { 'username': '******', 'password': '******', 'email': '*****@*****.**', 'steamid': 1 }, 'steamid': 2, 'game': { 'steamid': 3, 'onsaleselected': True, 'targetprice': 5.0, 'targetpriceselected': True } } } service = ServiceFactory.create_service(data, None) self.assertTrue(isinstance(service, SteamWishlistLink))