Example #1
0
    def test_no_permission_to_add_user_to_board(self):
        board = model_factories.Board()
        req_user = model_factories.User(email="*****@*****.**")
        user = model_factories.User()
        request = self.create_request(
            {
                "user_id": user.id,
                "board_id": board.id,
                "role": "editor"
            }, req_user)
        response = add_user_to_board(request)

        self.assertEqual(
            response.status_code,
            403,
            "User lacking permissions to add user to board did not recieve error",
        )
Example #2
0
    def test_remove_user_from_board_success(self):
        board = model_factories.Board()
        owner = model_factories.User(email="*****@*****.**")
        reader = model_factories.User(email="*****@*****.**")
        model_factories.BoardUser(user=owner, board=board, role="owner")
        model_factories.BoardUser(user=reader, board=board, role="reader")
        request = self.create_request(
            {
                "board_id": board.id,
                "user_id": reader.id
            }, user=owner)
        response = remove_user_from_board(request)

        self.assertEqual(response.status_code, 200,
                         "Error: {}".format(response.content))
        resp_data = json.loads(response.content.decode("utf8"))
        self.assertEqual(resp_data["response"]["board_user"]["user_id"],
                         reader.id)
Example #3
0
    def test_add_user_to_board(self):
        board = model_factories.Board()
        owner = model_factories.User(email="*****@*****.**")
        model_factories.BoardUser(user=owner, board=board, role="owner")
        user = model_factories.User(email="*****@*****.**")
        request = self.create_request(
            {
                "user_id": user.id,
                "board_id": board.id,
                "role": "editor"
            },
            user=owner)
        response = add_user_to_board(request)

        self.assertEqual(response.status_code, 200,
                         "Error: {}".format(response.content))
        response_data = json.loads(response.content.decode("utf8"))
        self.assertEqual(response_data["response"]["board"]["name"],
                         board.name)
Example #4
0
    def test_get_note_permission_denied(self):
        board = model_factories.Board()
        user = model_factories.User(email="*****@*****.**")
        note = model_factories.Note(board_id=board.id)

        request = self.create_request(note.id, user=user)
        response = get_note(request, note.id)

        self.assertEqual(response.status_code, 403,
                         "Error: {}".format(response.content))
Example #5
0
    def test_delete_board_success(self):
        board = model_factories.Board()
        owner = model_factories.User(email="*****@*****.**")
        model_factories.BoardUser(user=owner, board=board, role="owner")
        request = self.create_request({"id": board.id}, user=owner)
        response = delete_board(request)

        self.assertEqual(response.status_code, 200,
                         "Error: {}".format(response.content))
        response_data = json.loads(response.content.decode("utf8"))
        self.assertEqual(response_data["response"]["board"]["status"],
                         "deleted")
Example #6
0
    def test_get_note_success(self):
        board = model_factories.Board()
        user = model_factories.User(email="*****@*****.**")
        model_factories.BoardUser(user=user, board=board, role="reader")
        note = model_factories.Note(board_id=board.id)

        request = self.create_request(note.id, user=user)
        response = get_note(request, note.id)
        response_data = json.loads(response.content.decode("utf8"))

        self.assertEqual(response.status_code, 200,
                         "Error: {}".format(response.content))
        self.assertEqual(response_data["response"]["note"]["id"], note.id)
Example #7
0
    def test_edit_note(self):
        board = model_factories.Board()
        user = model_factories.User(email="*****@*****.**")
        model_factories.BoardUser(user=user, board=board, role="editor")
        note = model_factories.Note(title="original title", board_id=board.id)

        data = {"id": note.id, "title": "new title"}
        request = self.create_request(data, user)
        response = edit_note(request)
        response_data = json.loads(response.content.decode("utf8"))

        self.assertEqual(response.status_code, 200,
                         "Error: {}".format(response.content))
        self.assertEqual(response_data["response"]["note"]["title"],
                         data["title"])
Example #8
0
 def setUp(self):
     self.req_factory = RequestFactory()
     self.user = model_factories.User()