def test_get_url_content_retrieve_from_memcache(self):
        import dtmm_utils

        url_digest = dtmm_utils.md5_hash('http://mock.com')

        memcache.set(url_digest, {'content': 'word'})
        end_data = dtmm_utils.get_url_content(None, 'http://mock.com')
        self.assertEqual(end_data, {'content': 'word'})
    def test_get_url_content_fetch_from_remote(self, mock_authed_fetch):
        url = 'http://mock.com'
        content = {
            u'tree': [{
                u'sha': u'ac178f6489f2d3f601df6a9a5e641b62a0388eae',
                u'mode': u'100644',
                u'path': u'README.md',
                u'type': u'blob',
                u'size': 314
            }]
        }
        mock_authed_fetch.return_value.content = json.dumps(content)

        import dtmm_utils
        end_data = dtmm_utils.get_url_content(None, url)
        self.assertEqual(end_data, content)

        mock_authed_fetch.assert_called_with(url)
        self.assertEqual(
            memcache.get(dtmm_utils.md5_hash(url)),
            content
        )