I assume that all your changes are saved due to using the same neo4j database for testing that you use during development. Since neomodel is not tightly integrated with Django, it does not act the same as Django ORM when testing. Django will do some useful things when you run tests using your ORM, for example, creating a test database that will be destroyed upon completion.
With neo4j and neomodel, I would recommend doing the following:
Create custom tester
Django allows you to define a custom test runner by setting a configuration variable TEST_RUNNER. An extremely simple version of this for you:
from time import sleep
from subprocess import call
from django.test.runner import DiscoverRunner
class MyTestRunner(DiscoverRunner):
def setup_databases(self, *args, **kwargs):
call("sudo service neo4j-service stop", shell=True)
sleep(1)
success = call("/path/to/test/db/neo4j-community-2.2.2/bin/neo4j"
" start-no-wait", shell=True)
sleep(10)
if success != 0:
return False
try:
call("source /path/to/virtualenv/bin/activate && "
"/path/to/virtualenv/bin/neoauth "
"neo4j neo4j my-p4ssword")
except OSError:
pass
from neomodel import db
query = "match (n)-[r]-() delete n,r"
db.cypher_query(query)
super(MyTestRunner, self).__init__(*args, **kwargs)
def teardown_databases(self, old_config, **kwargs):
from neomodel import db
query = "match (n)-[r]-() delete n,r"
db.cypher_query(query)
sleep(1)
success = call("/path/to/test/db/neo4j-community-2.2.2/bin/neo4j"
" stop", shell=True)
if success != 0:
return False
sleep(1)
call("sudo service neo4j-service start", shell=True)
Add secondary neo4j database
, , neo4j website. , , , call .
, Linux-, . Django Test Runner Docs, , .