예제 #1
0
def test_studio_submit_json_handler_another_valid_input():
    player = OoyalaPlayerBlock(None, None, None)
    request_data = {
        "xml_config":
        ('<ooyala-player>'
         '    <overlay start="300" end="350">Overlayed content</overlay>'
         '</ooyala-player>'),
        "display_name":
        "The video we want to show you",
        "content_id":
        "6es2cT26W-vUkKHR17xZ3Wb6WSpyJQnP",
        "transcript_file_id":
        "the_transcript_profile",
        "enable_player_token":
        "the_player_token",
        "partner_code":
        "the_partner_code",
        "api_key":
        "the_api_key",
        "api_secret_key":
        "the_secret_key",
        "api_key_3play":
        "the_api_key_3play",
        "expiration_time":
        "10000",
        "width":
        "320px",
        "height":
        "280px",
    }
    result = player.studio_submit(_MockRequest(request_data))
    _assert_studio_submit(result, {"result": "success"})
    for key in request_data:
        assert_equal(getattr(player, key), request_data[key])
def test_studio_submit_json_handler_another_valid_input():
    player = OoyalaPlayerBlock(runtime, None, None)
    request_data = {
        "xml_config": (
            '<ooyala-player>'
            '    <overlay start="300" end="350">Overlayed content</overlay>'
            '</ooyala-player>'),
        "display_name": "The video we want to show you",
        "content_id": "6es2cT26W-vUkKHR17xZ3Wb6WSpyJQnP",
        "transcript_file_id": "the_transcript_profile",
        "enable_player_token": "the_player_token",
        "partner_code": "the_partner_code",
        "api_key": "the_api_key",
        "api_secret_key": "the_secret_key",
        "api_key_3play": "the_api_key_3play",
        "expiration_time": "10000",
        "width": "320px",
        "height": "280px",
        "cc_disable": True,
    }
    result = player.studio_submit(_MockRequest(request_data))
    _assert_json_result(result, {"result": "success"})
    assert_equal(player.disable_cc_and_translations, request_data.pop("cc_disable"))
    for key in request_data:
        assert_equal(getattr(player, key), request_data[key])
def test_enabled_player_token_is_not_empty():
    field_data = DictFieldData({
        "enable_player_token": True,
        "expiration_time": 1234
    })
    player = OoyalaPlayerBlock(runtime, field_data, None)
    token_data = player.player_token()
    assert_not_equal(token_data['player_token'], '')
    assert_equal(token_data['player_token_expires'], 10**10 + 1234)
예제 #4
0
def test_studio_submit_json_handler_invalid_xml_config():
    player = OoyalaPlayerBlock(None, None, None)
    request = _MockRequest({
        "xml_config": "this is clearly invalid xml"
    })
    result = player.studio_submit(request)
    _assert_studio_submit(result, {
        "result": "error",
        "message": _NotEmpty()
    })
def test_student_view_data_disable_player_token():
    """
    Test the student_view_data() results when enable_player_token=False.
    """
    field_data_dict = dict(
        partner_code='PARTNER-CODE',
        content_id='CONTENT-ID',
    )
    expected_data = dict(player_token="",
                         player_token_expires=None,
                         **field_data_dict)
    field_data = DictFieldData(
        dict(enable_player_token=False, **field_data_dict))
    player = OoyalaPlayerBlock(runtime, field_data, None)
    student_view_data = player.student_view_data()
    assert_equal(student_view_data, expected_data)
def test_student_view_data_disable_player_token():
    """
    Test the student_view_data() results when enable_player_token=False.
    """
    field_data_dict = dict(
        partner_code='PARTNER-CODE',
        content_id='CONTENT-ID',
    )
    expected_data = dict(
        player_token="",
        player_token_expires=None,
        **field_data_dict
    )
    field_data = DictFieldData(dict(enable_player_token=False, **field_data_dict))
    player = OoyalaPlayerBlock(runtime, field_data, None)
    student_view_data = player.student_view_data()
    assert_equal(student_view_data, expected_data)
def test_student_view_data_enable_player_token(mock_generate_player_token):
    """
    Test the student_view_data() results when enable_player_token=True.
    """
    field_data_dict = dict(
        partner_code='PARTNER-CODE',
        content_id='CONTENT-ID',
    )
    expected_data = dict(player_token="http://player_token.url",
                         player_token_expires=12345,
                         **field_data_dict)
    field_data = DictFieldData(
        dict(enable_player_token=True, **field_data_dict))
    player = OoyalaPlayerBlock(runtime, field_data, None)
    student_view_data = player.student_view_data()
    mock_generate_player_token.assert_called_once()
    assert_equal(student_view_data, expected_data)
예제 #8
0
def test_studio_submit_json_handler_valid_input():
    player = OoyalaPlayerBlock(None, None, None)
    request_data = {
        "xml_config": "<tag>this is a valid xml</tag>",
        "display_name": "exampleDisplayName",
        "content_id": "exampleContentID",
        "transcript_file_id": "exampleTranscriptFileID",
        "transcript_project_id": "exampleTranscriptProjectID",
        "enable_player_token": "examplePlayerToken",
        "partner_code": "examplePartnerCode",
        "api_key": "exampleApiKey",
        "api_secret_key": "exampleSecretKey",
        "expiration_time": "exampleExpirationTime"
    }
    result = player.studio_submit(_MockRequest(request_data))
    _assert_studio_submit(result, {"result": "success"})
    for key in request_data:
        assert_equal(getattr(player, key), request_data[key])
def test_student_view_data_enable_player_token(mock_generate_player_token):
    """
    Test the student_view_data() results when enable_player_token=True.
    """
    field_data_dict = dict(
        partner_code='PARTNER-CODE',
        content_id='CONTENT-ID',
    )
    expected_data = dict(
        player_token="http://player_token.url",
        player_token_expires=12345,
        **field_data_dict
    )
    field_data = DictFieldData(dict(enable_player_token=True, **field_data_dict))
    player = OoyalaPlayerBlock(runtime, field_data, None)
    student_view_data = player.student_view_data()
    mock_generate_player_token.assert_called_once()
    assert_equal(student_view_data, expected_data)
예제 #10
0
def test_studio_submit_json_handler_valid_input():
    player = OoyalaPlayerBlock(None, None, None)
    request_data = {
        "xml_config": "<tag>this is a valid xml</tag>",
        "display_name": "exampleDisplayName",
        "content_id": "exampleContentID",
        "transcript_file_id": "exampleTranscriptFileID",
        "transcript_project_id": "exampleTranscriptProjectID",
        "enable_player_token": "examplePlayerToken",
        "partner_code": "examplePartnerCode",
        "api_key": "exampleApiKey",
        "api_secret_key": "exampleSecretKey",
        "expiration_time": "exampleExpirationTime"
    }
    result = player.studio_submit(_MockRequest(request_data))
    _assert_studio_submit(result, {"result": "success"})
    for key in request_data:
        assert_equal(getattr(player, key), request_data[key])
 def setUp(self):
     field_data = KvsFieldData(DictKeyValueStore())
     runtime = TestRuntime(services={
         'settings':
         MockService(OoyalaPlayerBlock, self.XBLOCK_SETTINGS)
     })
     self.player = OoyalaPlayerBlock(runtime,
                                     field_data,
                                     scope_ids=Mock(spec=ScopeIds))
     self.player.DEFAULT_ATTRIBUTE_SETTINGS = {
         self.REAL_ATTRIBUTE: self.DEFAULT_SETTING_NAME
     }
def test_studio_submit_json_handler_valid_input():
    player = OoyalaPlayerBlock(runtime, None, None)
    request_data = {
        "xml_config": "<tag>this is a valid xml</tag>",
        "display_name": "exampleDisplayName",
        "content_id": "exampleContentID",
        "transcript_file_id": "exampleTranscriptFileID",
        "enable_player_token": "examplePlayerToken",
        "partner_code": "examplePartnerCode",
        "api_key": "exampleApiKey",
        "api_secret_key": "exampleSecretKey",
        "api_key_3play": "example3playApiKey",
        "expiration_time": "exampleExpirationTime",
        "width": "640px",
        "height": "480px",
        "cc_disable": False,
    }
    result = player.studio_submit(_MockRequest(request_data))
    _assert_json_result(result, {"result": "success"})
    assert_equal(player.disable_cc_and_translations, request_data.pop("cc_disable"))
    for key in request_data:
        assert_equal(getattr(player, key), request_data[key])
def test_studio_submit_json_handler_valid_input():
    player = OoyalaPlayerBlock(runtime, None, None)
    request_data = {
        "xml_config": "<tag>this is a valid xml</tag>",
        "display_name": "exampleDisplayName",
        "content_id": "exampleContentID",
        "transcript_file_id": "exampleTranscriptFileID",
        "enable_player_token": "examplePlayerToken",
        "partner_code": "examplePartnerCode",
        "api_key": "exampleApiKey",
        "api_secret_key": "exampleSecretKey",
        "api_key_3play": "example3playApiKey",
        "expiration_time": "exampleExpirationTime",
        "width": "640px",
        "height": "480px",
        "cc_disable": False,
    }
    result = player.studio_submit(_MockRequest(request_data))
    _assert_json_result(result, {"result": "success"})
    assert_equal(player.disable_cc_and_translations,
                 request_data.pop("cc_disable"))
    for key in request_data:
        assert_equal(getattr(player, key), request_data[key])
예제 #14
0
def test_parse_overlays():
    player = OoyalaPlayerBlock(None, None, None)
    player.parent = "the_parent"
    player.content_id = "the_parent"
    player.xml_config = (
        '<ooyala-player>'
        '    <overlays>'
        '        <overlay/>'
        '        <overlay start="123" end="320" />'
        '        <overlay start="134" end="160">The overlayed text</overlay>'
        '    </overlays>'
        '</ooyala-player>')
    assert_equal(player.overlays, [
        _MockOverlay(0, 0, None, "ooyala-" + player._get_unique_id()),
        _MockOverlay(123, 320, None, "ooyala-" + player._get_unique_id()),
        _MockOverlay(134, 160, "The overlayed text",
                     "ooyala-" + player._get_unique_id()),
    ])
예제 #15
0
def test_parse_overlays():
    player = OoyalaPlayerBlock(None, None, None)
    player.parent = "the_parent"
    player.content_id = "the_parent"
    player.xml_config = (
        '<ooyala-player>'
        '    <overlays>'
        '        <overlay/>'
        '        <overlay start="123" end="320" />'
        '        <overlay start="134" end="160">The overlayed text</overlay>'
        '    </overlays>'
        '</ooyala-player>')
    assert_equal(player.overlays, [
        _MockOverlay(0, 0, None, "ooyala-" + player._get_unique_id()),
        _MockOverlay(123, 320, None, "ooyala-" + player._get_unique_id()),
        _MockOverlay(134, 160, "The overlayed text", "ooyala-" + player._get_unique_id()),
    ])
def test_enabled_player_token_is_not_empty():
    field_data = DictFieldData({"enable_player_token": True, "expiration_time": 1234})
    player = OoyalaPlayerBlock(runtime, field_data, None)
    token_data = player.player_token()
    assert_not_equal(token_data['player_token'], '')
    assert_equal(token_data['player_token_expires'], 10**10 + 1234)
def test_disabled_player_token_is_empty():
    field_data = DictFieldData({"enable_player_token": False})
    player = OoyalaPlayerBlock(runtime, field_data, None)
    token_data = player.player_token()
    assert_equal(token_data['player_token'], '')
    assert_equal(token_data['player_token_expires'], None)
예제 #18
0
def test_studio_submit_json_handler_invalid_xml_config():
    player = OoyalaPlayerBlock(None, None, None)
    request = _MockRequest({"xml_config": "this is clearly invalid xml"})
    result = player.studio_submit(request)
    _assert_studio_submit(result, {"result": "error", "message": _NotEmpty()})
예제 #19
0
def test_enabled_player_token_is_not_empty():
    field_data = DictFieldData({"enable_player_token": True})
    player = OoyalaPlayerBlock(None, field_data, None)
    assert_not_equal(player.player_token, '')
예제 #20
0
def test_player_token_is_disabled_by_default():
    field_data = DictFieldData({})
    player = OoyalaPlayerBlock(None, field_data, None)
    assert_false(player.enable_player_token)
def test_disabled_player_token_is_empty():
    field_data = DictFieldData({"enable_player_token": False})
    player = OoyalaPlayerBlock(runtime, field_data, None)
    token_data = player.player_token()
    assert_equal(token_data['player_token'], '')
    assert_equal(token_data['player_token_expires'], None)