本文整理汇总了Python中server_support.server函数的典型用法代码示例。如果您正苦于以下问题:Python server函数的具体用法?Python server怎么用?Python server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了server函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_physical_format_from_format_and_type
def test_physical_format_from_format_and_type():
"""
Test physical format appending from format and type fields
"""
INPUT = {
"format": ["76.8 x 104 cm",
"Oil on canvas",
"7 1/4 x 6 inches (18.4 x 15.2 cm)",
"Sheet: 9 1/2 x 12 1/8 inches (24.1 x 30.8 cm)"],
"type": ["Paintings", "Painting"]
}
EXPECTED = {
"format": ["76.8 x 104 cm",
"Oil on canvas",
"7 1/4 x 6 inches (18.4 x 15.2 cm)",
"Sheet: 9 1/2 x 12 1/8 inches (24.1 x 30.8 cm)",
"Paintings", "Painting"]
}
resp, content = H.request(server() + "enrich-type?prop=type&format_field=format", "POST", body=json.dumps(INPUT))
assert str(resp.status).startswith("2")
FETCHED = json.loads(content)
assert FETCHED == EXPECTED, DictDiffer(EXPECTED, FETCHED).diff()
resp, content = H.request(server() + "enrich-format?prop=format&type_field=type", "POST", body=content)
assert str(resp.status).startswith("2")
FETCHED = json.loads(content)
assert FETCHED == EXPECTED, DictDiffer(EXPECTED, FETCHED).diff()
开发者ID:amber-reichert,项目名称:ingestion,代码行数:27,代码来源:test_enrich.py
示例2: test_cleanup_enrich_then_lookup1
def test_cleanup_enrich_then_lookup1():
"""Should produce both name and iso639_3 language fields"""
INPUT = [
"en", "English", ["eng"], ["English"], ["en", "English"]
]
EXPECTED = {
"sourceResource": {
"language": [{"name": "English", "iso639_3": "eng"}]
}
}
for i in range(len(INPUT)):
input = {"sourceResource": {"language": INPUT[i]}}
url = server() + "cleanup_language"
resp, content = H.request(url, "POST", json.dumps(input))
assert resp.status == 200
url = server() + "enrich_language"
resp, content = H.request(url, "POST", content)
assert resp.status == 200
url = server() + "lookup?prop=sourceResource%2Flanguage%2Fname" + \
"&target=sourceResource%2Flanguage%2Fname&substitution=iso639_3"
resp, content = H.request(url, "POST", content)
assert resp.status == 200
url = server() + "lookup?prop=sourceResource%2Flanguage%2Fname" + \
"&target=sourceResource%2Flanguage%2Fiso639_3" + \
"&substitution=iso639_3&inverse=True"
resp, content = H.request(url, "POST", content)
assert resp.status == 200
assert_same_jsons(content, EXPECTED)
开发者ID:amber-reichert,项目名称:ingestion,代码行数:29,代码来源:test_enrich_language.py
示例3: test_enrich_list_of_dictionaries_and_strings
def test_enrich_list_of_dictionaries_and_strings():
"""Should handle list of dictionaries and strings"""
INPUT = {
"id": "12345",
"sourceResource": {
"spatial": [
{"country": "United States", "county": "Buncombe", "state": "North Carolina"},
"Rushmore, Mount",
"Mount Rushmore National Memorial",
]
},
}
EXPECTED = {
"id": "12345",
"sourceResource": {
"spatial": [
{"country": "United States", "county": "Buncombe", "state": "North Carolina"},
{"name": "Rushmore, Mount"},
{"name": "Mount Rushmore National Memorial"},
]
},
}
url = server() + "enrich_location"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert resp.status == 200
assert json.loads(content) == EXPECTED
开发者ID:marktriggs,项目名称:ingestion,代码行数:27,代码来源:test_enrich_location.py
示例4: test_enrich_location_after_provider_specific_enrich_location4
def test_enrich_location_after_provider_specific_enrich_location4():
"""
Previous specific-provider location did not set state.
"""
INPUT = {
"id": "12345",
"sourceResource": {
"spatial": [{"city": "Asheville; La Jolla", "county": "Buncombe;San Diego", "country": "United States"}]
},
"creator": "Miguel",
}
EXPECTED = {
"id": "12345",
"sourceResource": {
"spatial": [
{"city": "Asheville", "county": "Buncombe", "country": "United States"},
{"city": "La Jolla", "county": "San Diego"},
]
},
"creator": "Miguel",
}
url = server() + "enrich_location"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert resp.status == 200
assert json.loads(content) == EXPECTED
开发者ID:marktriggs,项目名称:ingestion,代码行数:26,代码来源:test_enrich_location.py
示例5: _get_server_response
def _get_server_response(body, prop=None, to_prop=None):
url = server() + "move_date_values"
if prop:
url = "%s?prop=%s" % (url, prop)
if to_prop:
url = "%s&to_prop=%s" % (url, to_prop)
return H.request(url,"POST",body=body)
开发者ID:dpla,项目名称:ingestion,代码行数:7,代码来源:test_move_date_values.py
示例6: test_geocode_unicode
def test_geocode_unicode():
"""Should handle unicode values
"""
INPUT = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": {
"name": u"États-Unis"
}
}
}
EXPECTED = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": [{
"name": u"États-Unis"
}]
}
}
url = server() + "geocode"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert resp.status == 200
assert_same_jsons(EXPECTED, json.loads(content))
开发者ID:marktriggs,项目名称:ingestion,代码行数:27,代码来源:test_geocode.py
示例7: test_geocode_geonames_name_search_context
def test_geocode_geonames_name_search_context():
"""Should find a place name, only if matching other data.
"""
INPUT = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": {
"name": "Portland",
"state": "Maine"
}
}
}
EXPECTED = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": [{
"county": "Cumberland County",
"country": "United States",
"state": "Maine",
"name": "Portland",
"coordinates": "43.66147, -70.25533"
}
]}
}
url = server() + "geocode"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert resp.status == 200
assert_same_jsons(EXPECTED, json.loads(content))
开发者ID:marktriggs,项目名称:ingestion,代码行数:32,代码来源:test_geocode.py
示例8: test_geocode_exclude_coordinates_from_countries
def test_geocode_exclude_coordinates_from_countries():
"""Should not include coordinates or smaller administrative units in
country enhancements
"""
INPUT = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": {"name": "Greece"}
}
}
EXPECTED = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": [{
"country": "Greece",
"name": "Greece"
}]
}
}
url = server() + "geocode"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert resp.status == 200
assert_same_jsons(EXPECTED, json.loads(content))
开发者ID:marktriggs,项目名称:ingestion,代码行数:26,代码来源:test_geocode.py
示例9: test_geocode_works_with_dotted_abbreviations
def test_geocode_works_with_dotted_abbreviations():
"""Resolves something like "Greenville (S.C.)" as well as "SC" """
# Note when retrofitting Twofishes later: Twofishes handles "(S.C.)" just
# fine, so most of this test's assertion should be kept, but the code that
# works around this syntax should be altered. When we use Twofishes,
# we're going to be able to preserve the "S.C." spelling in the "name"
# property, and when we do this for Ingestion 3 with MAPv4 we'll be able
# to preserve that spelling in the providedLabel property.
INPUT = {
"_id": "foo",
"sourceResource": {
"spatial": {
"name": "Greenville (S.C.)"
}
}
}
EXPECTED = {
"_id": "foo",
"sourceResource": {
"spatial": [
{
"city": "Greenville",
"county": "Greenville County",
"country": "United States",
"state": "South Carolina",
"name": "Greenville (S.C.)",
"coordinates": "34.85262, -82.39401"
}
]
}
}
url = server() + "geocode"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert resp.status == 200
assert_same_jsons(EXPECTED, json.loads(content))
开发者ID:dpla,项目名称:ingestion,代码行数:35,代码来源:test_geocode.py
示例10: test_convert_spatial_string_to_dictionary
def test_convert_spatial_string_to_dictionary():
"""
Convert a spatial string into a dictionary with a key of 'name'
"""
INPUT = {
"id": "12345",
"sourceResource": {
"spatial": [u'42.24 N 71.49 W',
u"Bear Park (Reading Mass.)"]
},
"creator": "David"
}
EXPECTED = {
"id": "12345",
"sourceResource": {
"spatial": [
{
"name": u"42.24N 71.49W"
},
{
"name": u"Bear Park (Reading MA)"
}
]
},
"creator": "David"
}
url = server() + "digital_commonwealth_enrich_location"
resp,content = H.request(url,"POST",body=json.dumps(INPUT))
assert resp.status == 200
assert json.loads(content) == EXPECTED
开发者ID:amber-reichert,项目名称:ingestion,代码行数:31,代码来源:test_digital_commonwealth_enrich_location.py
示例11: test_strip_non_spatial_entries
def test_strip_non_spatial_entries():
"""
Strip out strings that are not locations.
"""
INPUT = {
"id": "12345",
"sourceResource": {
"spatial": ["Pictorial works", "Somerville, MA"]
},
"creator": "David"
}
EXPECTED = {
"id": "12345",
"sourceResource": {
"spatial": [
{
"name": "Somerville, MA"
}
]
},
"creator": "David"
}
url = server() + "digital_commonwealth_enrich_location"
resp,content = H.request(url,"POST",body=json.dumps(INPUT))
assert resp.status == 200
assert json.loads(content) == EXPECTED
开发者ID:amber-reichert,项目名称:ingestion,代码行数:27,代码来源:test_digital_commonwealth_enrich_location.py
示例12: test_webfeedjson
def test_webfeedjson():
from amara.thirdparty import json
import json
url = server() + "akara.webfeed.json?url=http://feeds.delicious.com/v2/rss/recent%3Fmin=1%26count=15"
response = urlopen(url)
results = json.load(response)
print results
开发者ID:dpla,项目名称:akara,代码行数:7,代码来源:test_demo_modules.py
示例13: _make_log2json_request
def _make_log2json_request(query_args):
from amara.thirdparty import json
url = server() + "akara.wwwlog.json" + query_args
req = urllib2.Request(url)
req.add_header("Content-Type", "text/plain")
response = urllib2.urlopen(req, _apache_query_data)
return json.load(response)
开发者ID:dpla,项目名称:akara,代码行数:7,代码来源:test_demo_modules.py
示例14: 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)
开发者ID:peterkingalex,项目名称:ingestion,代码行数:31,代码来源:test_enrich_date.py
示例15: test_geocode_set_name_by_feature
def test_geocode_set_name_by_feature():
"""Should set the name property to the smallest available feature value"""
INPUT = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": {
"country": "Canada",
"city": "Bananas"
}
}
}
EXPECTED = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": [{
'coordinates': '62.8329086304, -95.9133224487',
'country': 'Canada',
'name': 'Bananas',
'state': 'Nunavut',
"city": "Bananas"
}]
}
}
url = server() + "geocode"
resp,content = H.request(url,"POST",body=json.dumps(INPUT))
assert resp.status == 200
assert_same_jsons(EXPECTED, json.loads(content))
开发者ID:marktriggs,项目名称:ingestion,代码行数:30,代码来源:test_geocode.py
示例16: test_geocode_unicode
def test_geocode_unicode():
"""Handles unicode values that can be cast as UTF-8"""
INPUT = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": {
"name": u"États-Unis"
}
}
}
EXPECTED = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": [{
"country": "United States",
"name": u"États-Unis"
}]
}
}
url = server() + "geocode"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert resp.status == 200
assert_same_jsons(EXPECTED, json.loads(content))
开发者ID:dpla,项目名称:ingestion,代码行数:27,代码来源:test_geocode.py
示例17: test_geocode_do_not_skip_united_states
def test_geocode_do_not_skip_united_states():
"""Should geocode when name value is 'United States' is followed by a '-'
"""
INPUT = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": {"name": "United States--California"}
}
}
EXPECTED = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": [{
"coordinates": "37.25022, -119.75126",
"country": "United States",
"name": "United States--California",
"state": "California"
}]
}
}
url = server() + "geocode"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert resp.status == 200
assert_same_jsons(EXPECTED, json.loads(content))
开发者ID:marktriggs,项目名称:ingestion,代码行数:27,代码来源:test_geocode.py
示例18: 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)
开发者ID:chadfennell,项目名称:ingestion,代码行数:27,代码来源:test_enrich_date.py
示例19: test_geocode_geonames_name_search
def test_geocode_geonames_name_search():
"""Should find a place name.
"""
INPUT = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": {"name": "Portland, OR"}
}
}
EXPECTED = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": [{
"county": "Multnomah County",
"country": "United States",
"state": "Oregon",
"name": "Portland, OR",
"coordinates": "45.52345, -122.67621"
}]
}
}
url = server() + "geocode"
resp, content = H.request(url, "POST", body=json.dumps(INPUT))
assert resp.status == 200
assert_same_jsons(EXPECTED, json.loads(content))
开发者ID:marktriggs,项目名称:ingestion,代码行数:29,代码来源:test_geocode.py
示例20: test_geocode_set_name_coordinates
def test_geocode_set_name_coordinates():
"""Should set the name property to the lowest hierarchy value"""
INPUT = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": {
"coordinates": "37.7771186829, -122.419639587",
"city": "Bananas"
}
}
}
EXPECTED = {
"id": "12345",
"_id": "12345",
"sourceResource": {
"spatial": [
{
"coordinates": "37.7771186829, -122.419639587",
"city": "Bananas",
"state": "California",
"name": "Bananas",
"county": "San Francisco County",
"country": "United States"
}
]
}
}
url = server() + "geocode"
resp,content = H.request(url,"POST",body=json.dumps(INPUT))
assert resp.status == 200
assert_same_jsons(EXPECTED, json.loads(content))
开发者ID:marktriggs,项目名称:ingestion,代码行数:33,代码来源:test_geocode.py
注:本文中的server_support.server函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论