I had a simple function.def graphite_json(target):    url = 'http://server/render/?format=json&amp;target={}&amp;from=-10days'.format(target)    r = requests.get(url)    return r.json()This contacts  a (Graphite) server, uses the requests library to get JSON string and convert it to a native list. Simple.Then I wanted to test it and made a complete mess. My thinking was: I'll soon need more Graphite functionality so best to create a class, also have the requests library as an external dependency so that I can test better. What I ended up with is this:The Business Logic:import jsonimport requestsclass Graphite(object):    def __init__(self, server_url = 'http://server', requests_module=requests):        self.requests = requests_module        self.server_url = server_url    def get(self, metric):        url = '{}/render/?format=json&amp;target={}'.format(            self.server_url, metric)        response = self.requests.get(url)        return response.json()The Testimport jsonimport osimport pytestfrom api.graphite import Graphite@pytest.fixture(scope=session)def sample_response():    dirpath = os.path.dirname(os.path.realpath(__file__))    with open('{}/data/graphite_response.json'.format(dirpath), 'r') as content_file:        content = content_file.read()    return content@pytest.fixture(scope=session)def mock_graphite_requests(sample_response):    class Requests(object):        def get(self, url):            if 'target' not in url:                raise NotImplementedError('need a target for graphite stats')            class Response(object):                def __init__(self, data):                    self.data = data                def json(self):                    return json.loads(self.data)            return Response(sample_response)    return Requests()@pytest.fixture(scope=session)def graphite(mock_graphite_requests):    return Graphite(requests_module=mock_graphite_requests)def test_graphite_metric(graphite, sample_response):    data = graphite.get('summarize(stats.gauges.items,12hour,avg)')    assert data == json.loads(sample_response)I see this as weak because:The test is huge! I'll have to maintain it, probably.What am I actually testing? I think I only test that this class converts the response from JSON.How can I fix this mess?
Computing a list from Graphite JSON
python;unit testing