Projet

Général

Profil

0003-tests-drop-partial-sqlite-support-36990.patch

Paul Marillonnet, 15 novembre 2019 17:44

Télécharger (5,41 ko)

Voir les différences:

Subject: [PATCH 3/3] tests: drop partial sqlite support (#36990)

 tests/conftest.py                 | 9 +++------
 tests/test_concurrency.py         | 3 ---
 tests/test_manager_user_import.py | 3 ---
 tests/test_user_manager.py        | 7 +------
 tests/utils.py                    | 4 ----
 tox.ini                           | 1 -
 6 files changed, 4 insertions(+), 23 deletions(-)
tests/conftest.py
214 214

  
215 215
@pytest.fixture
216 216
def concurrency(settings):
217
    '''Select a level of concurrency based on the db, sqlite3 is less robust
218
       thant postgres due to its transaction lock timeout of 5 seconds.
217
    '''Select a level of concurrency based on the db. Currently only postgreql
218
       is supported.
219 219
    '''
220
    if 'sqlite' in settings.DATABASES['default']['ENGINE']:
221
        return 20
222
    else:
223
        return 100
220
    return 100
224 221

  
225 222

  
226 223
@pytest.fixture
tests/test_concurrency.py
20 20

  
21 21
import threading
22 22

  
23
from utils import skipif_sqlite
24 23

  
25

  
26
@skipif_sqlite
27 24
def test_attribute_value_uniqueness(migrations, transactional_db, simple_user, concurrency):
28 25
    #from django.db.transaction import set_autocommit
29 26
    # disabled default attributes
tests/test_manager_user_import.py
25 25
from authentic2.manager.user_import import UserImport, Report
26 26
from authentic2.models import Attribute
27 27

  
28
from utils import skipif_sqlite
29

  
30 28

  
31 29
@pytest.fixture
32 30
def profile(transactional_db):
33 31
    Attribute.objects.create(name='phone', kind='phone_number', label='Numéro de téléphone')
34 32

  
35 33

  
36
@skipif_sqlite
37 34
def test_user_import(media, transactional_db, profile):
38 35
    content = '''email key verified,first_name,last_name,phone no-create
39 36
tnoel@entrouvert.com,Thomas,Noël,1234
tests/test_user_manager.py
34 34
from authentic2.manager import user_import
35 35

  
36 36

  
37
from utils import login, get_link_from_mail, skipif_sqlite
37
from utils import login, get_link_from_mail
38 38

  
39 39
OU = get_ou_model()
40 40

  
......
125 125
    assert visible_users(response) == {simple_user.username}
126 126

  
127 127

  
128
@skipif_sqlite
129 128
def test_export_csv(settings, app, superuser, django_assert_num_queries):
130 129
    AT_COUNT = 30
131 130
    USER_COUNT = 2000
......
159 158
    assert len(table[0]) == (15 + AT_COUNT)
160 159

  
161 160

  
162
@skipif_sqlite
163 161
def test_export_csv_disabled_attribute(settings, app, superuser):
164 162
    attr = Attribute.objects.create(name='attr', label='Attr', kind='string')
165 163
    attr_d = Attribute.objects.create(name='attrd', label='Attrd', kind='string')
......
219 217
    assert response.pyquery('td.username')
220 218

  
221 219

  
222
@skipif_sqlite
223 220
@pytest.mark.parametrize('encoding', ['utf-8', 'cp1252', 'iso-8859-15'])
224 221
def test_user_import(encoding, transactional_db, app, admin, ou1, admin_ou1, media):
225 222
    Attribute.objects.create(name='phone', kind='phone_number', label='Numéro de téléphone')
......
378 375
    return response
379 376

  
380 377

  
381
@skipif_sqlite
382 378
def test_user_import_attributes(transactional_db, app, admin, media):
383 379
    Attribute.objects.create(name='more', kind='string', label='Signe particulier')
384 380
    Attribute.objects.create(name='title', kind='title', label='Titre')
......
440 436
    assert response.pyquery('.a2-manager-user-deletion')
441 437

  
442 438

  
443
@skipif_sqlite
444 439
def test_user_import_row_error_display(transactional_db, app, admin, media):
445 440
    User.objects.create(first_name='Elliott', last_name='1', ou=get_default_ou())
446 441
    User.objects.create(first_name='Elliott', last_name='2', ou=get_default_ou())
tests/utils.py
33 33
from authentic2 import utils
34 34

  
35 35

  
36
skipif_sqlite = pytest.mark.skipif('sqlite' in settings.DATABASES['default']['ENGINE'],
37
                                   reason='this test does not work with sqlite')
38

  
39

  
40 36
def login(app, user, path=None, password=None, remember_me=None, args=None, kwargs=None):
41 37
    if path:
42 38
        args = args or []
tox.ini
21 21
  authentic-oldldap: TESTS=tests/test_ldap.py
22 22
  rbac: TESTS=tests_rbac/
23 23

  
24
  sqlite: DB_ENGINE=django.db.backends.sqlite3
25 24
  pg: DB_ENGINE=django.db.backends.postgresql_psycopg2
26 25

  
27 26
  JUNIT={tty::-o junit_suite_name={envname} --junit-xml=junit-{envname}.xml}
28
-