Projet

Général

Profil

0001-misc-move-api-tests.patch

Lauréline Guérin, 26 février 2021 11:00

Télécharger (3,29 ko)

Voir les différences:

Subject: [PATCH 1/4] misc: move api tests

 tests/api/__init__.py                          |  0
 tests/{test_api.py => api/test_all.py}         |  0
 tests/{test_api_utils.py => api/test_utils.py} |  0
 tests/test_convert_to_sql.py                   | 13 ++++++++++++-
 tests/test_formdata.py                         | 14 ++++++++++++--
 5 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 tests/api/__init__.py
 rename tests/{test_api.py => api/test_all.py} (100%)
 rename tests/{test_api_utils.py => api/test_utils.py} (100%)
tests/test_convert_to_sql.py
7 7
from django.core.management import get_commands
8 8
from django.core.management import call_command
9 9
from django.core.management.base import CommandError
10
from quixote import get_publisher
10 11

  
11 12
from wcs.sql import cleanup_connection
12 13
from wcs.formdef import FormDef
......
15 16
from utilities import clean_temporary_pub
16 17
from utilities import create_temporary_pub
17 18
from utilities import force_connections_close
18
from test_api import local_user
19 19

  
20 20

  
21 21
@pytest.fixture
......
70 70
    clean_temporary_pub()
71 71

  
72 72

  
73
@pytest.fixture
74
def local_user():
75
    get_publisher().user_class.wipe()
76
    user = get_publisher().user_class()
77
    user.name = 'Jean Darmette'
78
    user.email = 'jean.darmette@triffouilis.fr'
79
    user.name_identifiers = ['0123456789']
80
    user.store()
81
    return user
82

  
83

  
73 84
def test_command_exists():
74 85
    assert 'convert_to_sql' in get_commands()
75 86

  
tests/test_formdata.py
6 6
import time
7 7

  
8 8
import mock
9
from quixote import get_publisher
9 10
from quixote.http_request import Upload
10 11
from wcs.qommon import force_str
11 12
from wcs.qommon.template import Template
......
33 34

  
34 35
from utilities import create_temporary_pub, clean_temporary_pub
35 36

  
36
from test_api import local_user
37

  
38 37

  
39 38
def pytest_generate_tests(metafunc):
40 39
    if 'pub' in metafunc.fixturenames:
......
73 72
    clean_temporary_pub()
74 73

  
75 74

  
75
@pytest.fixture
76
def local_user():
77
    get_publisher().user_class.wipe()
78
    user = get_publisher().user_class()
79
    user.name = 'Jean Darmette'
80
    user.email = 'jean.darmette@triffouilis.fr'
81
    user.name_identifiers = ['0123456789']
82
    user.store()
83
    return user
84

  
85

  
76 86
def test_basic(pub):
77 87
    formdata = formdef.data_class()()
78 88
    substvars = formdata.get_substitution_variables()
79
-