Coverage for crateweb/config/test_settings.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2026-01-06 10:22 -0600

1""" 

2crate_anon/crateweb/config/test_settings.py 

3 

4=============================================================================== 

5 

6 Copyright (C) 2015, University of Cambridge, Department of Psychiatry. 

7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk). 

8 

9 This file is part of CRATE. 

10 

11 CRATE is free software: you can redistribute it and/or modify 

12 it under the terms of the GNU General Public License as published by 

13 the Free Software Foundation, either version 3 of the License, or 

14 (at your option) any later version. 

15 

16 CRATE is distributed in the hope that it will be useful, 

17 but WITHOUT ANY WARRANTY; without even the implied warranty of 

18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

19 GNU General Public License for more details. 

20 

21 You should have received a copy of the GNU General Public License 

22 along with CRATE. If not, see <https://www.gnu.org/licenses/>. 

23 

24=============================================================================== 

25 

26**Django test settings for crateweb project.** 

27 

28""" 

29 

30from pathlib import Path 

31 

32from crate_anon.common.constants import mebibytes 

33from crate_anon.crateweb.config.constants import ResearchDbInfoKeys as RDIKeys 

34 

35BASE_DIR = Path(__file__).resolve().parent 

36 

37DATABASES = { 

38 "default": { 

39 "ENGINE": "django.db.backends.sqlite3", 

40 "NAME": BASE_DIR / "crate_db.sqlite3", 

41 }, 

42 "research": { 

43 "ENGINE": "django.db.backends.sqlite3", 

44 "NAME": BASE_DIR / "research.sqlite3", 

45 }, 

46 "secret": { 

47 "ENGINE": "django.db.backends.sqlite3", 

48 "NAME": BASE_DIR / "secret.sqlite3", 

49 }, 

50} 

51 

52ROOT_URLCONF = "crate_anon.crateweb.config.urls" 

53 

54INSTALLED_APPS = ( 

55 "django.contrib.admin", 

56 "django.contrib.auth", 

57 "django.contrib.contenttypes", 

58 "django.contrib.sessions", 

59 "django.contrib.messages", 

60 "django.contrib.staticfiles", 

61 "django.contrib.humanize", # for nice comma formatting of numbers 

62 "debug_toolbar", # for debugging 

63 "django_extensions", # for graph_models, show_urls etc. 

64 "sslserver", # for SSL testing 

65 "rest_framework", 

66 "drf_spectacular", 

67 "drf_spectacular_sidecar", 

68 # 'kombu.transport.django', # for Celery with Django database as broker 

69 # 'template_profiler_panel', 

70 # 'silk', 

71 "crate_anon.crateweb.config.apps.UserProfileAppConfig", # for user-specific settings # noqa: E501 

72 "crate_anon.crateweb.config.apps.ResearchAppConfig", # the research database query app # noqa: E501 

73 "crate_anon.crateweb.config.apps.ConsentAppConfig", # the consent-to-contact app # noqa: E501 

74 "crate_anon.crateweb.config.apps.CoreAppConfig", # for e.g. the runcpserver command # noqa: E501 

75 "crate_anon.crateweb.config.apps.ApiConfig", # for the anonymisation API 

76) 

77 

78RESEARCH_DB_DIALECT = "mysql" 

79 

80RESEARCH_DB_INFO = [ 

81 { 

82 RDIKeys.NAME: "research", 

83 RDIKeys.DESCRIPTION: "Demo research database", 

84 RDIKeys.DATABASE: "", 

85 RDIKeys.SCHEMA: "research", 

86 RDIKeys.PID_PSEUDO_FIELD: "pid", 

87 RDIKeys.MPID_PSEUDO_FIELD: "mpid", 

88 RDIKeys.TRID_FIELD: "trid", 

89 RDIKeys.RID_FIELD: "brcid", 

90 RDIKeys.RID_FAMILY: 1, 

91 RDIKeys.MRID_TABLE: "patients", 

92 RDIKeys.MRID_FIELD: "nhshash", 

93 RDIKeys.PID_DESCRIPTION: "Patient ID", 

94 RDIKeys.MPID_DESCRIPTION: "Master patient ID", 

95 RDIKeys.RID_DESCRIPTION: "Research ID", 

96 RDIKeys.MRID_DESCRIPTION: "Master research ID", 

97 RDIKeys.TRID_DESCRIPTION: "Transient research ID", 

98 RDIKeys.SECRET_LOOKUP_DB: "secret", 

99 RDIKeys.DATE_FIELDS_BY_TABLE: {}, 

100 RDIKeys.DEFAULT_DATE_FIELDS: [], 

101 RDIKeys.UPDATE_DATE_FIELD: "_when_fetched_utc", 

102 }, 

103] 

104 

105RESEARCH_DB_FOR_CONTACT_LOOKUP = "research" 

106 

107PRIVATE_FILE_STORAGE_ROOT = "/tmp/files" 

108MAX_UPLOAD_SIZE_BYTES = mebibytes(10) 

109SECRET_KEY = "ti_aghvCFNnC6L3M8Sq48n1j0SIXaITJO0uFi2DTXBc" 

110RESEARCH_DB_TITLE = "My NHS Trust Research Database" 

111FORCE_SCRIPT_NAME = "/crate"