示例#1
0
    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)
示例#2
0
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
示例#3
0
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
示例#4
0
 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
示例#5
0
 def test_connect_with_invalid_params(self, host, port):
     with pytest.raises(pyroonga.GroongaError):
         pyroonga.connect(host=host, port=port)
示例#6
0
 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
示例#7
0
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
示例#8
0
def test_connect_with_incorrect_params(host, port):
    with pytest.raises(pyroonga.GroongaError):
        pyroonga.connect(host, port)
示例#9
0
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