Skip to content

Commit

Permalink
Test for doi to URL
Browse files Browse the repository at this point in the history
  • Loading branch information
dlesbre committed Aug 7, 2024
1 parent 7f66dea commit fc29b55
Show file tree
Hide file tree
Showing 3 changed files with 378 additions and 0 deletions.
1 change: 1 addition & 0 deletions bibtexautocomplete/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def main(argv: Optional[List[str]] = None) -> None:
fields_to_overwrite=fields_to_overwrite,
fields_to_protect_uppercase=fields_to_protect_uppercase,
filter_by_entrytype=args.filter_fields_by_entrytype,
copy_doi_to_url=args.copy_doi_to_url,
)
completer.print_filters()
try:
Expand Down
375 changes: 375 additions & 0 deletions tests/bibs/doi-to-url.btac.bib.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,375 @@
@comment{@book{empty_entry,
}}

@comment{Outside of entries, text is just a comment}

@misc{entry_basic,
title = {My awesome article},
author = {Yours Truly},
booktitle = {Generated booktitle 1},
edition = {Edition 1},
journal = {Generated Journal 1},
month = {2},
note = {Note: this is query number 1
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 1},
pages = {1},
url = {https://example.com/1},
volume = {1},
}

@article{entry_basic2,
title = {Something},
author = {Someone},
booktitle = {Generated booktitle 2},
doi = {10.00000/doi.number.2},
edition = {Edition 2},
issn = {0002-0001},
journal = {Generated Journal 2},
month = {3},
note = {Note: this is query number 2
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 2},
pages = {1--2},
url = {https://dx.doi.org/10.00000/doi.number.2},
volume = {2},
}

@booklet{almost_empty,
note = {This entry shouldn't be queried, no useful data},
}

@techreport{also_almost_empty,
foo = {bar: no standard field at all},
}

@article{doi,
title = {Generated title 5},
author = {Doe5, John},
booktitle = {Generated booktitle 5},
doi = {10.5432/hello},
edition = {Edition 5},
journal = {Generated Journal 5},
month = {6},
note = {Note: this is query number 5
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 5},
pages = {1--5},
url = {https://dx.doi.org/10.00000/doi.number.5},
volume = {5},
}

@inproceedings{giberish,
title = {giberish},
author = {1789},
booktitle = {Generated booktitle 6},
date = {long ago},
doi = {invalid format},
edition = {Edition 6},
isbn = {also not a number},
issn = {not a number},
journal = {Generated Journal 6},
month = {brumaire},
note = {Note: this is query number 6
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 6},
pages = {not a number},
url = {https://example.com/6},
volume = {6},
}

@article{full,
title = {Full entry, never queried, but field order changed},
author = {1789},
booktitle = {full},
date = {long ago},
doi = {invalid format},
edition = {full},
isbn = {also not a number},
issn = {not a number},
journal = {full},
month = {brumaire},
note = {full},
organization = {full},
pages = {not a number},
url = {present},
volume = {full},
}

@misc{marked,
title = {marked entry is not queried},
btacqueried = {2024-07-19},
journal = {Something},
pages = {1--150},
}

@article{markedbis,
title = {marked entry is not queried},
btacqueried = {not necessarily a data},
doi = {10.22222/123456789},
}

@misc{all_fields_for_misc,
title = {Test for filter-by-entrytype},
author = {My Guy},
booktitle = {Generated booktitle 7},
doi = {10.12345/hello},
edition = {Edition 7},
howpublished = {Somehow},
journal = {Generated Journal 7},
month = {June},
note = {Shouldn't be queried with "-b all" flag},
organization = {organization 7},
pages = {1--7},
url = {https://example.com/7},
volume = {7},
year = {2015},
}

@misc{opt_field_for_misc,
title = {Test for filter-by-entrytype},
author = {My Guy},
booktitle = {Generated booktitle 8},
doi = {10.00000/doi.number.8},
edition = {Edition 8},
howpublished = {Somehow},
journal = {Generated Journal 8},
month = {June},
note = {Shouldn't be queried with "-b optional" flag, but queried for "-b all"},
organization = {organization 8},
pages = {1--8},
url = {https://dx.doi.org/10.00000/doi.number.8},
volume = {8},
year = {2015},
}

@misc{req_field_for_misc,
title = {Test for filter-by-entrytype},
author = {Doe9, John},
booktitle = {Generated booktitle 9},
edition = {Edition 9},
journal = {Generated Journal 9},
month = {10},
note = {Note: this is query number 9
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 9},
pages = {1--9},
url = {https://example.com/9},
volume = {9},
}

@article{entry0,
title = {Title of entry 0},
author = {Doe10, John},
booktitle = {Generated booktitle 10},
edition = {Edition 10},
journal = {Generated Journal 10},
month = {11},
note = {Note: this is query number 10
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 10},
pages = {1--10},
url = {https://example.com/10},
volume = {10},
}

@book{entry1,
title = {Title of entry 1},
author = {Doe11, John},
booktitle = {Generated booktitle 11},
doi = {10.00000/doi.number.11},
edition = {Edition 11},
journal = {Generated Journal 11},
month = {12},
note = {Note: this is query number 11
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 11},
pages = {1--11},
url = {https://dx.doi.org/10.00000/doi.number.11},
volume = {11},
}

@booklet{entry2,
title = {Title of entry 2},
author = {Doe12, John},
booktitle = {Generated booktitle 12},
edition = {Edition 12},
journal = {Generated Journal 12},
month = {1},
note = {Note: this is query number 12
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 12},
pages = {1--12},
url = {https://example.com/12},
volume = {12},
}

@conference{entry3,
title = {Title of entry 3},
author = {Doe13, John},
booktitle = {Generated booktitle 13},
edition = {Edition 13},
issn = {0013-0001},
journal = {Generated Journal 13},
month = {2},
note = {Note: this is query number 13
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 13},
pages = {1--13},
url = {https://example.com/13},
volume = {13},
}

@inbook{entry4,
title = {Title of entry 4},
author = {Doe14, John},
booktitle = {Generated booktitle 14},
doi = {10.00000/doi.number.14},
edition = {Edition 14},
journal = {Generated Journal 14},
month = {3},
note = {Note: this is query number 14
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 14},
pages = {1--14},
url = {https://dx.doi.org/10.00000/doi.number.14},
volume = {14},
}

@incollection{entry5,
title = {Title of entry 5},
author = {Doe15, John},
booktitle = {Generated booktitle 15},
edition = {Edition 15},
journal = {Generated Journal 15},
month = {4},
note = {Note: this is query number 15
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 15},
pages = {1--15},
url = {https://example.com/15},
volume = {15},
}

@manual{entry6,
title = {Title of entry 6},
author = {Doe16, John},
booktitle = {Generated booktitle 16},
edition = {Edition 16},
journal = {Generated Journal 16},
month = {5},
note = {Note: this is query number 16
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 16},
pages = {1--16},
url = {https://example.com/16},
volume = {16},
}

@mastersthesis{entry7,
title = {Title of entry 7},
author = {Doe17, John},
booktitle = {Generated booktitle 17},
doi = {10.00000/doi.number.17},
edition = {Edition 17},
journal = {Generated Journal 17},
month = {6},
note = {Note: this is query number 17
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 17},
pages = {1--17},
url = {https://dx.doi.org/10.00000/doi.number.17},
volume = {17},
}

@misc{entry8,
title = {Title of entry 8},
author = {Doe18, John},
booktitle = {Generated booktitle 18},
edition = {Edition 18},
journal = {Generated Journal 18},
month = {7},
note = {Note: this is query number 18
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 18},
pages = {1--18},
url = {https://example.com/18},
volume = {18},
}

@techreport{entry9,
title = {Title of entry 9},
author = {Doe19, John},
booktitle = {Generated booktitle 19},
edition = {Edition 19},
journal = {Generated Journal 19},
month = {8},
note = {Note: this is query number 19
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 19},
pages = {1--19},
url = {https://example.com/19},
volume = {19},
}

@unpublished{entry10,
title = {Title of entry 10},
author = {Doe20, John},
booktitle = {Generated booktitle 20},
doi = {10.00000/doi.number.20},
edition = {Edition 20},
journal = {Generated Journal 20},
month = {9},
note = {Note: this is query number 20
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 20},
pages = {1--20},
url = {https://dx.doi.org/10.00000/doi.number.20},
volume = {20},
}

@inproceedings{entry11,
title = {Title of entry 11},
author = {Doe21, John},
booktitle = {Generated booktitle 21},
edition = {Edition 21},
journal = {Generated Journal 21},
month = {10},
note = {Note: this is query number 21
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 21},
pages = {1--21},
url = {https://example.com/21},
volume = {21},
}

@phdthesis{entry12,
title = {Title of entry 12},
author = {Doe22, John},
booktitle = {Generated booktitle 22},
edition = {Edition 22},
journal = {Generated Journal 22},
month = {11},
note = {Note: this is query number 22
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 22},
pages = {1--22},
url = {https://example.com/22},
volume = {22},
}

@misc{with_accents,
title = {Lots OF accents AnD Capitalization: éàêïæøçÉÀÊÏÆØÇ},
author = {Somebody},
booktitle = {Generated booktitle 23},
doi = {10.00000/doi.number.23},
edition = {Edition 23},
journal = {Generated Journal 23},
month = {12},
note = {Note: this is query number 23
Newline UppERcaSE AND accents: éàêïæøçÉÀÊÏÆØÇ},
organization = {organization 23},
pages = {1--23},
url = {https://dx.doi.org/10.00000/doi.number.23},
volume = {23},
}
2 changes: 2 additions & 0 deletions tests/test_6_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ def get_value(self, res: SafeJSON) -> BibtexEntry:
+ ["-C=" + field for field in NOT_SELECTION2],
[("field-selection-and-entrytype.btac.bib.exp", "input.btac.bib")],
),
([input_bib, "-u"], [("doi-to-url.btac.bib.exp", "input.btac.bib")]),
([input_bib, "--copy-doi-to-url"], [("doi-to-url.btac.bib.exp", "input.btac.bib")]),
]


Expand Down

0 comments on commit fc29b55

Please sign in to comment.