本文整理汇总了Python中server_support.print_error_log函数的典型用法代码示例。如果您正苦于以下问题:Python print_error_log函数的具体用法?Python print_error_log怎么用?Python print_error_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_error_log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_prop_doesnt_exist
def test_prop_doesnt_exist():
"""Should return original JSON when prop doesn't exist."""
x = {"aaa": "BBB"}
r, c = _get_server_response(json.dumps(x), 'aaa%2Fddd')
pinfo(x,r,c)
print_error_log()
assert_same_jsons(c, x)
示例2: test_populating_publisher_field
def test_populating_publisher_field():
INPUT = {
"freetext": {
"publisher": [
{
"#text": "Glossary of Coins and Currency Terms",
"@label": "Publication title"
},
{
"#text": "http://americanhistory.si.edu/coins/glossary.cfm",
"@label": "Publication URL"
},
{
"#text": "xx",
"@label": "Publisher"
}
],
}
}
EXPECTED_PUBLISHER = {
"publisher": ["xx"]
}
resp, content = _get_server_response(INPUT)
print_error_log()
assert resp["status"].startswith("2")
CONTENT = json.loads(content)
pinfo(content)
assert_same_jsons(EXPECTED_PUBLISHER, CONTENT["sourceResource"])
示例3: test_not_remove_valid_date_dict
def test_not_remove_valid_date_dict():
INPUT = {
"sourceResource": {
"date":
{
"begin": "1959-01-01",
"end": "1959-01-01",
"displayDate": "1959-01-01"
},
}
}
EXPECTED_OUTPUT = {
"sourceResource": {
"date":
{
"begin": "1959-01-01",
"end": "1959-01-01",
"displayDate": "1959-01-01"
},
}
}
resp, content = _get_server_response(INPUT)
print_error_log()
assert resp["status"].startswith("2")
assert_same_jsons(EXPECTED_OUTPUT, content)
示例4: test_substitute_with_list_of_dictionaries
def test_substitute_with_list_of_dictionaries():
"""
Should convert all dicts in a list.
"""
data = {
"xxx": "yyy",
"aaa": {
"bbb": "ccc",
"xxx": [
{"eee": "aaa"},
{"xxx": "eee"},
{"eee": "bbb"}
]
}
}
INPUT = json.dumps(data)
data["aaa"]["xxx"] = [
{"eee": "AAA222"},
{"xxx": "eee"},
{"eee": "BBB222"},
]
EXPECTED_OUTPUT = json.dumps(data)
resp, content = _get_server_response(INPUT, "aaa/xxx/eee", "aaa/xxx/eee", "test2")
print_error_log()
pinfo(resp, content)
assert resp.status == 200
assert_same_jsons(content, EXPECTED_OUTPUT)
示例5: test_contentdm_identify_object_without_download
def test_contentdm_identify_object_without_download():
"""
Should add a thumbnail URL made of the source URL.
"""
INPUT = {
u"something": "x",
u"somethink": "y",
u"originalRecord":
{"handle":
["aaa", "http://repository.clemson.edu/u?/scp,104"]
},
u"left": "right now!"
}
EXPECTED = {
u"something": "x",
u"somethink": "y",
u"originalRecord": {
"handle":
["aaa", "http://repository.clemson.edu/u?/scp,104"]
},
u"object": ("http://repository.clemson.edu/cgi-bin/" +
"thumbnail.exe?CISOROOT=/scp&CISOPTR=104"),
u"admin": {u"object_status": 0},
u"left": "right now!"
}
url = contentdm_url("False")
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
print_error_log()
assert str(resp.status).startswith("2")
result = json.loads(content)
assert_same_jsons(EXPECTED, result)
示例6: test_substitution_using_scdl_format_dict
def test_substitution_using_scdl_format_dict():
formats = \
("Pamphlets", "Pamphlets"), \
("Pamphlet", "Pamphlets"), \
("pamphlets", "Pamphlets"), \
("Manuscripts", "Manuscripts"), \
("Manuscript", "Manuscripts"), \
("manuscripts", "Manuscripts"), \
("Photograph", "Photographs"), \
("Photographs", "Photographs"), \
("Photograph", "Photographs") \
data = {
"xxx": "yyy",
"aaa": ""
}
for f in formats:
data["aaa"] = f[0]
INPUT = json.dumps(data)
data["aaa"] = f[1]
EXPECTED_OUTPUT = json.dumps(data)
print "Checking: %s" + repr(f)
resp, content = _get_server_response(INPUT, "aaa", "aaa", "scdl_fix_format", None, False)
print_error_log()
assert resp.status == 200
assert_same_jsons(EXPECTED_OUTPUT, content)
示例7: test_year_month
def test_year_month():
"""Should recognize YYYY-MM and not YYYY-YY"""
INPUT = [
"1940/2",
"1940/02",
"1940 / 2",
"1940 / 02",
"1940-2",
"1940-02",
"1940 - 2",
"1940 - 02",
"2/1940",
"02/1940",
"2 / 1940",
"02 / 1940",
"2-1940",
"02-1940",
"2 - 1940",
"02 - 1940",
]
url = server() + "enrich_earliest_date?prop=date"
for date in INPUT:
d = "1940-02"
input = {"date": date}
expected = {"date": {"begin": d, "end": d, "displayDate": date}}
resp, content = H.request(url, "POST", body=json.dumps(input))
print_error_log()
assert str(resp.status).startswith("2")
assert_same_jsons(expected, content)
示例8: test_suppress_creator_value_for_string
def test_suppress_creator_value_for_string():
"""Should remove creator value if the is 'creator'."""
INPUT = {
"sourceResource": {
"creator": "creator",
"aaa": [
"Fisker, Kay--Architect--Danish--Male",
"Fisker, Kay--Architect--Danish--Male",
"bbb",
"ccc"
]
}
}
EXPECTED_OUTPUT = {
"sourceResource": {
"aaa": [
"Fisker, Kay--Architect--Danish--Male",
"Fisker, Kay--Architect--Danish--Male",
"bbb",
"ccc"
]
}
}
resp, content = _get_server_response(json.dumps(INPUT))
print_error_log()
assert resp["status"].startswith("2")
assert_same_jsons(EXPECTED_OUTPUT, content)
示例9: test_iso639_3_substitution
def test_iso639_3_substitution():
"""
Should add "name" to language
"""
INPUT = {
"sourceResource": {
"language": [
{"iso639_3": "eng"},
{"iso639_3": "ara"}
]
}
}
EXPECTED = {
"sourceResource": {
"language": [
{"iso639_3": "eng", "name": "English"},
{"iso639_3": "ara", "name": "Arabic"}
]
}
}
prop = "sourceResource%2Flanguage%2Fiso639_3"
targ = "sourceResource%2Flanguage%2Fname"
subs = "iso639_3"
resp, content = _get_server_response(json.dumps(INPUT), prop, targ, subs)
print_error_log()
assert resp.status == 200
assert_same_jsons(content, EXPECTED)
示例10: test_removing_multiple_invalid_date_dicts
def test_removing_multiple_invalid_date_dicts():
INPUT = {
"sourceResource": {
"date": [
{
"begin": "1959-01-01",
"end": "1959-01-01",
"displayDate": "1959-01-01"
},
{
"begin": "2008-11-18",
"end": "2008-11-18",
"displayDate": "2008-11-18"
},
{
"begin": "1959-01-01",
"end": None,
"displayDate": "1959-01-01"
},
{
"begin": "2008-11-18",
"end": "",
"displayDate": "2008-11-18"
},
{
"begin": None,
"end": "1959-01-01",
"displayDate": "1959-01-01"
},
{
"begin": "",
"end": "2008-11-18",
"displayDate": "2008-11-18"
},
"aaa",
"bbb",
"ccc",
]
}
}
EXPECTED_OUTPUT = {
"sourceResource": {
"date": [
{
"begin": "1959-01-01",
"end": "1959-01-01",
"displayDate": "1959-01-01",
},
{
"begin": "2008-11-18",
"end": "2008-11-18",
"displayDate": "2008-11-18"
},
]
}
}
resp, content = _get_server_response(INPUT, "sourceResource/date")
print_error_log()
assert resp["status"].startswith("2")
assert_same_jsons(EXPECTED_OUTPUT, content)
示例11: test_cleanup_value_for_list
def test_cleanup_value_for_list():
INPUT = {
"aaa": {
"bbb": [
"Fisker, Kay--Architect--Danish--Male",
"Fisker, Kay--Architect--Danish--Male",
"bbb",
"ccc"
]
}
}
EXPECTED_OUTPUT = {
"aaa": {
"bbb": [
"Fisker, Kay",
"Fisker, Kay",
"bbb",
"ccc"
]
}
}
resp, content = _get_server_response(json.dumps(INPUT), "aaa/bbb")
print_error_log()
assert resp["status"].startswith("2")
assert_same_jsons(EXPECTED_OUTPUT, content)
示例12: test_georgia_set_spec_type
def test_georgia_set_spec_type():
"""Should set the specType to include Book, Government Document,
and Serial
"""
INPUT = {
"sourceResource": {
"type": [
"something Books",
" GOVERNMENT something",
" Something periodicals",
" Another periodicals"
]
}
}
EXPECTED = {
"sourceResource": {
"type": [
"something Books",
" GOVERNMENT something",
" Something periodicals",
" Another periodicals"
],
"specType": [
"Book",
"Government Document",
"Serial"
]
}
}
resp, content = _get_server_response(json.dumps(INPUT))
print_error_log()
assert resp["status"] == "200"
assert_same_jsons(EXPECTED, json.loads(content))
示例13: test_unset_prop2
def test_unset_prop2():
"""Should unset prop since condition is met"""
action = "unset"
prop = "sourceResource/rights"
condition = "is_digit"
INPUT = {
"_id": "12345",
"key1": "value1",
"sourceResource": {
"key1" : "value1",
"rights": "20010983784"
},
"key2": "value2"
}
EXPECTED = {
"_id": "12345",
"key1": "value1",
"sourceResource": {
"key1" : "value1"
},
"key2": "value2"
}
resp,content = _get_server_response(json.dumps(INPUT), action=action,
prop=prop, condition=condition)
assert resp.status == 200
print_error_log()
assert json.loads(content) == EXPECTED
示例14: test_range_with_brackets
def test_range_with_brackets():
"""Should transform date range with brackets."""
ranges = [
("1960-05-01 - 1960-05-15", "1960-05-01 - 1960-05-15"),
("[ 1960-05-01 - 1960-05-15 ]", "1960-05-01 - 1960-05-15"),
("[1960-05-01 - 1960-05-15]", "1960-05-01 - 1960-05-15"),
("[1960-05-01 / 1960-05-15]", "1960-05-01 / 1960-05-15"),
("[1960-05-01/1960-05-15]", "1960-05-01/1960-05-15"),
]
for r in ranges:
INPUT = {"date": r[0]}
EXPECTED = {
u'date' : {
u'begin' : u'1960-05-01',
u'end' : u'1960-05-15',
"displayDate" : r[1]
}
}
url = server() + "enrich_earliest_date?prop=date"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert str(resp.status).startswith("2")
print_error_log()
assert_same_jsons(EXPECTED, content)
示例15: test_contentdm_identify_object_usc
def test_contentdm_identify_object_usc():
"""
Should add a thumbnail URL made of the source URL.
"""
INPUT = {
u"something": "x",
u"somethink": "y",
u"originalRecord":
{"handle":
["aaa", "http://some.url/cdm/ref/12345"]
},
u"left": "right now!"
}
EXPECTED = {
u"something": "x",
u"somethink": "y",
u"originalRecord": {
"handle":
["aaa", "http://some.url/cdm/ref/12345"]
},
u"object": ("http://some.url/utils/getthumbnail/12345"),
u"admin": {u"object_status": 0},
u"left": "right now!"
}
url = contentdm_url("False")
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
print_error_log()
assert str(resp.status).startswith("2")
result = json.loads(content)
assert_same_jsons(EXPECTED, result)