async def onload(event): logging.info("LOADED") app.register('click', buttonclicked, selector='#primary', client=event['client']) app.register('click', buttonclicked, selector='#secondary', client=event['client']) app.register('click', buttonclicked, selector='#secondary', client=event['client']) await asyncio.sleep(5) text = await app.gettext('#primary', event['client']) attr = await app.getattribute('#primary', 'class', event['client']) prop = await app.getproperty('#primary', 'type', event['client']) logging.info(f"TEXT {text}, ATTR {attr}, PROP {prop}") for i in range(1, 5): app.style("#fiddle", 'font-size', str(i*2) + "em", 'important', event['client']) await asyncio.sleep(1) await asyncio.sleep(5) img = Image() img.datauri(os.path.join(os.path.dirname(__file__), 'test', 'test.png')) app.replace("#fiddle", str(img), event['client']) msg = 'SWEET!!!' for i in range(8): app.set_text("h2", msg[:i], event['client']) await asyncio.sleep(1)
def test_data_uri(): img = Image() img.datauri(os.path.join(os.path.dirname(__file__), "test.png")) src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALUAAAAgCAIAAADbmq4OAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAadSURBVHhe7VtPb+JGFO/34Au0n4BPwCfY3Di1N06N1ENu6SnH3sKlufkUeiHisGmkLIoUlUMlJKqlQgrKdvm3hJggTDA2GHB/b56xnbFhiZrd7Dbz9DuMn9+MZ/x+894bJ3zjKlGyXhQ/lGySgB+n78yd/M13R81E9r3CiwU48Efb8jjh8wPkkOwUXjJ8inj8eJXvShYKLxngAxPD44d0W+GFA2UGE0PxQyEeTAzFD4V4MDEUPxTiwcTYlh/rzr2p3IdfKwbK3f3LO1/j31X4esHE2JYff+uzqONxVubuLM2R0xrNYRYh033dMwmkXgsbhHBpDd1ZLtx4Ehz3c+3Z0PGe7jqLesPIaCED7TZTCF1+IXi+WfF72pYfsBnaCxAirCx1bO7uCyhy9NcobCNA/FhLCAmfgB/JC7PpuJZh50o3KdJ00qVxHXO3p5r39o2ys/UMPx+ec1bs0G35gcDAlkgl37/usZI1Yfn93cTvEsKz8kM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89fiPWjA0ccgbqA+KQX9aEccYVwPsDvFCwR2tlKpSnLd1AkdhzVkNljSqKXCpEZH4ktFHVWQzDkUnkES4gkmdGmTKUntAovFPVUkChg6Ee1B+JApbgeqVubHd6KBLTOKNxeSFKMXlWssEeoohtH6CqOGav0x7IXM+hPMyjV2f3ClWzfQBSxim95ayB8Opj+MFAFOEuYUFm2fiPRWv4gVK/Ym1zfokxI5BLvKxBPOA6UQLSkOCNdlcURxLLmGjYwRDHKVX8MNvN4azLRavEj2xL03GSebDjQwcQVD+jdLZFmYX4R3fTcMDq/LJ3jbMMyVCH2bruvNh5tcvbz1+jNKuIQWFUXY3TbI+KKJBRymi3OKp4/75hO0WwE5axyo1g2634garzVb7747ke/s8iX1C6biTHM4ODsCjy5VuJ4wFveln/EMhHQe3yiSCTMoKPGjw12Lnbxo/dN30ECTZmwYkXzJC+qH6RwCZ2LOxU3Ty84O+nSMO9g5rddNxe1/C3dTwocUTK3ifH184PHyDE18AJGanzUXEwD/7+4i6H5vTk4mOHPfKK24t+e31y/G/4ofBCwMRQ/FCIBxND8UMhHkwMxQ+FGHx71GBiePxQv29QCEP+fYP6fZRCGPLvoyCgCFiDwCKZKrwogAPhr6ABP5QoiYrih5L14rr/AtKZuwF2olfXAAAAAElFTkSuQmCC' assert(str(img) == "<img src=\"" + src + "\">")
def test_data_uri(): img = Image() img.datauri(os.path.join(os.path.dirname(__file__), "test.png")) src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALUAAAAgCAIAAADbmq4OAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAadSURBVHhe7VtPb+JGFO/34Au0n4BPwCfY3Di1N06N1ENu6SnH3sKlufkUeiHisGmkLIoUlUMlJKqlQgrKdvm3hJggTDA2GHB/b56xnbFhiZrd7Dbz9DuMn9+MZ/x+894bJ3zjKlGyXhQ/lGySgB+n78yd/M13R81E9r3CiwU48Efb8jjh8wPkkOwUXjJ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kC7cCFAbxBYMY8EEoijXgE5SO3WkFD8gTfBVq5AfQiqq2SC01AktX0jpC23PnpKsFJMw+UkoRX7dtQx3Wz8g1aO5f3JX1WNxbgJUQYd/aupj3OTc68/JaPFLHKTRCmW/MDQG2xOcX88HrlABnx/PhP8UMUFs3GpOlOj8gxbrNtcURhMw/eIH3KI16N4lUk2NY7FHXtQwoPaz2RhM3gHv7wI1NsVABEEln2TNS84w3xI7479X10/EhWphZFhXGu3M8Uhl784AExn7yudeEvej+blbFgnz6CH6ncB/8UE5U1JxdGPD+ihQXlVN89fiPWjA0ccgbqA+KQX9aEccYVwPsDvFCwR2tlKpSnLd1AkdhzVkNljSqKXCpEZH4ktFHVWQzDkUnkES4gkmdGmTKUntAovFPVUkChg6Ee1B+JApbgeqVubHd6KBLTOKNxeSFKMXlWssEeoohtH6CqOGav0x7IXM+hPMyjV2f3ClWzfQBSxim95ayB8Opj+MFAFOEuYUFm2fiPRWv4gVK/Ym1zfokxI5BLvKxBPOA6UQLSkOCNdlcURxLLmGjYwRDHKVX8MNvN4azLRavEj2xL03GSebDjQwcQVD+jdLZFmYX4R3fTcMDq/LJ3jbMMyVCH2bruvNh5tcvbz1+jNKuIQWFUXY3TbI+KKJBRymi3OKp4/75hO0WwE5axyo1g2634garzVb7747ke/s8iX1C6biTHM4ODsCjy5VuJ4wFveln/EMhHQe3yiSCTMoKPGjw12Lnbxo/dN30ECTZmwYkXzJC+qH6RwCZ2LOxU3Ty84O+nSMO9g5rddNxe1/C3dTwocUTK3ifH184PHyDE18AJGanzUXEwD/7+4i6H5vTk4mOHPfKK24t+e31y/G/4ofBCwMRQ/FCIBxND8UMhHkwMxQ+FGHx71GBiePxQv29QCEP+fYP6fZRCGPLvoyCgCFiDwCKZKrwogAPhr6ABP5QoiYrih5L14rr/AtKZuwF2olfXAAAAAElFTkSuQmCC' assert (str(img) == "<img src=\"" + src + "\">")
async def onload(event): logging.info("LOADED") app.register('click', buttonclicked, selector='#primary', client=event['client']) app.register('click', buttonclicked, selector='#secondary', client=event['client']) app.register('click', buttonclicked, selector='#secondary', client=event['client']) await asyncio.sleep(5) for i in range(1, 5): app.style("#fiddle", 'font-size', str(i*2) + "em", 'important', event['client']) await asyncio.sleep(1) await asyncio.sleep(5) img = Image() img.datauri(os.path.join(os.path.dirname(__file__), 'test', 'test.png')) app.replace("#fiddle", str(img), event['client']) msg = 'SWEET!!!' for i in range(8): app.text("h2", msg[:i], event['client']) await asyncio.sleep(1)
def test_custom_class_ident_style_and_attrs(): assert ( str( Image("default.png", ident='123', cl="testing", style="font-size:0.9em;", attrs={"data-test": 'abc'})) == "<img src=\"default.png\" id=\"123\" class=\"testing\" style=\"font-size:0.9em;\" data-test=\"abc\">" )
def test_width_height(): assert (str(Image("default.png", width="100", height="300")) == "<img src=\"default.png\" width=\"100\" height=\"300\">")
def test_basic(): assert (str(Image("default.png")) == "<img src=\"default.png\">")
def test_responsive_image(): assert (str(Image("default.png", responsive=True)) == "<img src=\"default.png\" class=\"img-responsive\">")
def test_thumbnail_variety(): assert (str(Image("default.png", variety="thumbnail")) == "<img src=\"default.png\" class=\"img-thumbnail\">")
def test_rounded_variety(): assert (str(Image("default.png", variety="rounded")) == "<img src=\"default.png\" class=\"img-rounded\">")
def test_circle_variety(): assert (str(Image( "default.png", variety="circle")) == "<img src=\"default.png\" class=\"img-circle\">")