def test_personal_details_are_validated_on_dump(self): rezume = Rezume() rezume.name = "John" rezume.email = "john" with pytest.raises(ValidationError): rezume.dump_data()
def test_rezume_is_validate_before_dump(self, sample_rezume): rezume = Rezume().load_data(sample_rezume) section = rezume["education"] assert section is not None assert len(section) > 0 entry = list(section)[0] section.discard(entry) assert len(section) == 0 # a valid rezume is expected to have at least one entry in the # education section in addition to all required basics details with pytest.raises(RezumeError): rezume.dump_data()
def render(rezume: Rezume): """Renders the provide Rezume using template/rezume.mst template file. """ base_dir = Path(__file__).absolute().parent template = base_dir / "template" / "rezume.mst" assert template is not None with template.open("r") as tf: data = rezume.dump_data() html = chevron.render(tf, {"rezume": data}) return html
def render(rezume: Rezume): """Renders the provide Rezume using template/rezume.hbs template file. """ assets_dir = Path(__file__).absolute().parent / "assets" template_file = assets_dir / "rezume.hbs" style = assets_dir / "style.css" assert template_file is not None with template_file.open("r") as tf, style.open("r") as sf: data = rezume.dump_data() css = "".join(sf.readlines()) hbs = "".join(tf.readlines()) template = Compiler().compile(hbs) html = template({"resume": data, "css": css}) return html
def render(rezume: Rezume): """Returns a JSON string as the rendered representation of provided rezume.""" data = rezume.dump_data() return json.dumps(data)