def test_create_menu_get_not_permited(self):
        ALLOW_VIEW_SELECTION.remove('angie')
        request = self.factory.get(self.url)
        parsed_request = set_base_request(request, self.user)
        response = CreateMenuView.as_view()(parsed_request)

        self.assertEqual(response.status_code, 302)
    def test_send_reminder_get(self, mock):
        mock.return_value = 'ok'
        request = self.factory.get(self.url)
        parsed_request = set_base_request(request, self.user)
        response = SendReminder.as_view()(parsed_request)

        self.assertEqual(response.status_code, 200)
    def test_create_menu_post(self):
        ALLOW_VIEW_SELECTION.append('angie')
        request = self.factory.post(self.url, self.data)
        parsed_request = set_base_request(request, self.user)
        response = CreateMenuView.as_view()(parsed_request)
        menu_created = Menu.objects.get(menu_date='2020-03-03')

        self.assertEqual(menu_created.option1, 'test')
        self.assertEqual(response.status_code, 200)
예제 #4
0
    def test_edit_menu_post(self):
        ALLOW_VIEW_SELECTION.append('angie')
        request = self.factory.post(self.url, self.data)
        parsed_request = set_base_request(request, self.user)
        response = EditMenuView.as_view()(parsed_request, self.menu.pk)
        edited_menu = Menu.objects.get(menu_date='2020-03-03')

        self.assertEqual(edited_menu.option1, 'test michael jordan')
        self.assertEqual(edited_menu.option2, 'test kobe bryant')
        self.assertEqual(response.status_code, 302)
예제 #5
0
    def test_create_menu_post_invalid_data(self):
        self.data = {
            'menu_date': '03/03/2020',
            'option1': 'test michael jordan',
            'option2': 'test kobe bryant',
        }
        request = self.factory.post(self.url, self.data)
        parsed_request = set_base_request(request, self.user)
        response = CreateEmployeeView.as_view()(parsed_request)

        self.assertEqual(response.status_code, 200)
예제 #6
0
    def test_create_menu_post(self):
        request = self.factory.post(self.url, self.data)
        parsed_request = set_base_request(request, self.user)
        response = CreateEmployeeView.as_view()(parsed_request)
        user = User.objects.get(username='******')
        employee_created = Employee.objects.get(user=user)

        self.assertEqual(user.username, 'nora')
        self.assertEqual(employee_created.slack_id, 'UA3K1MQQK')
        self.assertEqual(employee_created.country, 'Chile')
        self.assertEqual(response.status_code, 302)
예제 #7
0
    def test_select_menu_post(self):
        today = datetime.now(tz)
        ALLOW_VIEW_SELECTION.remove('angie')
        Menu.objects.create(
            menu_date=today,
            option1='test',
        )

        request = self.factory.post(self.url, self.data)
        parsed_request = set_base_request(request, self.user)
        response = select_menu(parsed_request)
        menu_selected = MenuEmployee.objects.get(menu_date=today)

        self.assertEqual(menu_selected.option_selected, 'test')
        self.assertEqual(response.status_code, 302)
예제 #8
0
    def test_create_employee_menu_get(self):
        request = self.factory.get(self.url)
        parsed_request = set_base_request(request, self.user)
        response = CreateEmployeeView.as_view()(parsed_request)

        self.assertEqual(response.status_code, 200)
예제 #9
0
    def test_edit_menu_get(self):
        request = self.factory.get(self.url)
        parsed_request = set_base_request(request, self.user)
        response = EditMenuView.as_view()(parsed_request, self.menu.pk)

        self.assertEqual(response.status_code, 200)
예제 #10
0
    def test_select_menu_get(self):
        request = self.factory.get(self.url)
        parsed_request = set_base_request(request, self.user)
        response = select_menu(parsed_request)

        self.assertEqual(response.status_code, 200)