Пример #1
0
def test_phonetic_block_generation_broken():
    schema = load_schema('hep')
    subschema = schema['properties']['authors']

    extra_config = {
        "BEARD_API_URL": "http://example.com/beard",
    }

    with mock.patch.dict(current_app.config, extra_config):
        httpretty.register_uri(
            httpretty.POST,
            "{base_url}/text/phonetic_blocks".format(
                base_url=current_app.config.get('BEARD_API_URL')),
            content_type="application/json",
            body='{"phonetic_blocks": {}}',
            status=200)

        json_dict = {
            "authors": [{
                "full_name": "** NOT VALID **"
            }]
        }

        receivers.assign_phonetic_block(json_dict)

        assert validate(json_dict['authors'], subschema) is None
        assert json_dict['authors'][0].get('signature_block') is None
Пример #2
0
def test_phonetic_block_generation_ascii():
    json_dict = {
        "authors": [{
            "full_name": "John Richard Ellis"
        }]
    }

    receivers.assign_phonetic_block(json_dict)

    assert json_dict['authors'][0]['signature_block'] == "ELj"
def test_phonetic_block_generation_unicode():
    extra_config = {
        "BEARD_API_URL": "http://example.com/beard",
    }

    with mock.patch.dict(current_app.config, extra_config):
        httpretty.register_uri(
            httpretty.POST,
            "{base_url}/text/phonetic_blocks".format(
                base_url=current_app.config.get('BEARD_API_URL')),
            content_type="application/json",
            body=u'{"phonetic_blocks": {"Grzegorz Jacenków": "JACANCg"}}',
            status=200)

        json_dict = {"authors": [{"full_name": u"Grzegorz Jacenków"}]}

        receivers.assign_phonetic_block(json_dict)

        assert json_dict['authors'][0]['signature_block'] == "JACANCg"
Пример #4
0
def test_phonetic_block_generation_broken(httppretty_mock, app):
    extra_config = {
        "BEARD_API_URL": "http://example.com/beard",
    }

    with app.app_context():
        with mock.patch.dict(app.config, extra_config):
            httpretty.register_uri(
                httpretty.POST,
                "{base_url}/text/phonetic_blocks".format(
                    base_url=app.config.get('BEARD_API_URL')),
                content_type="application/json",
                body='{"phonetic_blocks": {}}',
                status=200)

            json_dict = {"authors": [{"full_name": "** NOT VALID **"}]}

            receivers.assign_phonetic_block(json_dict)

            assert json_dict['authors'][0]['signature_block'] is None
def test_phonetic_block_generation_broken():
    extra_config = {
        "BEARD_API_URL": "http://example.com/beard",
    }

    with mock.patch.dict(current_app.config, extra_config):
        httpretty.register_uri(
            httpretty.POST,
            "{base_url}/text/phonetic_blocks".format(
                base_url=current_app.config.get('BEARD_API_URL')),
            content_type="application/json",
            body='{"phonetic_blocks": {}}',
            status=200)

        json_dict = {
            "authors": [{
                "full_name": "** NOT VALID **"
            }]
        }

        receivers.assign_phonetic_block(json_dict)

        assert json_dict['authors'][0]['signature_block'] is None
def test_phonetic_block_generation_ascii(httppretty_mock, app):
    extra_config = {
        "BEARD_API_URL": "http://example.com/beard",
    }

    with app.app_context():
        with mock.patch.dict(app.config, extra_config):
            httpretty.register_uri(
                httpretty.POST,
                "{base_url}/text/phonetic_blocks".format(
                    base_url=app.config.get('BEARD_API_URL')),
                content_type="application/json",
                body='{"phonetic_blocks": {"John Richard Ellis": "ELj"}}',
                status=200)

            json_dict = {
                "authors": [{
                    "full_name": "John Richard Ellis"
                }]
            }

            receivers.assign_phonetic_block(json_dict)

            assert json_dict['authors'][0]['signature_block'] == "ELj"