NEO4J服务器存根设置
p01.neo4jstub的Python项目详细描述
这个包提供了一个基于真实neo4j服务器的neo4j服务器存根设置。
README
setup
此测试使用的是Neo4J服务器。用于此的测试设置方法 测试正在调用startneo4jserver方法,该方法正在启动一个neo4j 服务器。第一次调用这个测试时,新的neo4j服务器将 下载。测试设置如下:
def test_suite(): return unittest.TestSuite(( doctest.DocFileSuite('README.txt', setUp=testing.doctestSetUp, tearDown=testing.doctestTearDown, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS, encoding='utf-8'), ))
使用自定义conf文件夹的设置可能如下所示:
def mySetUp(test): # setup neo4j server here = os.path.dirname(__file__) sandbox = os.path.join(here, 'sandbox') confSource = os.path.join(here, 'conf') startNeo4jServer(sandbox, confSource=confSource) def myTearDown(test): # tear down neo4j server here = os.path.dirname(__file__) sandbox = os.path.join(here, 'sandbox') stopNeo4jServer(sandbox) # do some custom teardown stuff here
有关示例设置,请参见test.py。
windows
在windows上安装了名为p01_neo4jstub_testing的服务,并 在测试运行期间删除。这不好,但Neo4J就是这样 启动后停止。如果soemthing失败并且服务没有被删除, 您可以使用以下命令删除服务:
sc delete p01_neo4jstub_testing
testing
让我们设置一个python httplib连接:
>>> import httplib >>> conn = httplib.HTTPConnection('localhost', 47474)
并测试群集状态:
>>> conn.request('GET', '/db/data') >>> response = conn.getresponse() >>> response.status 302