def test_create_papers_by_year_list_3(): _references = [] for ref in [bibtex2, bibtex4, bibtex5]: _ref_str = bibtexparser.loads(ref) _references.append(Reference(_ref_str, "bibpath", "bibfile")) biblio = Bibliography(_references) papers_by_year = biblio.create_papers_by_year_list() _expected = ( "\n### 2013\n\n" '- Jean César. (2013). "[An amazing title](https://example.com)."' " Nice Journal. " "[`bibfile`](bibpath/bibfile)\n" "\n### 1968\n\n" '- Chow, C and Liu, Cong. (1968). "[Approximating Discrete Probability ' "Distributions with Dependence Trees]" '(https://ieeexplore.ieee.org/iel5/18/22639/01054142.pdf)."' " IEEE Transactions on Information Theory. [`bibfile`]" "(bibpath/bibfile)\n" '- Chow, C and Liu, Cong. (1968). "[Approximating Discrete Probability ' "Distributions with Dependence Trees]" '(https://ieeexplore.ieee.org/iel5/18/22639/01054142.pdf)."' " IEEE Transactions on Information Theory. [`bibfile`]" "(bibpath/bibfile)\n") assert papers_by_year == _expected
def test_formatting_1(): example = bibtexparser.loads(bibtex1) ref = Reference(example, "bibdir", "2013_cesar.bib") _expected = ( 'Jean César. (2013). "An amazing title." Nice Journal. ' "[`2013_cesar.bib`](bibdir/2013_cesar.bib)" ) assert str(ref) == _expected
def test_build_toc_papers_by_year_3(): _references = [] for ref in [bibtex3, bibtex4]: _ref_str = bibtexparser.loads(ref) _references.append(Reference(_ref_str, "bibpath", "bibfile")) biblio = Bibliography(_references) toc_years = biblio.create_toc_papers_by_year() assert toc_years == " - [2013](#2013)\n - [1968](#1968)"
def test_formatting_2(): example = bibtexparser.loads(bibtex4) ref = Reference(example, "bib", "1968_chow.bib") _expected = ( 'Chow, C and Liu, Cong. (1968). "[Approximating Discrete Probability ' "Distributions with Dependence Trees]" '(https://ieeexplore.ieee.org/iel5/18/22639/01054142.pdf)."' " IEEE Transactions on Information Theory. [`1968_chow.bib`]" "(bib/1968_chow.bib)") assert str(ref) == _expected
def test_reference_2(): example = bibtexparser.loads(bibtex2) ref = Reference(example, "bib", "example.bib") assert ref.author == "Jean César" assert ref.title == "An amazing title" assert ref.year == 2013 assert ref.journal == "Nice Journal" assert ref.url == "https://example.com" assert ref.note == "Unclassified" assert ref.file_location[0] == "bib" assert ref.file_location[1] == "example.bib"
def test_reference_1(): example = bibtexparser.loads(bibtex1) ref = Reference(example, "bib", "example.bib") assert ref.author == "Jean César" assert ref.title == "An amazing title" assert ref.year == 2013 assert ref.journal == "Nice Journal" assert ref.url is None assert ref.note == "structure-learning" assert ref.file_location[0] == "bib" assert ref.file_location[1] == "example.bib"
def test_reference_3(): example = bibtexparser.loads(bibtex3) ref = Reference(example, "bibdir", "2013_cesar.bib") assert ref.author == "Jean César" assert ref.title == "An amazing title" assert ref.year == 2013 assert ref.journal == "Nice Journal" assert ref.url == "https://example.com" assert ref.note == "parameter-learning" assert ref.file_location[0] == "bibdir" assert ref.file_location[1] == "2013_cesar.bib"
def test_load_2(): ref = Reference.load("bib/1968", "1968_chow.bib") assert ref.author == "Chow, C and Liu, Cong" _expected = ("Approximating Discrete Probability " "Distributions with Dependence Trees") assert ref.title == _expected assert ref.year == 1968 assert ref.journal == "IEEE Transactions on Information Theory" assert ref.url == "https://ieeexplore.ieee.org/iel5/18/22639/01054142.pdf" assert ref.note == "theory" assert ref.file_location[0] == "bib/1968" assert ref.file_location[1] == "1968_chow.bib"
def test_build_toc_topics_2(): _references = [] for ref in [bibtex1, bibtex3]: _ref_str = bibtexparser.loads(ref) _references.append(Reference(_ref_str, "bibpath", "bibfile")) biblio = Bibliography(_references) toc_topics = biblio.create_toc_topics() _expected = (" - [structure-learning](#structure-learning)\n" " - [parameter-learning](#parameter-learning)") assert toc_topics == _expected
def test_load_2(): ref = Reference.load("bib/1968", "1968_chow.bib") assert ref.author == "C. Chow and C. Liu" _expected = ( "Approximating Discrete Probability " "Distributions with Dependence Trees" ) assert ref.title == _expected assert ref.year == 1968 assert ref.journal == "IEEE Transactions on Information Theory" assert ref.url == "https://doi.org/10.1109/TIT.1968.1054142" assert ref.note == "theory" assert ref.file_location[0] == "bib/1968" assert ref.file_location[1] == "1968_chow.bib"
def test_initialize_bibliography(): _references = [] for ref in [bibtex1, bibtex2, bibtex3, bibtex4, bibtex5]: _ref_str = bibtexparser.loads(ref) _references.append(Reference(_ref_str, "bibpath", "bibfile")) biblio = Bibliography(_references) assert len(biblio.references) == 5 assert biblio._verbose is False assert list(biblio._topics.keys()) == [ "structure-learning", "Unclassified", "parameter-learning", "theory", ]
def test_create_papers_by_year_list_1(): _references = [] for ref in [bibtex1, bibtex3]: _ref_str = bibtexparser.loads(ref) _references.append(Reference(_ref_str, "bibpath", "bibfile")) biblio = Bibliography(_references) papers_by_year = biblio.create_papers_by_year_list() _expected = ( "\n### 2013\n\n" '- Jean César. (2013). "An amazing title." Nice Journal. ' "[`bibfile`](bibpath/bibfile)\n" '- Jean César. (2013). "[An amazing title](https://example.com)."' " Nice Journal. " "[`bibfile`](bibpath/bibfile)\n") assert papers_by_year == _expected
def test_load_1(): ref = Reference.load("bib/1968", "1968_chow.bib") _names = ref.get_names() assert _names == ["Chow, C", "Liu, Cong"]
def test_get_names_2(): example = bibtexparser.loads(bibtex4) ref = Reference(example, "bib", "1968_chow.bib") _names = ref.get_names() assert _names == ["Chow, C", "Liu, Cong"]
def test_get_names_1(): example = bibtexparser.loads(bibtex1) ref = Reference(example, "bibdir", "2013_cesar.bib") _names = ref.get_names() assert _names == ["César, Jean"]