Skip to content

Commit

Permalink
More correctly mock out urllib3 objects passed to ijson.
Browse files Browse the repository at this point in the history
Previously, we mocked out the return value of read() with a simple
constant but newer versions of ijson tight-loop if we don't return
an EOF at some point.
  • Loading branch information
fasaxc committed Sep 28, 2016
1 parent ec0ebdd commit 82cf203
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions calico/etcddriver/test/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import sys

import time
from mock import Mock, patch, call
from mock import Mock, patch, call, mock_open
from urllib3 import HTTPConnectionPool
from urllib3.exceptions import TimeoutError, HTTPError, ReadTimeoutError
from calico.datamodel_v1 import READY_KEY, CONFIG_DIR, VERSION_DIR
Expand Down Expand Up @@ -960,16 +960,14 @@ def test_parse_snapshot_bad_status(self):
m_resp, Mock())

def test_parse_snapshot_bad_data(self):
m_resp = Mock()
m_resp = mock_open(read_data="[]")()
m_resp.status = 200
m_resp.read.return_value = "[]"
self.assertRaises(ResyncRequired, driver.parse_snapshot,
m_resp, Mock())

def test_parse_snapshot_garbage_data(self):
m_resp = Mock()
m_resp = mock_open(read_data="garbage")()
m_resp.status = 200
m_resp.read.return_value = "garbage"
self.assertRaises(ResyncRequired, driver.parse_snapshot,
m_resp, Mock())

Expand Down

0 comments on commit 82cf203

Please sign in to comment.