class JubaRPCServerTest(JubaTestCase): def setUp(self): node = JubaNode('127.0.0.1', [12345], None, '/tmp', []) self.instance = JubaRPCServer(node, CLASSIFIER, []) self.stub_instance = JubaRPCServerStub(node) def test_start_fail(self): self.assertRaises(JubaTestFixtureFailedError, self.stub_instance.start) def test_get_client(self): self.assertIsInstance(self.instance.get_client('foo'), jubatus.classifier.client.Classifier) def test_get_client_type(self): self.assertIsInstance(self.instance.get_client_type('datum')(), jubatus.common.Datum) def test_types(self): self.assertIsInstance(self.instance.types.Datum(), jubatus.common.Datum) def test_get_host_port(self): (host, port) = self.instance.get_host_port() self.assertEqual('127.0.0.1', host) self.assertEqual(-1, port) # port will not be allocated before calling start def test_log_fail(self): self.assertRaises(JubaTestAssertionError, self.instance.log) def test_flatten_options(self): opts = [('--opt1', 'yes'), ('--opt2', 100), ('--opt1', 'no')] expected = ['--opt1', 'yes', '--opt2', '100'] self.assertEqual(expected, self.instance._flatten_options(opts))
class JubaRPCServerTest(JubaTestCase): def setUp(self): node = JubaNode('127.0.0.1', [12345], None, '/tmp', []) self.instance = JubaRPCServer(node, CLASSIFIER, []) self.stub_instance = JubaRPCServerStub(node) def test_start_fail(self): self.assertRaises(JubaTestFixtureFailedError, self.stub_instance.start) def test_get_client(self): self.assertIsInstance(self.instance.get_client(), jubatus.classifier.client.classifier) def test_get_client_type(self): self.assertIsInstance(self.instance.get_client_type('datum')([], []), jubatus.classifier.types.datum) def test_types(self): self.assertIsInstance(self.instance.types.datum([], []), jubatus.classifier.types.datum) def test_get_host_port(self): (host, port) = self.instance.get_host_port() self.assertEqual('127.0.0.1', host) self.assertEqual(-1, port) # port will not be allocated before calling start def test_log_fail(self): self.assertRaises(JubaTestAssertionError, self.instance.log) def test_flatten_options(self): opts = [('--opt1', 'yes'), ('--opt2', 100), ('--opt1', 'no')] expected = ['--opt1', 'yes', '--opt2', '100'] self.assertEqual(expected, self.instance._flatten_options(opts))
def test_get_client_class(self): server = JubaRPCServer(self.node, CLASSIFIER, []) self.assertEqual(server.get_client_class(), jubatus.classifier.client.Classifier) server = JubaRPCServer(self.node, NEAREST_NEIGHBOR, []) self.assertEqual(server.get_client_class(), jubatus.nearest_neighbor.client.NearestNeighbor)
def setUp(self): self.node = JubaNode('127.0.0.1', [12345], None, '/tmp', []) self.instance = JubaRPCServer(self.node, CLASSIFIER, []) self.stub_instance = JubaRPCServerStub(self.node)