def test_feedback(self): self._register_fake_endpoints() t = PredictiveServiceClient(config_file =self.configfile) t.feedback('some', {'a':1}) t.feedback('some more', {'a':1})
def test_read_config(self): self._register_fake_endpoints() t = PredictiveServiceClient(config_file =self.configfile) self.assertEquals(t.endpoint, 'http://abc.com') self.assertEquals(t.api_key, API_KEY)
def test_query(self): self._register_fake_endpoints() t = PredictiveServiceClient(config_file = self.configfile) data = {"dataset":{"user_id":175343, "movie_id":1011}} result = t.query('a', method='predict', data= data}) result = t.query('a', method='recommend', data= data}) result = t.query('name with space', method='recommend', data= data}) # unknown model with self.assertRaises(RuntimeError): t.query('nonexist', data) # wrong data type with self.assertRaises(TypeError): t.query('a', 'str') # wrong method with self.assertRaises(RuntimeError): t.query('a', {"method":"wrong method", "data":data})