Exemplo n.º 1
0
 def test_execute(self, ret, expected):
     class A(object):
         grn = mock.MagicMock()
     A.grn.query = mock.MagicMock(return_value=ret)
     record = query.SimpleQuery(A)
     result = record.execute()
     assert result == expected
     assert A.grn.query.mock_calls == [mock.call('')]
Exemplo n.º 2
0
 def test_connect_with_default(self):
     grn = Groonga()
     grn._ctx = mock.MagicMock()
     grn._ctx.connect.return_value = 0
     assert grn.connected is False
     assert grn.host == '0.0.0.0'
     assert grn.port == 10041
     grn.connect()
     assert grn.connected is True
     assert grn.host == '0.0.0.0'
     assert grn.port == 10041
     assert grn._ctx.connect.mock_calls == [mock.call('0.0.0.0', 10041,
                                                      flags=0)]
Exemplo n.º 3
0
 def test_connect_with_params(self):
     host = utils.random_string()
     port = random.randint(1025, 65535)
     grn = Groonga()
     grn._ctx = mock.MagicMock()
     grn._ctx.connect.return_value = 0
     assert grn.connected is False
     assert grn.host == '0.0.0.0'
     assert grn.port == 10041
     grn.connect(host=host, port=port)
     assert grn.connected is True
     assert grn.host == '0.0.0.0'
     assert grn.port == 10041
     assert grn._ctx.connect.mock_calls == [mock.call(host, port, flags=0)]