Coverage for boot_django.py: 93%

1 import os

2 from pathlib import Path

3 import sys

4

5 import django

6 from django.conf import settings

7

8 BASE_DIR = os.path.abspath(os.path.dirname(__file__))

9

10 settings_module = "django_custom_admin_pages.app_settings"

11

12# Add the path of "top" directory to the sys.path

13 top_level_dir = Path(__file__).resolve().parent.parent

14 test_proj_dir = os.path.join(top_level_dir, "test_proj")

15 sys.path.append(test_proj_dir)

16

17

18 def boot_django():

19 settings.configure(

20 DEBUG=True,

21 SECRET_KEY="deadbeefdeadbeefdeadbeef-deefbed",

22 DATABASES=(

23 {

24 "default": {

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

26 "NAME": os.path.join(BASE_DIR, "db.sqlite3"),

27 }

28 }

29 ),

30 INSTALLED_APPS=(

31 "django.contrib.auth",

32 "django.contrib.contenttypes",

33 "django.contrib.sessions",

34 "django_custom_admin_pages",

35 "django_custom_admin_pages.admin.CustomAdminConfig",

36 "test_app",

37 ),

38 MIDDLEWARE=[

39 "django.middleware.security.SecurityMiddleware",

40 "django.contrib.sessions.middleware.SessionMiddleware",

41 "django.middleware.common.CommonMiddleware",

42 "django.contrib.auth.middleware.AuthenticationMiddleware",

43 "django.middleware.clickjacking.XFrameOptionsMiddleware",

44 ],

45 TIME_ZONE="UTC",

46 ROOT_URLCONF="django_custom_admin_pages.tests.test_urls",

47 USE_TZ=True,

48 DEFAULT_CUSTOM_ADMIN_PATH="django-custom-admin-pages/",

49 CUSTOM_ADMIN_DEFAULT_APP_LABEL="django_custom_admin_pages",

50 TEMPLATES=[

51 {

52 "BACKEND": "django.template.backends.django.DjangoTemplates",

53 "DIRS": [os.path.join(os.path.join(BASE_DIR, "tests"), "templates")],

54 "APP_DIRS": True,

55 "OPTIONS": {

56 "context_processors": [

57 "django.template.context_processors.debug",

58 "django.template.context_processors.request",

59 "django.contrib.auth.context_processors.auth",

60 "django.contrib.messages.context_processors.messages",

61 ],

62 },

63 },

64 ],

65 )

66 django.setup()

67

68

69 if __name__ == "__main__":

70 boot_django()