Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_encode_url():
url = "https://www.wolframalpha.com/input/?i=integrate+from+0+to+2pi+(cos(x)+e%5E(i+*+(m+-+n)+*+x))"
d = {
"wolframalphai1": pybtex.database.Entry(
"misc", fields=[("url", url), ("note", "Online; accessed 19-February-2019")]
)
}
out = betterbib.pybtex_to_bibtex_string(d["wolframalphai1"], "wolframalphai1")
# Split string and fetch entry with url
url_entry = out.split()[3]
# Remove braces and trailing comma
url_entry = url_entry[1:-2]
assert url_entry == url
def test():
assert (
betterbib.tools._translate_title(
"The Magnus expansion and some of its applications"
)
== "The {Magnus} expansion and some of its applications"
)
assert (
betterbib.tools._translate_title("VODE: a variable-coefficient ODE solver")
== "{VODE:} {A} variable-coefficient {ODE} solver"
)
assert (
betterbib.tools._translate_title(
"Peano's kernel theorem for vector-valued functions"
)
== "{Peano's} kernel theorem for vector-valued functions"
)
def test():
assert (
betterbib.tools._translate_title(
"The Magnus expansion and some of its applications"
)
== "The {Magnus} expansion and some of its applications"
)
assert (
betterbib.tools._translate_title("VODE: a variable-coefficient ODE solver")
== "{VODE:} {A} variable-coefficient {ODE} solver"
)
assert (
betterbib.tools._translate_title(
"Peano's kernel theorem for vector-valued functions"
)
== "{Peano's} kernel theorem for vector-valued functions"
)
assert (
betterbib.tools._translate_title(
"Exponential Runge-Kutta methods for parabolic problems"
)
== "Exponential {Runge}-{Kutta} methods for parabolic problems"
)
def test():
assert (
betterbib.tools._translate_title(
"The Magnus expansion and some of its applications"
)
== "The {Magnus} expansion and some of its applications"
)
assert (
betterbib.tools._translate_title("VODE: a variable-coefficient ODE solver")
== "{VODE:} {A} variable-coefficient {ODE} solver"
)
assert (
betterbib.tools._translate_title(
"Peano's kernel theorem for vector-valued functions"
)
== "{Peano's} kernel theorem for vector-valued functions"
)
assert (
betterbib.tools._translate_title(
"Exponential Runge-Kutta methods for parabolic problems"
)
== "Exponential {Runge}-{Kutta} methods for parabolic problems"
)
assert (
betterbib.tools._translate_title(
"GMRES: A generalized minimal residual algorithm"
)
'source': u'Crossref',
'url': u'http://dx.doi.org/10.1002/0470868279',
'publisher': u'John Wiley & Sons, Ltd',
'title': u'Numerical Methods for Ordinary Differential Equations',
'isbn': '9780470868270, 9780471967583',
'year': 2003,
'month': 6,
},
persons=pybtex.database.OrderedCaseInsensitiveDict({
'author': [
pybtex.database.Person(u'Butcher, J.C.'),
]
}))
assert betterbib.pybtex_to_bibtex_string(bt, 'key') \
== betterbib.pybtex_to_bibtex_string(reference, 'key')
return
'volume': u'34',
'issn': u'0895-4798, 1095-7162',
'year': 2013,
'month': 1,
},
persons=pybtex.database.OrderedCaseInsensitiveDict({
'author': [
pybtex.database.Person(u'Gaul, Andr\xe9'),
pybtex.database.Person(u'Gutknecht, Martin H.'),
pybtex.database.Person(u'Liesen, J\xf6rg'),
pybtex.database.Person(u'Nabben, Reinhard')
]
}))
assert betterbib.pybtex_to_bibtex_string(bt, 'key') \
== betterbib.pybtex_to_bibtex_string(reference, 'key')
assert betterbib.tools.get_short_doi(
betterbib.tools.doi_from_url(bt.fields['url'])
) == '10/f44kd7'
return
'Krylov Subspace Methods',
'volume': u'34',
'issn': u'0895-4798, 1095-7162',
'year': 2013,
'month': 1,
},
persons=pybtex.database.OrderedCaseInsensitiveDict({
'author': [
pybtex.database.Person(u'Gaul, Andr\xe9'),
pybtex.database.Person(u'Gutknecht, Martin H.'),
pybtex.database.Person(u'Liesen, J\xf6rg'),
pybtex.database.Person(u'Nabben, Reinhard')
]
}))
assert betterbib.pybtex_to_bibtex_string(bt, 'key') \
== betterbib.pybtex_to_bibtex_string(reference, 'key')
return
"doi": "10.1002/0470868279",
"publisher": "John Wiley & Sons, Ltd",
"title": "Numerical Methods for Ordinary Differential Equations",
"subtitle": "Butcher/Numerical Methods",
"url": "http://dx.doi.org/10.1002/0470868279",
"month": 6,
"source": "Crossref",
"year": 2003,
"isbn": "9780470868270, 9780471967583",
},
persons=pybtex.database.OrderedCaseInsensitiveDict(
{"author": [pybtex.database.Person("Butcher, J.C.")]}
),
)
assert betterbib.pybtex_to_bibtex_string(
bt, "key", sort=True
) == betterbib.pybtex_to_bibtex_string(reference, "key", sort=True)
'url': u'http://dx.doi.org/10.2172/15014765',
'institution': 'Office of Scientific ' +
'and Technical Information (OSTI)',
'title': 'CT Scan of NASA Booster Nozzle',
'year': 2004,
'month': 7,
},
persons=pybtex.database.OrderedCaseInsensitiveDict({
'author': [
pybtex.database.Person(u'Schneberk, D'),
pybtex.database.Person(u'Perry, R'),
pybtex.database.Person(u'Thompson, R'),
]})
)
assert betterbib.pybtex_to_bibtex_string(bt, 'key') \
== betterbib.pybtex_to_bibtex_string(reference, 'key')
return
'isbn': u'9780444501684',
'year': 2002,
},
persons=pybtex.database.OrderedCaseInsensitiveDict({
'author': [
pybtex.database.Person(u'Beyn, Wolf-J\xfcrgen'),
pybtex.database.Person(u'Champneys, Alan'),
pybtex.database.Person(u'Doedel, Eusebius'),
pybtex.database.Person(u'Govaerts, Willy'),
pybtex.database.Person(u'Kuznetsov, Yuri A.'),
pybtex.database.Person(u'Sandstede, Bj\xf6rn')
]})
)
assert betterbib.pybtex_to_bibtex_string(bt, 'key') \
== betterbib.pybtex_to_bibtex_string(reference, 'key')
return