Ejemplo n.º 1
0
    def test_trainer_gets_404_when_trying_to_login_to_non_trainer_in_different_gym(self, _):
        request_user = _build_mock_user('trainer-gym', is_trainer=True)
        request = _build_mock_request(request_user)
        user_from_db_lookup = _build_mock_user('user-gym', is_trainer=False)

        with mock.patch('wger.core.views.user.get_object_or_404', return_value=user_from_db_lookup):
            resp = trainer_login(request, 'primary-key-not-needed-because-of-mock')

        self.assertEqual(404, resp.status_code)
Ejemplo n.º 2
0
    def test_trainer_is_denied_from_login_to_trainer_in_same_gym(self, _):
        request_user = _build_mock_user('same-gym', is_trainer=True)
        request = _build_mock_request(request_user)
        user_from_db_lookup = _build_mock_user('same-gym', is_trainer=True)

        with mock.patch('wger.core.views.user.get_object_or_404', return_value=user_from_db_lookup):
            resp = trainer_login(request, 'primary-key-not-needed-because-of-mock')

        self.assertEqual(403, resp.status_code)