def test_create_header(): author = {'firstname': 'Miles', 'lastname': 'Davis'} author2 = {'firstname': 'John', 'lastname': 'Mike'} aut = [author, author2] header_test = header.create_header(aut) assert "Miles" in header_test
def create_markdown(self): with open(self.json_path, 'r') as in_file: reloaded = json.load(in_file) sortie = header.create_header(reloaded) + f"\n![alt text]({self.png_path})" with open(self.md_path, "w", encoding='utf-8') as out_file: out_file.write(sortie)
def test_create_header_incomplete(): auth_list = [ {"first": "Jojo",}, {"last": "Dudu",}, ] res = create_header(auth_list, "NY") assert "Dudu" in res assert "Jojo" in res
def test_create_header_withloc(): auth_list = [ {"first": "Jojo", "last": "Juju",}, {"first": "Dodo", "last": "Dudu",}, ] res = create_header(auth_list, "NY") assert "NY" in res
def test_create_header(): author1 = {'firstname': 'Miles', 'lastname': 'Davis', 'DOB': 1926} author2 = {'firstname': 'John', 'lastname': 'Coltrane', 'DOB': 1933} author3 = {'firstname': 'Alfred', 'lastname': 'McCoy Tyner', 'DOB': 1938} authors = [author1, author2, author3] header_txt = header.create_header(authors) assert "Alfred" in header_txt assert "McCoy" in header_txt
def test_create_header(): auth_list = [ {"first": "Jojo", "last": "Juju",}, {"first": "Dodo", "last": "Dudu",}, ] res = create_header(auth_list) if not "Jojo" in res: raise ValueError('Firstname not in string') assert "Jojo" in res
def test_create_header_incomplete(): #liste de dictionnaires pour create_header, incomplete pour test authors_list = [ {"first" : "Le premier"}, {"last":"Le second"}, {"first" : "Le premier", "last":"Le second"}, ] loc = "Londres" #On appelle la fonction dans une variable res = create_header(authors_list,loc) if not "premier" in res: # si la chaine attendue n'est pas là. Pourrait être "assert". raise ValueError('On trouve pas le premier') # on remonte volontairement une erreur avec un message assert "Londres" in res #on force le nom de "loc" et on test sa prise en compte.
def test_create_header(): auth_list = [ { "first": "Jean", "last": "Dupont" }, { "first": "Eric", "last": "Martin" }, ] res = create_header(auth_list, "NY") if not "Jean" in res: raise ValueError('Prénom manquant') assert "NY" in res
def test_create_header(): author = { 'firstname': 'Miles', 'lastname' : 'Davis' } author2 = { 'firstname': 'John', 'lastname' : 'Coltrane' } authors=[author,author2] header_texte = header.create_header(authors) assert len(header_texte)>0 assert 'Miles' in header_texte
def create_markdown(self): var_md = header.create_header(self.reloaded) + "\n\n![a graph](graph.png)\n" with open(self.md_path, 'w', encoding='utf-8') as out_file: out_file.write(var_md)