Пример #1
0
 def test_set(self):
     self.block.field_b = set([5, 6, 5])
     self.block.save()
     assert_is_instance(self.block.field_b, set)
     assert_equals(
         {'$type': 'set', '$vals': [5, 6]},
         self.block._field_data.get(self.block, 'field_b')
     )
Пример #2
0
 def test_set(self):
     self.block.field_b = set([5, 6, 5])
     self.block.save()
     assert_is_instance(self.block.field_b, set)
     assert_equals({
         '$type': 'set',
         '$vals': [5, 6]
     }, self.block._field_data.get(self.block, 'field_b'))
Пример #3
0
def test_json_handler_return_unicode():
    test_request = Mock(method="POST", body='["foo", "bar"]')

    @XBlock.json_handler
    def test_func(self, request, suffix):  # pylint: disable=unused-argument
        return Response(request=request)

    response = test_func(Mock(), test_request, "dummy_suffix")
    for request_part in response.request:  # pylint: disable=not-an-iterable
        assert_is_instance(request_part, six.text_type)
Пример #4
0
def test_dummy_user_service_current_user():
    """
    Tests that get_current_user() works on a dummy user service.
    """
    user = XBlockUser(full_name="tester")
    user_service = SingleUserService(user)
    current_user = user_service.get_current_user()
    assert_equals(current_user, user)
    assert_equals(current_user.full_name, "tester")
    # assert that emails is an Iterable but not a string
    assert_is_instance(current_user.emails, collections.Iterable)
    assert_false(isinstance(current_user.emails, (six.text_type, six.binary_type)))
    # assert that opt_attrs is a Mapping
    assert_is_instance(current_user.opt_attrs, collections.Mapping)
Пример #5
0
def test_dummy_user_service_current_user():
    """
    Tests that get_current_user() works on a dummy user service.
    """
    user = XBlockUser(full_name="tester")
    user_service = SingleUserService(user)
    current_user = user_service.get_current_user()
    assert_equals(current_user, user)
    assert_equals(current_user.full_name, "tester")
    # assert that emails is an Iterable but not a string
    assert_is_instance(current_user.emails, collections.Iterable)
    assert_false(isinstance(current_user.emails, basestring))
    # assert that opt_attrs is a Mapping
    assert_is_instance(current_user.opt_attrs, collections.Mapping)
Пример #6
0
    def test_get(self):
        # Test field with a value
        assert_is_instance(self.block.field_a, set)

        # Test ModelData default
        assert_is_instance(self.block.field_b, set)
Пример #7
0
    def test_get(self):
        # Test field with a value
        assert_is_instance(self.block.field_a, set)

        # Test ModelData default
        assert_is_instance(self.block.field_b, set)