Commit 15802a15 authored by Romain Loth's avatar Romain Loth

update comments to account for last commit

parent fa0cd2e2
...@@ -52,26 +52,13 @@ TEST_RUNNER = 'unittests.framework.GargTestRunner' ...@@ -52,26 +52,13 @@ TEST_RUNNER = 'unittests.framework.GargTestRunner'
Using a DB session Using a DB session
------------------ ------------------
To emulate a session the way we usually do it in gargantext, our `unittests.framework` also The GargTestRunner overrides default settings so that the test database is used in the way we usually do it in gargantext :
provides a session object to the test database via `GargTestRunner.testdb_session`
To work correctly, it needs to be read *inside the test setup.*
**Example** **Example**
``` ```
from unittests.framework import GargTestRunner from gargantext.util.db import session
class MyTestRecipes(TestCase): session.query(Nodes).all() # gives all the nodes of the testdb
def setUp(self):
# -------------------------------------
session = GargTestRunner.testdb_session
# -------------------------------------
new_project = Node(
typename = 'PROJECT',
name = "hello i'm a project",
)
session.add(new_project)
session.commit()
``` ```
...@@ -123,12 +110,3 @@ class MyTestRecipes(TestCase): ...@@ -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) *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 ...@@ -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. docs.djangoproject.com/en/1.9/topics/testing/advanced/#using-different-testing-frameworks
cf. gargantext/settings.py => TEST_RUNNER cf. gargantext/settings.py => TEST_RUNNER
cf. dbmigrate.py cf. dbmigrate.py
cf ./session_and_db_remarks.md
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
""" """
# basic elements # basic elements
...@@ -43,10 +39,8 @@ class GargTestRunner(DiscoverRunner): ...@@ -43,10 +39,8 @@ class GargTestRunner(DiscoverRunner):
We use the default test runner but we just add We use the default test runner but we just add
our own dbmigrate elements at db creation our own dbmigrate elements at db creation
=> we let django.test.runner do the test db creation + auto migrations 1) we let django.test.runner do the test db creation + auto migrations
=> we retrieve the test db name from django.test.runner 2) we create tables for our models like in dbmigrate with the test engine
=> 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
POSSIBLE: definitions of tables to be created should be fully hard coded like the list in self.models 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 => 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