def test_load_xml_with_response_status_failure(self): self.maxDiff = None response = self.create_response(False) with cast(BinaryIO, (DATA_DIR / 'light_response_failure.xml').open('r')) as f: data = f.read() self.assertEqual(LightResponse.load_xml(parse_xml(data)), response)
def test_put_light_response(self): with cast(TextIO, (DATA_DIR / 'light_response.xml').open('r')) as f: data = f.read() response = LightResponse.load_xml(parse_xml(data)) self.storage.put_light_response('abc', response) self.assertEqual(self.client_class_mock.mock_calls, [call(timeout=33)]) self.assertEqual(self.client_mock.mock_calls, [ call.connect(self.HOST, self.PORT), call.get_cache(self.RESPONSE_CACHE_NAME), call.get_cache().put('abc', data) ])
def test_pop_light_response_found(self): with cast(BinaryIO, (DATA_DIR / 'light_response.xml').open('rb')) as f: data = f.read() self.cache_mock.get_and_remove.return_value = data.decode('utf-8') self.assertEqual(LightResponse.load_xml(parse_xml(data)), self.storage.pop_light_response('abc')) self.assertEqual(self.client_class_mock.mock_calls, [call(timeout=33)]) self.assertEqual(self.client_mock.mock_calls, [ call.connect(self.HOST, self.PORT), call.get_cache(self.RESPONSE_CACHE_NAME), call.get_cache().get_and_remove('abc') ])