Projet

Général

Profil

0001-pwa-ship-manifest.json-template-29465.patch

Thomas Noël, 04 janvier 2019 23:42

Télécharger (2,71 ko)

Voir les différences:

Subject: [PATCH] pwa: ship manifest.json template (#29465)

 combo/apps/pwa/templates/combo/manifest.json | 23 ++++++++++++++++++++
 tests/templates-1/combo/manifest.json        |  3 ---
 tests/test_pwa.py                            |  9 +++-----
 3 files changed, 26 insertions(+), 9 deletions(-)
 create mode 100644 combo/apps/pwa/templates/combo/manifest.json
 delete mode 100644 tests/templates-1/combo/manifest.json
combo/apps/pwa/templates/combo/manifest.json
1
{% load static %}{
2
    "name": "{% firstof global_title "Compte Citoyen" %}",
3
    "short_name": "{% firstof global_title "Compte Citoyen" %}",
4
    "start_url": "{% firstof pwa_start_url "/" %}",
5
    {% if theme_color %}
6
    "background_color": "{{ theme_color }}",
7
    "theme_color": "{{ theme_color }}",
8
    {% endif %}
9
    {% block icons %}
10
    "icons": [
11
      {% for icon_size in icon_sizes %}
12
        {
13
            "sizes": "{{ icon_size }}x{{ icon_size }}",
14
            "src": "{{ site_base }}{% static "" %}{{ css_variant }}/{{ icon_prefix }}{{ icon_size }}px.png",
15
            "type": "image/png"
16
        }{% if not forloop.last %},{% endif %}
17
      {% endfor %}
18
    ],
19
    {% endblock %}
20
    {% block extra %}
21
    {% endblock %}
22
    "display": "{% firstof pwa_display "browser" %}"
23
}
tests/templates-1/combo/manifest.json
1
{
2
  "name": "test"
3
}
tests/test_pwa.py
26 26

  
27 27

  
28 28
def test_manifest_json(app):
29
    app.get('/manifest.json', status=404)
30

  
31
    templates_settings = [settings.TEMPLATES[0].copy()]
32
    templates_settings[0]['DIRS'] = ['%s/templates-1' % os.path.abspath(os.path.dirname(__file__))]
33
    with override_settings(TEMPLATES=templates_settings):
34
        assert app.get('/manifest.json', status=200).json['name'] == 'test'
29
    assert app.get('/manifest.json', status=200).json['name'] == 'Compte Citoyen'
30
    with override_settings(TEMPLATE_VARS={'global_title': 'FooBar'}):
31
        assert app.get('/manifest.json', status=200).json['name'] == 'FooBar'
35 32

  
36 33
def test_service_worker(app):
37 34
    app.get('/service-worker.js', status=200)
38
-