Commit 1d649204 authored by Romain Loth's avatar Romain Loth

update comments to account for last commit

parent 1604e126
......@@ -52,26 +52,13 @@ TEST_RUNNER = 'unittests.framework.GargTestRunner'
Using a DB session
------------------
To emulate a session the way we usually do it in gargantext, our `unittests.framework` also
provides a session object to the test database via `GargTestRunner.testdb_session`
To work correctly, it needs to be read *inside the test setup.*
The GargTestRunner overrides default settings so that the test database is used in the way we usually do it in gargantext :
**Example**
```
from unittests.framework import GargTestRunner
from gargantext.util.db import session
class MyTestRecipes(TestCase):
def setUp(self):
# -------------------------------------
session = GargTestRunner.testdb_session
# -------------------------------------
new_project = Node(
typename = 'PROJECT',
name = "hello i'm a project",
)
session.add(new_project)
session.commit()
session.query(Nodes).all() # gives all the nodes of the testdb
```
......@@ -123,12 +110,3 @@ class MyTestRecipes(TestCase):
```
*Si vous aimez les aventures de Peter Corser, lisez l'album précédent ["Doors"](https://gogs.iscpif.fr/leclaire/doors)* (Scénario M. Leclaire, Dessins R. Loth) (disponible dans toutes les bonnes librairies)
FIXME
-----
url client get will still give read access to original DB ?
cf. http://stackoverflow.com/questions/19714521
cf. http://stackoverflow.com/questions/11046039
cf. test_073_get_api_one_node
......@@ -4,11 +4,7 @@ A test runner derived from default (DiscoverRunner) but adapted to our custom DB
cf. docs.djangoproject.com/en/1.9/topics/testing/advanced/#using-different-testing-frameworks
cf. gargantext/settings.py => TEST_RUNNER
cf. dbmigrate.py
FIXME url get will still give read access to original DB ?
cf. http://stackoverflow.com/questions/19714521
cf. http://stackoverflow.com/questions/11046039
cf. test_073_get_api_one_node
cf ./session_and_db_remarks.md
"""
# basic elements
......@@ -43,10 +39,8 @@ class GargTestRunner(DiscoverRunner):
We use the default test runner but we just add
our own dbmigrate elements at db creation
=> we let django.test.runner do the test db creation + auto migrations
=> we retrieve the test db name from django.test.runner
=> we create a test engine like in gargantext.db.create_engine but with the test db name
=> we create tables for our models like in dbmigrate with the test engine
1) we let django.test.runner do the test db creation + auto migrations
2) we create tables for our models like in dbmigrate with the test engine
POSSIBLE: definitions of tables to be created should be fully hard coded like the list in self.models
=> then remove django.setup() used to import models and DATABASES renaming to prevent its secondary effects
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment