Esempio n. 1
0
 def test_thread(self, is_privileged, is_cohorted):
     context = _get_context(requester_id="5",
                            is_requester_privileged=is_privileged,
                            is_cohorted=is_cohorted)
     actual = get_initializable_thread_fields(context)
     expected = {
         "abuse_flagged", "course_id", "following", "raw_body", "read",
         "title", "topic_id", "type", "voted"
     }
     if is_privileged and is_cohorted:
         expected |= {"group_id"}
     self.assertEqual(actual, expected)
Esempio n. 2
0
 def test_thread(self, is_privileged, is_cohorted):
     context = _get_context(
         requester_id="5",
         is_requester_privileged=is_privileged,
         is_cohorted=is_cohorted
     )
     actual = get_initializable_thread_fields(context)
     expected = {
         "abuse_flagged", "course_id", "following", "raw_body", "read", "title", "topic_id", "type", "voted"
     }
     if is_privileged and is_cohorted:
         expected |= {"group_id"}
     self.assertEqual(actual, expected)
Esempio n. 3
0
def _check_initializable_thread_fields(data, context):  # pylint: disable=invalid-name
    """
    Checks if the given data contains a thread field that is not initializable
    by the requesting user

    Arguments:
        data (dict): The data to compare the allowed_fields against
        context (dict): The context appropriate for use with the thread which
            includes the requesting user

    Raises:
        ValidationError if the given data contains a thread field that is not
            initializable by the requesting user
    """
    _check_fields(get_initializable_thread_fields(context), data, "This field is not initializable.")
Esempio n. 4
0
def _check_initializable_thread_fields(data, context):  # pylint: disable=invalid-name
    """
    Checks if the given data contains a thread field that is not initializable
    by the requesting user

    Arguments:
        data (dict): The data to compare the allowed_fields against
        context (dict): The context appropriate for use with the thread which
            includes the requesting user

    Raises:
        ValidationError if the given data contains a thread field that is not
            initializable by the requesting user
    """
    _check_fields(get_initializable_thread_fields(context), data,
                  "This field is not initializable.")