From 0727145d53d81b31609187dc096ddbbe7346deb4 Mon Sep 17 00:00:00 2001 From: "leonard.bongard" Date: Wed, 29 Jul 2020 19:52:31 +0200 Subject: [PATCH 01/18] add test folder; add test for frontend views --- tests/__init__.py | 1 + tests/tests_base/__init__.py | 0 tests/tests_base/test_models_base.py | 0 tests/tests_base/test_views_base.py | 0 tests/tests_content/__init__.py | 0 tests/tests_content/test_models_content.py | 0 tests/tests_content/test_views_content.py | 0 tests/tests_export/test_views_export.py | 0 tests/tests_frontend/__init__.py | 0 tests/tests_frontend/test_urls_frontend.py | 15 ++ tests/tests_frontend/test_views.py | 293 +++++++++++++++++++++ 11 files changed, 309 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/tests_base/__init__.py create mode 100644 tests/tests_base/test_models_base.py create mode 100644 tests/tests_base/test_views_base.py create mode 100644 tests/tests_content/__init__.py create mode 100644 tests/tests_content/test_models_content.py create mode 100644 tests/tests_content/test_views_content.py create mode 100644 tests/tests_export/test_views_export.py create mode 100644 tests/tests_frontend/__init__.py create mode 100644 tests/tests_frontend/test_urls_frontend.py create mode 100644 tests/tests_frontend/test_views.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ + diff --git a/tests/tests_base/__init__.py b/tests/tests_base/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tests_base/test_models_base.py b/tests/tests_base/test_models_base.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tests_base/test_views_base.py b/tests/tests_base/test_views_base.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tests_content/__init__.py b/tests/tests_content/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tests_content/test_models_content.py b/tests/tests_content/test_models_content.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tests_content/test_views_content.py b/tests/tests_content/test_views_content.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tests_export/test_views_export.py b/tests/tests_export/test_views_export.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tests_frontend/__init__.py b/tests/tests_frontend/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/tests_frontend/test_urls_frontend.py b/tests/tests_frontend/test_urls_frontend.py new file mode 100644 index 00000000..7f02435c --- /dev/null +++ b/tests/tests_frontend/test_urls_frontend.py @@ -0,0 +1,15 @@ +from django.test import SimpleTestCase +from django.urls import reverse, resolve +from django.test import RequestFactory, TestCase +"""from frontend.views import StartView + + +class TestFrontendUrls(TestCase): # todo write url tests if needed + + def test_index_url_is_resolved(self): + + url = reverse('frontend:index') + #self.assertEquals(resolve(url).func, StartView.as_view()) + + +""" \ No newline at end of file diff --git a/tests/tests_frontend/test_views.py b/tests/tests_frontend/test_views.py new file mode 100644 index 00000000..2cbb559f --- /dev/null +++ b/tests/tests_frontend/test_views.py @@ -0,0 +1,293 @@ +from django.contrib.auth.models import User +from django.test import SimpleTestCase, Client +from django.urls import reverse, resolve +from django.test import RequestFactory, TestCase +from django_cas_ng.views import LoginView + +from base.models import Course, Profile, Period, Category, Topic, Content, Comment, CourseStructureEntry + +from frontend.views import DeleteComment, EditComment, StartView, CourseView, DashboardView, ProfileView, \ + ProfileEditView, CourseListView, CourseListForCategoryView, CourseListForPeriodView +from frontend.views.search import SearchView + + +class Test_comment_delete_classed_based_views(TestCase): + + def setUp(self): + # create + self.client = Client() + self.staffuser = User.objects.create(username="testuser", password="testpassword", + first_name="first", last_name="last", is_staff=True, is_superuser=False, + is_active=True) + self.profile = Profile.objects.get(user=self.staffuser) + self.client.login(username=self.profile.user.username, password=self.profile.user.password) + + self.period = Period.objects.create(title="Period", start="2020-06-29", end="2020-07-29") + self.category = Category.objects.create(title="Category") + self.topic = Topic.objects.create(title="Title", category=self.category) + self.content = Content.objects.create(topic=self.topic, author=self.profile, + description="D", type="Dummy_Type", language="English") + self.comment = Comment.objects.create(content=self.content, author=self.profile, text="Comment") + self.course = Course.objects.create(title="Course", description="D", category=self.category, period=self.period) + self.structure = CourseStructureEntry.objects.create(course=self.course, index="1", topic=self.topic) + + self.request_delete = RequestFactory().get( + reverse("frontend:comment-delete", args=[self.course.id, self.topic.id, self.content.id, self.comment.id])) + self.request_delete.user = self.profile.user # for factory + + # self.request_edit = RequestFactory().get(reverse("frontend:comment-edit")) + + def test_delete_comment(self): + view = DeleteComment() + view.setup(self.request_delete) + response = DashboardView.as_view()(self.request_delete) + self.assertEquals(response.status_code, 200) + # todo delete comment with and without permission + + +class Test_page_classed_based_views(TestCase): + + def setUp(self): + # create + self.client = Client() + self.staffuser = User.objects.create(username="testuser", password="testpassword", + first_name="first", last_name="last", is_staff=True, + is_superuser=False) + self.profile = Profile.objects.get(user=self.staffuser) # wird automatisch angelegt + self.client.login(username=self.profile.user.username, password=self.profile.user.password) + + self.period = Period.objects.create(title="Period", start="2020-06-29", end="2020-07-29") + self.category = Category.objects.create(title="Category") + self.topic = Topic.objects.create(title="Title", category=self.category) + self.content = Content.objects.create(topic=self.topic, author=self.profile, + description="D", type="Dummy_Type", language="English") + self.comment = Comment.objects.create(content=self.content, author=self.profile, text="Comment") + self.course = Course.objects.create(title="Course", description="D", category=self.category, + period=self.period) + self.structure = CourseStructureEntry.objects.create(course=self.course, index="1", topic=self.topic) + + self.request_index = RequestFactory().get(reverse("frontend:index")) + self.request_index.user = self.staffuser # for factory + + self.request_dashboard = RequestFactory().get(reverse("frontend:dashboard")) + self.request_dashboard.user = self.staffuser # for factory + + def test_index(self): + view = LoginView() + view.setup(self.request_index) + response = DashboardView.as_view()(self.request_index) + self.assertEquals(response.status_code, 200) + + def test_dashboard_view(self): + view = DashboardView() + view.setup(self.request_dashboard) + response = DashboardView.as_view()(self.request_dashboard) + self.assertEquals(response.status_code, 200) + + # check context + context = view.get_context_data() + self.assertIn('periods', context) + self.assertIn('categories', context) + self.assertIn('view', context) + + # check querysets + self.assertEquals(context["categories"].get(title=self.category.title), self.category) + self.assertEquals(len(context["categories"].values()), 1) + + self.assertEquals(context["periods"].get(title=self.period.title), self.period) + self.assertEquals(len(context["periods"].values()), 1) + + +class Test_profile_classed_based_views(TestCase): + + def setUp(self): + # create + self.client = Client() + self.staffuser = User.objects.create(username="testuser", password="testpassword", + first_name="first", last_name="last", is_staff=True, + is_superuser=False) + self.profile = Profile.objects.get(user=self.staffuser) # wird automatisch angelegt + self.client.login(username=self.profile.user.username, password=self.profile.user.password) + + self.period = Period.objects.create(title="Period", start="2020-06-29", end="2020-07-29") + self.category = Category.objects.create(title="Category") + self.topic = Topic.objects.create(title="Title", category=self.category) + self.content = Content.objects.create(topic=self.topic, author=self.profile, + description="D", type="Dummy_Type", language="English") + self.comment = Comment.objects.create(content=self.content, author=self.profile, text="Comment") + self.course = Course.objects.create(title="Course", description="D", category=self.category, + period=self.period) + self.structure = CourseStructureEntry.objects.create(course=self.course, index="1", topic=self.topic) + + self.request_profile = RequestFactory().get(reverse("frontend:profile", args=[self.profile.user.id, ])) + self.request_profile.user = self.staffuser # for factory + + self.request_profile_edit = RequestFactory().get(reverse("frontend:profile-edit")) + self.request_profile_edit.user = self.staffuser # for factory + + def test_profile(self): + view = ProfileEditView() + view.setup(self.request_profile) + self.assertTrue(view.get_queryset().filter(user=self.profile)) + + response = ProfileView.as_view()(self.request_profile, pk=self.staffuser.pk) + self.assertEquals(response.status_code, 200) + # self.assertTemplateUsed(response,"frontend:profile") # only useable on client() # todo should be tested? + + def test_profile_edit(self): + view = ProfileEditView() + view.setup(self.request_profile_edit) + response = ProfileEditView.as_view()(self.request_profile_edit) + + self.assertEquals(response.status_code, 200) + self.assertEquals(view.get_success_url(), self.request_profile.path) + self.assertEquals(view.get_object(), self.profile) + # todo how to test form with view? + + +class Test_search_classed_based_views(TestCase): + + def setUp(self): + # create + self.client = Client() + self.staffuser = User.objects.create(username="testuser", password="testpassword", + first_name="first", last_name="last", is_staff=True, + is_superuser=False) + self.profile = Profile.objects.get(user=self.staffuser) # wird automatisch angelegt + self.client.login(username=self.profile.user.username, password=self.profile.user.password) + + self.period = Period.objects.create(title="Period", start="2020-06-29", end="2020-07-29") + self.category = Category.objects.create(title="Category") + self.topic = Topic.objects.create(title="Title", category=self.category) + self.content = Content.objects.create(topic=self.topic, author=self.profile, + description="D", type="Dummy_Type", language="English") + self.comment = Comment.objects.create(content=self.content, author=self.profile, text="Comment") + self.course = Course.objects.create(title="Course", description="D", category=self.category, + period=self.period) + self.structure = CourseStructureEntry.objects.create(course=self.course, index="1", topic=self.topic) + + def test_searchview_find_course_true(self): + self.request_search = RequestFactory().get(reverse("frontend:search") + "?q=" + self.course.title) + self.request_search.user = self.staffuser # for factory + + view = SearchView() + view.setup(self.request_search) + self.assertTrue(view.get_queryset()["courses"].filter(title=self.course.title)) + + view.object_list = [] + self.assertIn("search_query", view.get_context_data()) + + response = SearchView.as_view()(self.request_search) + self.assertEquals(response.status_code, 200) + + def test_searchview_find_course_false(self): + self.request_search = RequestFactory().get(reverse("frontend:search") + "?q=***********") + self.request_search.user = self.staffuser # for factory + + view = SearchView() + view.setup(self.request_search) + self.assertFalse(view.get_queryset()["courses"].filter(title=self.course.title)) + + response = SearchView.as_view()(self.request_search) + self.assertEquals(response.status_code, 200) + + # todo test for all searching possibilities? + + + +class Test_courses_classed_based_views(TestCase): + + def setUp(self): + # create + self.client = Client() + self.staffuser = User.objects.create(username="testuser", password="testpassword", + first_name="first", last_name="last", is_staff=True, + is_superuser=False) + self.profile = Profile.objects.get(user=self.staffuser) # wird automatisch angelegt + self.client.login(username=self.profile.user.username, password=self.profile.user.password) + + self.period = Period.objects.create(title="Period", start="2020-06-29", end="2020-07-29") + self.period_fake = Period.objects.create(title="Period_fake", start="2020-06-29", end="2020-07-29") + self.category = Category.objects.create(title="Category") + self.category_fake = Category.objects.create(title="Category_Fake") + + self.topic = Topic.objects.create(title="Title", category=self.category) + self.content = Content.objects.create(topic=self.topic, author=self.profile, + description="D", type="Dummy_Type", language="English") + self.comment = Comment.objects.create(content=self.content, author=self.profile, text="Comment") + self.course = Course.objects.create(title="Course", description="D", category=self.category, + period=self.period) + for i in range(CourseListView.paginate_by): # to have more than one site + Course.objects.create(title="Course"+str(i), description="D", category=self.category, + period=self.period) + self.structure = CourseStructureEntry.objects.create(course=self.course, index="1", topic=self.topic) + + self.request_courses = RequestFactory().get(reverse("frontend:courses")) + self.request_courses.user = self.staffuser # for factory + + self.request_category_courses = RequestFactory().get(reverse("frontend:category-courses", + args=[self.category.id,])) + self.request_category_courses.user = self.staffuser # for factory + + self.request_period_courses = RequestFactory().get( + reverse("frontend:period-courses", args=[self.period.id, ])) + self.request_period_courses.user = self.staffuser # for factory + + def test_CourseListView(self): + view = CourseListView() + view.setup(self.request_courses, **{'sort':'title-z'}) # ** = kwargs var + self.assertTrue(len(view.get_queryset()) == 10) + view.object_list = [] + self.assertEquals(view.get_context_data()["sort"], "Z-A") + self.assertGreater(view.get_queryset().first().title, "Course") # sorting is django, so no need for testing + + response = CourseListView.as_view()(self.request_courses) + self.assertEquals(response.status_code, 200) + + + def test_CourseListForCategoryView(self): + view = CourseListForCategoryView() + view.setup(self.request_category_courses, **{'pk': self.category.id}) # ** = kwargs var + view.object_list = [] + view.dispatch(self.request_category_courses) + self.assertEquals(view.get_context_data()['category'], self.category) + self.assertTrue(len(view.get_queryset()) == 10) + + response = CourseListForCategoryView.as_view()(self.request_category_courses, pk=self.category.id) + self.assertEquals(response.status_code, 200) + + def test_CourseListForCategoryView_Fake_category(self): + view = CourseListForCategoryView() + view.setup(self.request_category_courses, **{'pk': self.category_fake.id}) # ** = kwargs var + view.object_list = [] + view.dispatch(self.request_category_courses) + self.assertEquals(view.get_context_data()['category'], self.category_fake) + self.assertTrue(len(view.get_queryset()) == 0) + + response = CourseListForCategoryView.as_view()(self.request_category_courses, pk=self.category_fake.id) + self.assertEquals(response.status_code, 200) + + def test_CourseListForPeriodView(self): + view = CourseListForPeriodView() + view.setup(self.request_period_courses, **{'pk': self.period.id}) # ** = kwargs var + view.object_list = [] + view.dispatch(self.request_period_courses) + self.assertEquals(view.get_context_data()['period'], self.period) + self.assertTrue(len(view.get_queryset()) == 10) + + response = CourseListForPeriodView.as_view()(self.request_period_courses, pk=self.period.id) + self.assertEquals(response.status_code, 200) + + def test_CourseListForPeriodView_fake_period(self): + view = CourseListForPeriodView() + view.setup(self.request_period_courses, **{'pk': self.period_fake.id}) # ** = kwargs var + view.object_list = [] + view.dispatch(self.request_period_courses) + self.assertEquals(view.get_context_data()['period'], self.period_fake) + self.assertTrue(len(view.get_queryset()) == 0) + + response = CourseListForPeriodView.as_view()(self.request_period_courses, pk=self.period_fake.id) + self.assertEquals(response.status_code, 200) + +# todo aufteilen in einzelne files ? +# todo es fehlt bei views: content course coursebook comment(oben angefangen) \ No newline at end of file From 9da490db464dbe8f2e26506746a84395d0641ae2 Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Mon, 28 Sep 2020 17:08:13 +0200 Subject: [PATCH 02/18] introduce special test settings --- .github/workflows/django.yml | 2 +- collab_coursebook/settings_ci.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 collab_coursebook/settings_ci.py diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 22281610..27531cc6 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -28,4 +28,4 @@ jobs: - name: Run Tests run: | python manage.py check - python manage.py test + python manage.py test --settings collab-coursebook.settings_ci diff --git a/collab_coursebook/settings_ci.py b/collab_coursebook/settings_ci.py new file mode 100644 index 00000000..2b8927c9 --- /dev/null +++ b/collab_coursebook/settings_ci.py @@ -0,0 +1,18 @@ +from collab_coursebook.settings import * +import collab_coursebook.settings_secrets as secrets + +DEBUG = False +SECRET_KEY = secrets.SECRET_KEY + +SESSION_COOKIE_SECURE = True +CSRF_COOKIE_SECURE = True + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'HOST': 'localhost', + 'NAME': 'test', + 'USER': 'django', + 'PASSWORD': 'test' + } +} \ No newline at end of file From 430711bb244ed30237b69d9c5b446b55833ad633 Mon Sep 17 00:00:00 2001 From: leonard Date: Mon, 28 Sep 2020 17:11:29 +0200 Subject: [PATCH 03/18] check migrations --- .github/workflows/django.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 27531cc6..e9d12353 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -28,4 +28,5 @@ jobs: - name: Run Tests run: | python manage.py check + python manage.py makemigrations --check python manage.py test --settings collab-coursebook.settings_ci From 25c6c4d857beac2620aa7629c6509a43afc2d6a7 Mon Sep 17 00:00:00 2001 From: leonard Date: Mon, 28 Sep 2020 17:12:17 +0200 Subject: [PATCH 04/18] check migrations --- .github/workflows/django.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index e9d12353..acf9d7bc 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -29,4 +29,5 @@ jobs: run: | python manage.py check python manage.py makemigrations --check + python manage.py migrate --check python manage.py test --settings collab-coursebook.settings_ci From 8b89e3eea48292d84d06c32b7a1cd0c3f3697f62 Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Mon, 28 Sep 2020 17:22:58 +0200 Subject: [PATCH 05/18] check deployment --- .github/workflows/django.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index acf9d7bc..1fb10259 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -31,3 +31,6 @@ jobs: python manage.py makemigrations --check python manage.py migrate --check python manage.py test --settings collab-coursebook.settings_ci + - name: Check Deployment + run : | + python manage.py --deploy --settings=collab-coursebook.settings_production \ No newline at end of file From df98c71b8390d42d012fe8238a8631df879c4dd6 Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Mon, 28 Sep 2020 17:24:13 +0200 Subject: [PATCH 06/18] check deployment --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 1fb10259..bd356c91 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -33,4 +33,4 @@ jobs: python manage.py test --settings collab-coursebook.settings_ci - name: Check Deployment run : | - python manage.py --deploy --settings=collab-coursebook.settings_production \ No newline at end of file + python manage.py check --deploy --settings=collab-coursebook.settings_production \ No newline at end of file From 0d12e8a63e73a8f59bb0ff8c238c1a030aef713a Mon Sep 17 00:00:00 2001 From: leonard Date: Thu, 1 Oct 2020 15:44:07 +0200 Subject: [PATCH 07/18] remove todos --- tests/tests_frontend/test_views.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/tests_frontend/test_views.py b/tests/tests_frontend/test_views.py index 2cbb559f..ffda2864 100644 --- a/tests/tests_frontend/test_views.py +++ b/tests/tests_frontend/test_views.py @@ -138,7 +138,6 @@ def test_profile_edit(self): view = ProfileEditView() view.setup(self.request_profile_edit) response = ProfileEditView.as_view()(self.request_profile_edit) - self.assertEquals(response.status_code, 200) self.assertEquals(view.get_success_url(), self.request_profile.path) self.assertEquals(view.get_object(), self.profile) @@ -194,7 +193,6 @@ def test_searchview_find_course_false(self): # todo test for all searching possibilities? - class Test_courses_classed_based_views(TestCase): def setUp(self): @@ -217,16 +215,16 @@ def setUp(self): self.comment = Comment.objects.create(content=self.content, author=self.profile, text="Comment") self.course = Course.objects.create(title="Course", description="D", category=self.category, period=self.period) - for i in range(CourseListView.paginate_by): # to have more than one site - Course.objects.create(title="Course"+str(i), description="D", category=self.category, - period=self.period) + for i in range(CourseListView.paginate_by): # to have more than one site + Course.objects.create(title="Course" + str(i), description="D", category=self.category, + period=self.period) self.structure = CourseStructureEntry.objects.create(course=self.course, index="1", topic=self.topic) self.request_courses = RequestFactory().get(reverse("frontend:courses")) self.request_courses.user = self.staffuser # for factory self.request_category_courses = RequestFactory().get(reverse("frontend:category-courses", - args=[self.category.id,])) + args=[self.category.id, ])) self.request_category_courses.user = self.staffuser # for factory self.request_period_courses = RequestFactory().get( @@ -235,7 +233,7 @@ def setUp(self): def test_CourseListView(self): view = CourseListView() - view.setup(self.request_courses, **{'sort':'title-z'}) # ** = kwargs var + view.setup(self.request_courses, **{'sort': 'title-z'}) # ** = kwargs var self.assertTrue(len(view.get_queryset()) == 10) view.object_list = [] self.assertEquals(view.get_context_data()["sort"], "Z-A") @@ -244,7 +242,6 @@ def test_CourseListView(self): response = CourseListView.as_view()(self.request_courses) self.assertEquals(response.status_code, 200) - def test_CourseListForCategoryView(self): view = CourseListForCategoryView() view.setup(self.request_category_courses, **{'pk': self.category.id}) # ** = kwargs var @@ -289,5 +286,4 @@ def test_CourseListForPeriodView_fake_period(self): response = CourseListForPeriodView.as_view()(self.request_period_courses, pk=self.period_fake.id) self.assertEquals(response.status_code, 200) -# todo aufteilen in einzelne files ? -# todo es fehlt bei views: content course coursebook comment(oben angefangen) \ No newline at end of file + From 70da17f2b48d0d21b1b47b657165755b567c7ae0 Mon Sep 17 00:00:00 2001 From: tobi-werner <55047826+tobi-werner@users.noreply.github.com> Date: Tue, 13 Oct 2020 15:04:27 +0200 Subject: [PATCH 08/18] Update django.yml remove manage.py migrate --check --- .github/workflows/django.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index bd356c91..fadd9a49 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -29,8 +29,7 @@ jobs: run: | python manage.py check python manage.py makemigrations --check - python manage.py migrate --check python manage.py test --settings collab-coursebook.settings_ci - name: Check Deployment run : | - python manage.py check --deploy --settings=collab-coursebook.settings_production \ No newline at end of file + python manage.py check --deploy --settings=collab-coursebook.settings_production From af25e1c2ac83d8c40ecc3a2844be32b5d833f8bd Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:09:11 +0200 Subject: [PATCH 09/18] fix: check deployment --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index fadd9a49..efa581b7 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -32,4 +32,4 @@ jobs: python manage.py test --settings collab-coursebook.settings_ci - name: Check Deployment run : | - python manage.py check --deploy --settings=collab-coursebook.settings_production + python manage.py check --deploy --settings=collab_coursebook.settings_production From 6c652d371362ea481c9d37cfbbf7b07fff3316a7 Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:10:39 +0200 Subject: [PATCH 10/18] fix: check deployment --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index efa581b7..4ad14a5e 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -29,7 +29,7 @@ jobs: run: | python manage.py check python manage.py makemigrations --check - python manage.py test --settings collab-coursebook.settings_ci + python manage.py test --settings collab_coursebook.settings_ci - name: Check Deployment run : | python manage.py check --deploy --settings=collab_coursebook.settings_production From fdff51124b7b7d04c8ce07530dd9355fc585bdb6 Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:12:34 +0200 Subject: [PATCH 11/18] fix: run tests --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 4ad14a5e..17f2919b 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -29,7 +29,7 @@ jobs: run: | python manage.py check python manage.py makemigrations --check - python manage.py test --settings collab_coursebook.settings_ci + python manage.py test --settings=collab_coursebook.settings_ci - name: Check Deployment run : | python manage.py check --deploy --settings=collab_coursebook.settings_production From 80d9aa7d5074cc48de8e105e5323e8449bc802ee Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:16:50 +0200 Subject: [PATCH 12/18] fix: settings_ci --- collab_coursebook/settings_ci.py | 5 +---- collab_coursebook/settings_secrets.py.sample | 9 --------- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 collab_coursebook/settings_secrets.py.sample diff --git a/collab_coursebook/settings_ci.py b/collab_coursebook/settings_ci.py index 2b8927c9..eca7b09a 100644 --- a/collab_coursebook/settings_ci.py +++ b/collab_coursebook/settings_ci.py @@ -1,8 +1,5 @@ -from collab_coursebook.settings import * -import collab_coursebook.settings_secrets as secrets - DEBUG = False -SECRET_KEY = secrets.SECRET_KEY +SECRET_KEY = 'SECRET' SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True diff --git a/collab_coursebook/settings_secrets.py.sample b/collab_coursebook/settings_secrets.py.sample deleted file mode 100644 index a051c21e..00000000 --- a/collab_coursebook/settings_secrets.py.sample +++ /dev/null @@ -1,9 +0,0 @@ -SECRET_KEY = '' - -HOSTS = [] - -DB_NAME = '' - -DB_USER = '' - -DB_PASSWORD = '' \ No newline at end of file From 22db1461144b8742e6fee3b8226f2a27fc2253b1 Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:23:12 +0200 Subject: [PATCH 13/18] fix: settings_ci --- collab_coursebook/settings_ci.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/collab_coursebook/settings_ci.py b/collab_coursebook/settings_ci.py index eca7b09a..61164034 100644 --- a/collab_coursebook/settings_ci.py +++ b/collab_coursebook/settings_ci.py @@ -1,3 +1,6 @@ +# noinspection PyUnresolvedReferences +from collab_coursebook.settings import * + DEBUG = False SECRET_KEY = 'SECRET' From f579018d5b3465eb80abe3274ab423c308dab155 Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:25:57 +0200 Subject: [PATCH 14/18] add allowed_hosts --- collab_coursebook/settings_ci.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/collab_coursebook/settings_ci.py b/collab_coursebook/settings_ci.py index 61164034..b75f3bd8 100644 --- a/collab_coursebook/settings_ci.py +++ b/collab_coursebook/settings_ci.py @@ -2,6 +2,9 @@ from collab_coursebook.settings import * DEBUG = False + +ALLOWED_HOSTS = [] + SECRET_KEY = 'SECRET' SESSION_COOKIE_SECURE = True From 4b7c31edbed8e36d4357093fe55e3f877c1c7ddf Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:29:48 +0200 Subject: [PATCH 15/18] add install statement --- .github/workflows/django.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 17f2919b..8c91360d 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -25,6 +25,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt + pip install psycopg2-binary - name: Run Tests run: | python manage.py check From cd6aa53691d04fff1c4252a2bc0682c1d58b2019 Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:38:47 +0200 Subject: [PATCH 16/18] change host --- .github/workflows/django.yml | 2 +- collab_coursebook/settings_ci.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 8c91360d..8ff823f1 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -25,7 +25,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install psycopg2-binary + pip install psycopg2 - name: Run Tests run: | python manage.py check diff --git a/collab_coursebook/settings_ci.py b/collab_coursebook/settings_ci.py index b75f3bd8..2473cfae 100644 --- a/collab_coursebook/settings_ci.py +++ b/collab_coursebook/settings_ci.py @@ -3,7 +3,7 @@ DEBUG = False -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['127.0.0.1'] SECRET_KEY = 'SECRET' @@ -13,7 +13,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'HOST': 'localhost', + 'HOST': '127.0.0.1', 'NAME': 'test', 'USER': 'django', 'PASSWORD': 'test' From 5452eebf3d4da58d440f03b897ed9b95e2cb0ba6 Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:41:20 +0200 Subject: [PATCH 17/18] remove database --- collab_coursebook/settings_ci.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/collab_coursebook/settings_ci.py b/collab_coursebook/settings_ci.py index 2473cfae..01c55c36 100644 --- a/collab_coursebook/settings_ci.py +++ b/collab_coursebook/settings_ci.py @@ -10,12 +10,12 @@ SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'HOST': '127.0.0.1', - 'NAME': 'test', - 'USER': 'django', - 'PASSWORD': 'test' - } -} \ No newline at end of file +# DATABASES = { +# 'default': { +# 'ENGINE': 'django.db.backends.postgresql_psycopg2', +# 'HOST': '127.0.0.1', +# 'NAME': 'test', +# 'USER': 'django', +# 'PASSWORD': 'test' +# } +# } \ No newline at end of file From 3836c7862364e5ab0d40cccd8c5709d2ec42bd9d Mon Sep 17 00:00:00 2001 From: tobi-werner Date: Tue, 13 Oct 2020 15:44:11 +0200 Subject: [PATCH 18/18] re-add database --- collab_coursebook/settings_ci.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/collab_coursebook/settings_ci.py b/collab_coursebook/settings_ci.py index 01c55c36..2473cfae 100644 --- a/collab_coursebook/settings_ci.py +++ b/collab_coursebook/settings_ci.py @@ -10,12 +10,12 @@ SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True -# DATABASES = { -# 'default': { -# 'ENGINE': 'django.db.backends.postgresql_psycopg2', -# 'HOST': '127.0.0.1', -# 'NAME': 'test', -# 'USER': 'django', -# 'PASSWORD': 'test' -# } -# } \ No newline at end of file +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'HOST': '127.0.0.1', + 'NAME': 'test', + 'USER': 'django', + 'PASSWORD': 'test' + } +} \ No newline at end of file