예제 #1
0
파일: __init__.py 프로젝트: shucao/pyroonga
    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
파일: __init__.py 프로젝트: naoina/pyroonga
 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
파일: __init__.py 프로젝트: naoina/pyroonga
 def test_connect_with_invalid_params(self, host, port):
     with pytest.raises(pyroonga.GroongaError):
         pyroonga.connect(host=host, port=port)
예제 #6
0
파일: __init__.py 프로젝트: naoina/pyroonga
 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