Esempio n. 1
0
def test_macro_sources_empty_macro_list(mock_requests):
    """When KumaScript can't return macros, the sources are empty."""
    macros_url = urljoin(KUMASCRIPT_BASE_URL, 'macros/')
    response = {'can_list_macros': False, 'loader': 'HTTPLoader', 'macros': []}
    mock_requests.get(macros_url, json=response)
    macros = kumascript.macro_sources()
    assert macros == {}
Esempio n. 2
0
def test_macro_sources(mock_requests):
    """When KumaScript returns macros, the sources are populated."""
    macros_url = urljoin(KUMASCRIPT_BASE_URL, 'macros/')
    response = {
        'can_list_macros':
        True,
        'loader':
        'FileLoader',
        'macros': [
            {
                'filename': 'A11yRoleQuicklinks.ejs',
                'name': 'A11yRoleQuicklinks'
            },
            {
                'filename': 'APIFeatureList.ejs',
                'name': 'APIFeatureList'
            },
            {
                # Normal form D, common on OSX
                'filename': u'traduccio\u0301n.ejs',
                'name': u'traduccio\u0301n'
            }
        ]
    }
    mock_requests.get(macros_url, json=response)
    macros = kumascript.macro_sources()
    expected = {
        'A11yRoleQuicklinks': 'A11yRoleQuicklinks.ejs',
        'APIFeatureList': 'APIFeatureList.ejs',
        # Normal form C, used on GitHub, ElasticSearch
        u'traducci\xf3n': u'traducci\xf3n.ejs',
    }
    assert macros == expected
Esempio n. 3
0
def test_macro_sources_empty_macro_list(mock_requests):
    """When KumaScript can't return macros, the sources are empty."""
    macros_url = urljoin(KUMASCRIPT_BASE_URL, 'macros/')
    response = {
        'can_list_macros': False,
        'loader': 'HTTPLoader',
        'macros': []
    }
    mock_requests.get(macros_url, json=response)
    macros = kumascript.macro_sources()
    assert macros == {}
Esempio n. 4
0
def test_macro_sources(mock_requests):
    """When KumaScript returns macros, the sources are populated."""
    macros_url = urljoin(KUMASCRIPT_BASE_URL, 'macros/')
    response = {
        'can_list_macros': True,
        'loader': 'FileLoader',
        'macros': [{
            'filename': 'A11yRoleQuicklinks.ejs', 'name': 'A11yRoleQuicklinks'
        }, {
            'filename': 'APIFeatureList.ejs', 'name': 'APIFeatureList'
        }, {
            # Normal form D, common on OSX
            'filename': u'traduccio\u0301n.ejs', 'name': u'traduccio\u0301n'
        }]
    }
    mock_requests.get(macros_url, json=response)
    macros = kumascript.macro_sources()
    expected = {
        'A11yRoleQuicklinks': 'A11yRoleQuicklinks.ejs',
        'APIFeatureList': 'APIFeatureList.ejs',
        # Normal form C, used on GitHub, ElasticSearch
        u'traducci\xf3n': u'traducci\xf3n.ejs',
    }
    assert macros == expected
Esempio n. 5
0
def test_macro_sources_error(mock_requests):
    """When KumaScript raises an error, the sources are empty."""
    macros_url = urljoin(KUMASCRIPT_BASE_URL, 'macros/')
    mock_requests.get(macros_url, status_code=404, text='Cannot GET /macros')
    macros = kumascript.macro_sources()
    assert macros == {}
Esempio n. 6
0
def test_macro_sources_error(mock_requests):
    """When KumaScript raises an error, the sources are empty."""
    macros_url = urljoin(KUMASCRIPT_BASE_URL, 'macros/')
    mock_requests.get(macros_url, status_code=404, text='Cannot GET /macros')
    macros = kumascript.macro_sources()
    assert macros == {}