sayan801 / indivo_server

The Indivo™ Personally Controlled Health Record
http://indivohealth.org
GNU General Public License v3.0
2 stars 1 forks source link

tests run failing - Testing Indivo Backend Server using python manage.py test indivo #2

Closed cribello closed 10 years ago

cribello commented 10 years ago

root@curatehealth:/indivo/indivo_server$ python manage.py test indivo

Creating test database for alias 'default'............................................................................................................E.E........................................................................................................................................................F.....F..............................................................

ERROR: test_to_facts (indivo.tests.unit.rdf.transforms.medication.MedicationTransformUnitTests)

Traceback (most recent call last): File "/indivo/indivo_server/indivo/tests/unit/rdf/transforms/medication.py", line 17, in test_to_facts facts = MedicationTransform()(graph) File "/indivo/indivo_server/indivo/document_processing/transform.py", line 68, in call ret = self._call_func('to_facts', doc_etree) File "/indivo/indivo_server/indivo/document_processing/transform.py", line 89, in _call_func return func(_args, *_kwargs) File "/indivo/indivo_server/indivo/rdf/transforms/medication.py", line 30, in to_facts facts, sub_facts = self.params_to_facts(medication_params) File "/indivo/indivo_server/indivo/rdf/transforms/medication.py", line 65, in params_to_facts medication = fact_form.save() File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 364, in save fail_message, commit, construct=False) File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 74, in save_instance " validate." % (opts.object_name, fail_message)) ValueError: The Medication could not be created because the data didn't validate.

ERROR: test_to_facts_with_fill (indivo.tests.unit.rdf.transforms.medication.MedicationTransformUnitTests)

Traceback (most recent call last): File "/indivo/indivo_server/indivo/tests/unit/rdf/transforms/medication.py", line 56, in test_to_facts_with_fill facts = MedicationTransform()(graph) File "/indivo/indivo_server/indivo/document_processing/transform.py", line 68, in call ret = self._call_func('to_facts', doc_etree) File "/indivo/indivo_server/indivo/document_processing/transform.py", line 89, in _call_func return func(_args, *_kwargs) File "/indivo/indivo_server/indivo/rdf/transforms/medication.py", line 30, in to_facts facts, sub_facts = self.params_to_facts(medication_params) File "/indivo/indivo_server/indivo/rdf/transforms/medication.py", line 65, in params_to_facts medication = fact_form.save() File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 364, in save fail_message, commit, construct=False) File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 74, in save_instance " validate." % (opts.object_name, fail_message)) ValueError: The Medication could not be created because the data didn't validate.

FAIL: test_accounts (indivo.tests.integration.accounting.AccountIntegrationTests)

Traceback (most recent call last): File "/indivo/indivo_server/indivo/tests/integration/accounting.py", line 24, in test_accounts self.assert_200(resp) File "/indivo/indivo_server/indivo/tests/internal_tests.py", line 337, in assert_200 self.assertEqual(response['status'], '200') AssertionError: '500' != '200'

FAIL: test_document_processing (indivo.tests.integration.document_processing.DocumentProcessingIntegrationTests)

Traceback (most recent call last): File "/indivo/indivo_server/indivo/tests/integration/document_processing.py", line 23, in test_document_processing self.assertTrue(False) AssertionError: False is not true


Ran 329 tests in 573.493s

FAILED (failures=2, errors=2) Destroying test database for alias 'default'...

cribello commented 10 years ago

Looks like development version is unstable yet.. So we are reverting back to release 2.0

cribello commented 10 years ago

python utils/reset.py does not work with existing db..

root@curatehealth:/indivo/indivo_server# python utils/reset.py
You have requested a reset of the database.
This will IRREVERSIBLY DESTROY all data currently in the 'indivo' database,
and return each table to its initial state.
Are you sure you want to do this?

    Type 'yes' to continue, or 'no' to cancel: yes
RESETTING DATABASE...
Flushing the Database of existing data...
Error: Database indivo couldn't be flushed. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the expected database tables doesn't exist.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: cannot truncate a table referenced in a foreign key constraint
DETAIL:  Table "indivo_problem_encounters" references "indivo_encounter".
HINT:  Truncate table "indivo_problem_encounters" at the same time, or use TRUNCATE ... CASCADE.

So i renamed old db..

root@curatehealth:/indivo/indivo_server# sudo su postgres
postgres@curatehealth:/indivo/indivo_server$ psql
psql (9.1.13)
Type "help" for help.

postgres=# \list
                                  List of databases
    Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
------------+----------+----------+-------------+-------------+-----------------------
 dao_indivo | indivo   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 indivo     | indivo   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres   | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
            |          |          |             |             | postgres=CTc/postgres
 template1  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
            |          |          |             |             | postgres=CTc/postgres
(5 rows)

postgres=# ALTER DATABASE indivo  RENAME TO old_indivo_3rd_july;
ALTER DATABASE

^Z
[2]+  Stopped                 psql

I created a new db..

postgres@curatehealth:/indivo/indivo_server$ createdb -U indivo -O indivo indivo

python utils/reset.py does not work if you are not logged as root..

postgres@curatehealth:/indivo/indivo_server$ python utils/reset.py
Traceback (most recent call last):
  File "utils/reset.py", line 17, in <module>
    from django.db import connection, DatabaseError, IntegrityError
  File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 14, in <module>
    if not settings.DATABASES:
  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__
    self._setup()
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 90, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/indivo/indivo_server/settings.py", line 114, in <module>
    filename = APP_HOME + '/indivo.log', filemode = 'a')
  File "/usr/lib/python2.7/logging/__init__.py", line 1519, in basicConfig
    hdlr = FileHandler(filename, mode)
  File "/usr/lib/python2.7/logging/__init__.py", line 897, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python2.7/logging/__init__.py", line 916, in _open
    stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: '/indivo/indivo_server/indivo.log'
postgres@curatehealth:/indivo/indivo_server$

logged in back as root..

login as: root
root@128.199.200.18's password:

Now after closing all the existing db connection, running the reset script again..

Last login: Mon Aug  4 03:22:08 2014 from 112.79.39.47
root@curatehealth:~# cd /indivo/indivo_server/
root@curatehealth:/indivo/indivo_server# python utils/reset.py
You have requested a reset of the database.
This will IRREVERSIBLY DESTROY all data currently in the 'indivo' database,
and return each table to its initial state.
Are you sure you want to do this?

    Type 'yes' to continue, or 'no' to cancel: yes
RESETTING DATABASE...
Flushing the Database of existing data...
Database nonexistent or corrupted, or Database drop requeseted. Attempting to drop database...
Password:
Creating the Database...
Password:
Syncing and Migrating the database...
Database Synced.
LOADING INITIAL INDIVO DATA...
        Adding authsystem:  auth_system_example
        Adding account:  johnsmith@indivo.org
        Loading data profile patient_967332 for record John S. Smith
        Processing Machine App sample_ui...
                New app. Registering...
        Processing Machine App sample_admin...
                New app. Registering...
        Processing User App smart_problems...
                New app. Registering...
        Processing User App problems...
                New app. Registering...
        Processing User App smart_api_playground...
                New app. Registering...
        Processing User App smart_api_verifier...
                New app. Registering...
        Processing User App bp_centiles...
                New app. Registering...
        Processing User App allergies...
                New app. Registering...
        Processing User App smart_med_list...
                New app. Registering...
        Processing User App labs...
                New app. Registering...
        Processing User App medications...
                New app. Registering...
        Processing User App smart_med_calendar...
                New app. Registering...
        Processing User App smart_med_adherence...
                New app. Registering...
LOADED.
root@curatehealth:/indivo/indivo_server# nano /etc/apache2/sites-available/default
root@curatehealth:/indivo/indivo_server# python manage.py cleanup_old_tokens

Now running the unit test to check server..

root@curatehealth:/indivo/indivo_server# python manage.py test indivo
Creating test database for alias 'default'...
..............................................................................................................
==========================
RUNNING INTEGRATION TESTS:
==========================

=============================================================================
Report:
.......... pass : Document Handling Test
.......... pass : Sharing
.......... pass : PHA Document Handling
.......... pass : PHAing record_app delete
.......... pass : PHAing app delete
.......... pass : AppSpecific
.......... pass : Document Metadata Test
.......... pass : OAuthing
.......... pass : Binary Document Test
.......... pass : Accounting
.......... pass : Record Shares
.......... pass : Messaging
.......... pass : Special Document Handling
.......... pass : Auditing
.......... pass : Document Processing Test
.......... pass : Security
=============================================================================
................................................................................................................................................................
----------------------------------------------------------------------
Ran 270 tests in 108.673s

OK
Destroying test database for alias 'default'...
root@curatehealth:/indivo/indivo_server#