def test_connect(self): grn = pyroonga.connect() self.assertTrue(grn.connected) self.assertEqual(grn.host, '0.0.0.0') self.assertEqual(grn.port, 10041) grn = pyroonga.connect(host='localhost', port=10041) self.assertTrue(grn.connected) self.assertEqual(grn.host, 'localhost') self.assertEqual(grn.port, 10041) self.assertRaises(pyroonga.GroongaError, pyroonga.connect, host='unknown', port=10041) self.assertRaises(pyroonga.GroongaError, pyroonga.connect, host='localhost', port=1)
def test_connect_with_default(): with mock.patch('pyroonga.groonga.Context') as m: m.return_value.connect.return_value = 0 grn = pyroonga.connect() assert isinstance(grn, pyroonga.Groonga) assert grn.host == '0.0.0.0' assert grn.port == 10041 assert grn.connected is True
def test_connect(): host = utils.random_string() port = random.randint(1025, 65535) with mock.patch('pyroonga.groonga.Context') as m: m.return_value.connect.return_value = 0 grn = pyroonga.connect(host, port) assert isinstance(grn, pyroonga.Groonga) assert grn.host == host assert grn.port == port assert grn.connected is True
def test_connect_with_default(self): grn = pyroonga.connect() assert grn.connected is True assert grn.host == '0.0.0.0' assert grn.port == 10041
def test_connect_with_invalid_params(self, host, port): with pytest.raises(pyroonga.GroongaError): pyroonga.connect(host=host, port=port)
def test_connect_with_params(self): grn = pyroonga.connect(host='localhost', port=10041) assert grn.connected is True assert grn.host == 'localhost' assert grn.port == 10041
def test_connect_with_default(): grn = pyroonga.connect() assert isinstance(grn, pyroonga.Groonga) assert grn.host == '0.0.0.0' assert grn.port == 10041 assert grn.connected is True
def test_connect_with_incorrect_params(host, port): with pytest.raises(pyroonga.GroongaError): pyroonga.connect(host, port)
def test_connect(): grn = pyroonga.connect('localhost', 10041) assert isinstance(grn, pyroonga.Groonga) assert grn.host == 'localhost' assert grn.port == 10041 assert grn.connected is True