Exemplo n.º 1
0
def test_total():
    e = EXPECTED_ACTIVITY
    e.update(EXPECTED_TITLE)
    e.update(EXPECTED_FACTS)
    e.update(EXPECTED_TEXT)
    e.update(EXPECTED_HERO)

    section = CardSection()
    section = CardSection(title=e["title"])
    section.set_activity(
        title=e["activityTitle"],
        subtitle=e["activitySubtitle"],
        image_url=e["activityImage"],
    )
    for fact in e["facts"]:
        section.add_fact(fact["name"], fact["value"])

    section.set_text(e["text"])
    section.set_hero_image({e["heroImage"]["title"]: e["heroImage"]["image"]})

    section.json_payload == json.dumps(e)
Exemplo n.º 2
0
def test_hero_image():
    e = EXPECTED_HERO
    image = ImageObject(image=e["heroImage"]["image"], title=e["heroImage"]["title"])

    section = CardSection()
    section.set_hero_image(image)
    assert section.json_payload == json.dumps(e)

    section = CardSection()
    section.set_hero_image({e["heroImage"]["title"]: e["heroImage"]["image"]})
    assert section.json_payload == json.dumps(e)

    section = CardSection()
    section.set_hero_image(e["heroImage"]["image"])
    section["hero_image"].set_title(e["heroImage"]["title"])
    assert section.json_payload == json.dumps(e)

    section = CardSection(hero_image={e["heroImage"]["title"]: e["heroImage"]["image"]})
    assert section.json_payload == json.dumps(e)