Пример #1
0
 def test_all_get_request_paths_succeed(self):
     path_predicates = [
         Get(reverse('skills_present_list'), public=True),
         Get(reverse('profile'), public=False),
         Get(reverse('suggest'), public=False),
     ]
     assert_requesting_paths_succeeds(self, path_predicates)
Пример #2
0
 def test_all_admin_get_request_paths_succeed(self):
     path_predicates = [
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Member, self.members)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 SystemAccess, [
                     access for member in self.members
                     for access in member.system_accesses.all()
                 ])
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Secret, self.secrets)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Quote, self.quotes)
         ],
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #3
0
 def test_all_get_request_paths_succeed(self):
     path_predicates = [
         Get(reverse('announcement_admin'), public=False),
         Get(reverse('create_announcement'), public=False),
         Get(reverse('edit_announcement', args=[self.announcement1.pk]),
             public=False),
     ]
     assert_requesting_paths_succeeds(self, path_predicates)
Пример #4
0
 def test_all_get_request_paths_succeed(self):
     path_predicates = [
         Get(reverse('committee_list'), public=True),
         Get(reverse('committee_detail', args=[self.committee1.pk]),
             public=True),
         Get(reverse('committee_edit', args=[self.committee1.pk]),
             public=False),
         Get(reverse('committee_admin'), public=False),
     ]
     assert_requesting_paths_succeeds(self, path_predicates)
Пример #5
0
 def test_all_admin_get_request_paths_succeed(self):
     path_predicates = [
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(Category, self.categories)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(Question, self.questions)
         ],
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #6
0
 def test_all_admin_get_request_paths_succeed(self):
     path_predicates = [
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Content, [self.content1, self.content2])
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Page, [self.page1])
         ],
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #7
0
 def test_all_admin_get_request_paths_succeed(self):
     path_predicates = [
         Get('/robots.txt', public=True, translated=False),
         Get('/.well-known/security.txt', public=True, translated=False),
         Get(reverse_admin('index'), public=False),
         Get(reverse_admin('password_change'), public=False),
         *[
             Get(reverse_admin('app_list', args=[app_label]), public=False)
             for app_label in [
                 'announcements', 'auth', 'checkin', 'contentbox', 'docs',
                 'faq', 'groups', 'internal', 'make_queue', 'makerspace',
                 'news', 'social_django', 'users'
             ]
         ],
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #8
0
 def test_all_admin_get_request_paths_succeed(self):
     path_predicates = [
         Get(admin_url, public=False)
         for admin_url in generate_all_admin_urls_for_model_and_objs(
             User, self.users)
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #9
0
 def test_all_admin_get_request_paths_succeed(self):
     path_predicates = [
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(Printer3DCourse, [self.course1, self.course2])
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(MachineType, [self.printer_machine_type, self.sewing_machine_type])
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(MachineUsageRule, [self.usage_rule1, self.usage_rule2])
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(Machine, self.machines)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(Quota, self.quotas)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(ReservationRule, self.rules)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(Reservation, self.reservations)
         ],
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #10
0
 def test_all_get_request_paths_succeed(self):
     path_predicates = [
         Get(self.reverse('home'), public=False),
         Get(self.reverse('page_detail', self.page1.pk), public=False),
         Get(self.reverse('page_history', self.page1.pk), public=False),
         Get(self.reverse('old_page_content', self.page1.pk,
                          self.content1.pk),
             public=False),
         Get(self.reverse('old_page_content', self.page1.pk,
                          self.content2.pk),
             public=False),
         Get(self.reverse('create_page'), public=False),
         Get(self.reverse('edit_page', self.page1.pk), public=False),
         Get(self.reverse('search_pages'), public=False),
         Get('/robots.txt', public=True, translated=False),
         Get('/.well-known/security.txt', public=True, translated=False),
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'docs')
Пример #11
0
 def test_all_admin_get_request_paths_succeed(self):
     path_predicates = [
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Group, [self.group1.group_ptr])
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 InheritanceGroup, [self.group1])
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Committee, [self.committee1])
         ],
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #12
0
 def test_all_admin_get_request_paths_succeed(self):
     content_boxes = [
         self.get_content_box_from_url(url, client)
         for url, client, _ in self.url__client__should_be_bleached__tuples
     ]
     path_predicates = [
         Get(admin_url, public=False)
         for admin_url in generate_all_admin_urls_for_model_and_objs(
             ContentBox, content_boxes)
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #13
0
 def test_all_admin_get_request_paths_succeed(self):
     path_predicates = [
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Profile, self.profiles)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Skill, self.skills)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 SuggestSkill, self.suggest_skills)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 UserSkill, self.user_skills)
         ],
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #14
0
 def test_all_admin_get_request_paths_succeed(self):
     path_predicates = [
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Article, [self.article1, self.article2])
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 EventTicket, self.tickets)
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 Event, [self.event1, self.event2])
         ],
         *[
             Get(admin_url, public=False)
             for admin_url in generate_all_admin_urls_for_model_and_objs(
                 TimePlace, self.time_places)
         ],
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'admin')
Пример #15
0
 def test_all_get_request_paths_succeed(self):
     path_predicates = [
         Get(reverse('faq_list'), public=True),
         Get(reverse('faq_admin_panel'), public=False),
         Get(reverse('admin_question_list'), public=False),
         Get(reverse('question_create'), public=False),
         *[
             Get(reverse('question_update', args=[question.pk]), public=False)
             for question in self.questions
         ],
         Get(reverse('admin_category_list'), public=False),
         Get(reverse('category_create'), public=False),
         *[
             Get(reverse('category_update', args=[category.pk]), public=False)
             for category in self.categories
         ],
     ]
     assert_requesting_paths_succeeds(self, path_predicates)
Пример #16
0
 def test_all_old_urls_succeed(self):
     path_predicates = [
         Get('/rules/', public=True, permanent_redirect=True),
         Get('/reservation/rules/1/', public=True, permanent_redirect=True),
         Get('/reservation/rules/usage/1/',
             public=True,
             permanent_redirect=True),
         Get(f'/news/article/{self.article1.pk}/',
             public=True,
             permanent_redirect=True),
         Get(f'/news/event/{self.event1.pk}/',
             public=True,
             permanent_redirect=True),
         Get(f'/news/ticket/{self.ticket1.pk}/',
             public=False,
             permanent_redirect=True),
         Get(f'/news/ticket/me/', public=False, permanent_redirect=True),
     ]
     assert_requesting_paths_succeeds(self, path_predicates)
Пример #17
0
 def test_all_get_request_paths_succeed(self):
     path_predicates = [
         Get('/robots.txt', public=True, translated=False),
         Get('/.well-known/security.txt', public=True, translated=False),
         Get(reverse('front_page'), public=True),
         Get(reverse('adminpanel'), public=False),
         Get(reverse('about'), public=True),
         Get(reverse('contact'), public=True),
         Get(reverse('apply'), public=True),
         Get('/søk/', public=True),
         Get('/sok/', public=True),
         Get(reverse('cookies'), public=True),
         Get(reverse('privacypolicy'), public=True),
         Get(reverse('ckeditor_browse'), public=False, translated=False),
     ]
     assert_requesting_paths_succeeds(self, path_predicates)
Пример #18
0
    def test_all_get_request_paths_succeed(self):
        year, week_number, _weekday = timezone.localtime().isocalendar()
        # Create URL params to query all reservations
        api_reservation_list_url_params = urlencode({
            'startDate': Reservation.objects.earliest('start_time').start_time.isoformat(),
            'endDate': Reservation.objects.latest('end_time').end_time.isoformat(),
        })

        path_predicates = [
            # urlpatterns
            Get(reverse('machine_list'), public=True),

            # machine_urlpatterns
            Get(reverse('create_machine'), public=False),
            *[
                Get(reverse('edit_machine', args=[machine.pk]), public=False)
                for machine in self.machines
            ],

            # Back to urlpatterns
            *[
                Get(reverse('machine_detail', kwargs={'year': year, 'week': week_number, 'pk': machine.pk}), public=True)
                for machine in self.machines
            ],

            # calendar_urlpatterns
            *[
                Get(
                    f"{reverse('api_reservations', args=[machine.pk])}?{api_reservation_list_url_params}",
                    public=True,
                )
                for machine in self.machines
            ],
            *[
                Get(reverse('api_reservation_rules', args=[machine.pk]), public=True)
                for machine in self.machines
            ],

            # json_urlpatterns
            *[
                Get(reverse('reservation_json', args=[machine.pk]), public=False)
                for machine in self.machines
            ],
            *[
                Get(reverse('reservation_json', args=[reservation.machine.pk, reservation.pk]), public=False)
                for reservation in self.reservations
            ],
            Get(reverse('user_json', args=[self.user1.username]), public=False),
            Get(reverse('user_json', args=[self.user2.username]), public=False),

            # Back to urlpatterns
            *[
                Get(reverse('create_reservation', args=[machine.pk]), public=False)
                for machine in self.machines
            ],
            *[
                Get(reverse('edit_reservation', args=[reservation.pk]), public=False)
                for reservation in self.reservations if reservation != self.reservation2  # `reservation2` starts in the future
            ],
            Get(reverse('my_reservations_list'), public=False),
            Get(reverse('MAKE_reservations_list'), public=False),
            Get(reverse('find_free_slot'), public=False),

            # rules_urlpatterns
            Get(reverse('reservation_rule_list', args=[self.printer_machine_type.pk]), public=True),
            Get(reverse('reservation_rule_list', args=[self.sewing_machine_type.pk]), public=True),
            Get(reverse('create_reservation_rule', args=[self.printer_machine_type.pk]), public=False),
            Get(reverse('create_reservation_rule', args=[self.sewing_machine_type.pk]), public=False),
            *[
                Get(reverse('edit_reservation_rule', args=[rule.machine_type.pk, rule.pk]), public=False)
                for rule in self.rules
            ],
            Get(reverse('machine_usage_rules_detail', args=[self.printer_machine_type.pk]), public=True),
            Get(reverse('machine_usage_rules_detail', args=[self.sewing_machine_type.pk]), public=True),
            Get(reverse('edit_machine_usage_rules', args=[self.printer_machine_type.pk]), public=False),
            Get(reverse('edit_machine_usage_rules', args=[self.sewing_machine_type.pk]), public=False),

            # quota_urlpatterns
            Get(reverse('quota_panel'), public=False),
            Get(reverse('create_quota'), public=False),
            *[
                Get(reverse('edit_quota', args=[quota.pk]), public=False)
                for quota in self.quotas
            ],
            Get(reverse('user_quota_list', args=[self.user1.pk]), public=False),
            Get(reverse('user_quota_list', args=[self.user2.pk]), public=False),
            Get(reverse('quota_panel', args=[self.user1.pk]), public=False),
            Get(reverse('quota_panel', args=[self.user2.pk]), public=False),

            # course_urlpatterns
            Get(reverse('course_registration_list'), public=False),
            Get(reverse('create_course_registration'), public=False),
            Get(reverse('create_course_registration_success'), public=False),
            Get(reverse('edit_course_registration', args=[self.course1.pk]), public=False),
            Get(reverse('edit_course_registration', args=[self.course2.pk]), public=False),
        ]
        assert_requesting_paths_succeeds(self, path_predicates)
Пример #19
0
 def test_all_get_request_paths_succeed(self):
     path_predicates = [
         Get(reverse('admin_article_list'), public=False),
         Get(reverse('admin_event_list'), public=False),
         Get(reverse('admin_event_detail', args=[self.event1.pk]),
             public=False),
         Get(reverse('admin_event_detail', args=[self.event2.pk]),
             public=False),
         Get(reverse('article_list'), public=True),
         Get(reverse('article_create'), public=False),
         Get(reverse('article_edit', args=[self.article1.pk]),
             public=False),
         Get(reverse('article_edit', args=[self.article2.pk]),
             public=False),
         Get(reverse('article_detail', args=[self.article1.pk]),
             public=True),
         Get(reverse('article_detail', args=[self.article2.pk]),
             public=False),  # this article is private
         Get(reverse('event_list'), public=True),
         Get(reverse('event_create'), public=False),
         Get(reverse('event_edit', args=[self.event1.pk]), public=False),
         Get(reverse('event_edit', args=[self.event2.pk]), public=False),
         Get(reverse('event_ticket_list', args=[self.event2.pk]),
             public=False),  # can't test `event1`, as it has no tickets
         Get(reverse('event_detail', args=[self.event1.pk]), public=True),
         Get(reverse('event_detail', args=[self.event2.pk]),
             public=False),  # this event is private
         Get(reverse('register_event', args=[self.event1.pk]),
             public=False),
         Get(reverse('register_event', args=[self.event2.pk]),
             public=False),
         *[
             Get(reverse('timeplace_edit',
                         args=[time_place.event.pk, time_place.pk]),
                 public=False) for time_place in self.time_places
         ],
         Get(reverse('timeplace_create', args=[self.event1.pk]),
             public=False),
         Get(reverse('timeplace_create', args=[self.event2.pk]),
             public=False),
         *[
             Get(reverse('timeplace_ticket_list',
                         args=[time_place.event.pk, time_place.pk]),
                 public=False)
             for time_place in self.time_places if time_place != self.
             time_place3  # can't test `time_place3`, as it has no tickets
         ],
         *[
             Get(reverse('timeplace_ical',
                         args=[time_place.event.pk, time_place.pk]),
                 public=True) for time_place in self.time_places
         ],
         *[
             Get(reverse('register_timeplace',
                         args=[time_place.event.pk, time_place.pk]),
                 public=False)
             for time_place in self.time_places if time_place != self.
             time_place3  # can't test `time_place3`, as it has no tickets
         ],
         *[
             Get(reverse('ticket_detail', args=[ticket.pk]), public=False)
             for ticket in self.tickets
         ],
         Get(reverse('my_tickets_list'), public=False),
     ]
     assert_requesting_paths_succeeds(self, path_predicates)
Пример #20
0
 def test_all_non_member_get_request_paths_succeed(self):
     path_predicates = [
         Get(reverse_internal(self.home_content_box.url_name),
             public=False),
         Get(reverse_internal('contentbox_edit', self.home_content_box.pk),
             public=False),
         Get(reverse_internal('secret_list'), public=False),
         Get(reverse_internal('create_secret'), public=False),
         Get(reverse_internal('edit_secret', self.secret1.pk),
             public=False),
         Get(reverse_internal('edit_secret', self.secret2.pk),
             public=False),
         Get(reverse_internal('quote_list'), public=False),
         Get(reverse_internal('quote_create'), public=False),
         Get(reverse_internal('quote_update', self.quote1.pk),
             public=False),
         Get(reverse_internal('quote_update', self.quote2.pk),
             public=False),
         Get('/robots.txt', public=True, translated=False),
         Get('/.well-known/security.txt', public=True, translated=False),
     ]
     assert_requesting_paths_succeeds(self, path_predicates, 'internal')