code: def test_hierarchy():
      url = "http://api.geonames.org/hierarchyJSON?geonameId=6094817&username=mock"
      data_file = "tests/results/geonames_hierarchy.json"
      with requests_mock.Mocker() as mocker, open(
          data_file, "r"
      ) as input:
          mocker.get(url, text=input.read())
          g = geocoder.geonames(6094817, method="hierarchy", key="mock")
          assert g.ok
          assert repr(g) == "<[OK] Geonames - Hierarchy #5 results>"
          assert len(g) == 5
          assert g.status_code == 200
  
          expected_names = [
              "Earth",
              "North America",
              "Canada",
              "Ontario",
              "Ottawa",
          ]
          assert expected_names == [res.address for res in g]
  
file_path: geocoder/tests/test_geonames.py
imports: import json
  import pytest
  import geocoder
  import requests_mock
label_desc: Use image node_id 12 for calling a global function with example usage: test_hierarchy() without return types