def test_get_bytes(self, m_getvalue, _m_downloadFile): m_getvalue.return_value = 'foo' e = GirderDataElement('someId') actual_bytes = e.get_bytes() self.assertEqual(actual_bytes, bytes('foo'))
def test_get_bytes(self, _m_downloadFile): """ Test that getting bytes is driven by the girder_client downloadFile method. """ _m_downloadFile.side_effect = lambda fid, buf: buf.write(b'foo') e = GirderDataElement('someId') actual_bytes = e.get_bytes() assert actual_bytes == b'foo'
def test_get_bytes(self, m_downloadFile): # Simulate actually downloading something bytes. m_downloadFile.side_effect = \ lambda _if, _bytesio: _bytesio.write(b'foo') e = GirderDataElement('someId') actual_bytes = e.get_bytes() self.assertEqual(actual_bytes, b'foo')
def test_get_bytes(self, m_requests_get, m_gtm): expected_content = 'Some byte content.' expected_response = gen_response(expected_content) # Mock out requests call m_requests_get.return_value = expected_response # Get mocked bytes e = GirderDataElement('someId') actual_bytes = e.get_bytes() nose.tools.assert_equal(expected_content, actual_bytes)