def test009_files_get(self, m_FileSchema, m_FileWebSchema, m_FileWeb, m_File): sha256 = "whatever" api_files.get(sha256, self.db) m_File.load_from_sha256.assert_called_once_with(sha256, self.db) m_func = m_FileWeb.query_find_by_hash m_func.assert_called_once_with("sha256", sha256, None, self.db, distinct_name=False)
def test011_files_get_offset_limit(self, m_FileSchema, m_FileWebSchema, m_FileWeb, m_File): sha256 = "whatever" offset = randint(1000, 2000) limit = randint(0, 1000) self.request.query['offset'] = offset self.request.query['limit'] = limit api_files.get(sha256, self.db) m_File.load_from_sha256.assert_called_once_with(sha256, self.db) m_query = m_FileWeb.query_find_by_hash m_query().limit.assert_called_once_with(limit) m_query().limit().offset.assert_called_once_with(offset)
def test016_download(self, m_File, m_open): sha256 = "whatever" self.request.query['alt'] = "media" api_files.get(sha256, self.db) m_File.load_from_sha256.assert_called_once_with(sha256, self.db)
def test010_files_get_error(self, m_File, m_process_error): sha256 = "whatever" exception = Exception() m_File.load_from_sha256.side_effect = exception api_files.get(sha256, self.db) m_process_error.assert_called_with(exception)