Beispiel #1
0
def test_empty_item_from_json_with_whitespace():
    item = Item()

    item.json = ('{}')
    assert item.json == ('{}')

    item.json = ('   {  }')
    assert item.json == ('{}')
def test_empty_item_from_json_with_whitespace():
    item = Item()

    item.json = "{}"
    assert item.json == ("{}")

    item.json = "   {  }"
    assert item.json == ("{}")
Beispiel #3
0
def test_postaladdress_from_json():
    item = Item()
    item.json = ('{"addressCountry":"GB",'
                 '"addressLocality":"Holborn",'
                 '"addressRegion":"London",'
                 '"postcode":"WC2B 6NH",'
                 '"streetAddress":"Aviation House, 125 Kingsway"}')

    assert item.streetAddress == "Aviation House, 125 Kingsway"
    assert item.addressLocality == "Holborn"
    assert item.addressRegion == "London"
    assert item.postcode == "WC2B 6NH"
    assert item.addressCountry == "GB"
Beispiel #4
0
def load_register(store,
                  name,
                  domain="register.gov.uk",
                  protocol="https",
                  path="download-register"):
    url = "{protocol}://{name}.{domain}/{path}".format(protocol=protocol,
                                                       name=name,
                                                       domain=domain,
                                                       path=path)

    response = cache.get(url)

    zipfile = ZipFile(BytesIO(response.content))

    for info in zipfile.infolist():
        if info.filename.startswith("item/"):
            item = Item()
            item.json = zipfile.open(info.filename).read().decode("utf-8")
            store.put(item)
Beispiel #5
0
def test_set_of_tags_from_json():
    item = Item()
    item.json = ('{"fields":["a","b","c"],"name":"foo"}')
    assert item.name == 'foo'
    assert item.fields == ['a', 'b', 'c']
Beispiel #6
0
def test_empty_item_from_json():
    item = Item()
    item.json = ('{}')
    assert item.json == ('{}')
def test_set_of_tags_from_json():
    item = Item()
    item.json = '{"fields":["a","b","c"],"name":"foo"}'
    assert item.name == "foo"
    assert item.fields == ["a", "b", "c"]
def test_empty_item_from_json():
    item = Item()
    item.json = "{}"
    assert item.json == ("{}")