Exemplo n.º 1
0
 def test_user_hide_private_boards(self):
     board = factories.BoardFactory(creator=self.user,
                                    permissions=AuthLevels.collaborators)
     response = self.client.get(
         reverse("openach:user_boards", args=(self.user.id, )) +
         "?query=created")
     self.assertNotContains(response, board.board_title, status_code=200)
Exemplo n.º 2
0
 def test_user_public_board_view(self):
     """Test board listing for user that created a public board."""
     board = factories.BoardFactory(creator=self.user)
     board.permissions.make_public()
     response = self.client.get(
         reverse("openach:user_boards", args=(self.user.id,)) + "?query=created"
     )
     self.assertContains(response, board.board_title, status_code=200)
Exemplo n.º 3
0
    def test_team_collaborator_can_see_board(self):
        team = factories.TeamFactory(owner=self.user, members=[self.other])
        board = factories.BoardFactory(creator=self.user,
                                       permissions=AuthLevels.collaborators,
                                       teams=[team])

        response = self.client.get(reverse("openach:boards"))
        self.assertNotContains(response, board.board_title)

        self.login_other()
        response = self.client.get(reverse("openach:boards"))
        self.assertContains(response, board.board_title)
Exemplo n.º 4
0
    def test_can_edit_board_permissions(self):
        """Test that the board owner can edit the board permissions via form."""
        board = factories.BoardFactory(creator=self.user)
        self.login()
        response = self.client.post(
            reverse("openach:edit_permissions", args=(board.id,)),
            data={
                **{
                    p: AuthLevels.registered.key
                    for p in BoardPermissions.PERMISSION_NAMES
                },
                "collaborators": [],
            },
        )
        self.assertEqual(response.status_code, 302)

        board.permissions.refresh_from_db()

        for p in BoardPermissions.PERMISSION_NAMES:
            self.assertEqual(
                getattr(board.permissions, p),
                AuthLevels.registered.key,
                f"failed for: {p}",
            )