Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.storage.tests.test_storage.TestLocalStorage::test_content_add_objstorage_exception
Failed

TEST RESULT

Run At
May 20 2020, 9:28 AM
Details
self = <swh.storage.tests.test_storage.TestLocalStorage object at 0x7f45ba04f860> swh_storage = <swh.storage.validate.ValidatingProxyStorage object at 0x7f45ba04f9e8> def test_content_add_objstorage_exception(self, swh_storage): swh_storage.objstorage.content_add = Mock( side_effect=Exception("mocked broken objstorage") ) with pytest.raises(Exception) as e: swh_storage.content_add([data.cont]) assert e.value.args == ("mocked broken objstorage",) > missing = list(swh_storage.content_missing([data.cont])) .tox/py3/lib/python3.7/site-packages/swh/storage/tests/test_storage.py:3588: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox/py3/lib/python3.7/site-packages/swh/core/db/common.py:97: in _meth yield from meth(self, *args, db=db, cur=cur, **kwargs) .tox/py3/lib/python3.7/site-packages/swh/storage/storage.py:329: in content_missing for obj in db.content_missing_from_list(content, cur): .tox/py3/lib/python3.7/site-packages/swh/storage/db.py:147: in content_missing_from_list (tuple(c[key] for key in self.content_hash_keys) for c in contents), _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cur = <cursor object at 0x7f45b9e31330; closed: -1> sql = b'\n SELECT sha1, sha1_git, sha256, blake2s256\n FROM (VALUES %s) as t(sha1, sha1_git, sha256, b....sha1 AND t.sha1_git = c.sha1_git AND t.sha256 = c.sha256 AND t.blake2s256 = c.blake2s256\n )\n ' argslist = <generator object Db.content_missing_from_list.<locals>.<genexpr> at 0x7f45b9c42e58> template = b'(%s,%s,%s,%s)', page_size = 100 def execute_values_generator(cur, sql, argslist, template=None, page_size=100): """Execute a statement using SQL ``VALUES`` with a sequence of parameters. Rows returned by the query are returned through a generator. You need to consume the generator for the queries to be executed! :param cur: the cursor to use to execute the query. :param sql: the query to execute. It must contain a single ``%s`` placeholder, which will be replaced by a `VALUES list`__. Example: ``"INSERT INTO mytable (id, f1, f2) VALUES %s"``. :param argslist: sequence of sequences or dictionaries with the arguments to send to the query. The type and content must be consistent with *template*. :param template: the snippet to merge to every item in *argslist* to compose the query. - If the *argslist* items are sequences it should contain positional placeholders (e.g. ``"(%s, %s, %s)"``, or ``"(%s, %s, 42)``" if there are constants value...). - If the *argslist* items are mappings it should contain named placeholders (e.g. ``"(%(id)s, %(f1)s, 42)"``). If not specified, assume the arguments are sequence and use a simple positional template (i.e. ``(%s, %s, ...)``), with the number of placeholders sniffed by the first element in *argslist*. :param page_size: maximum number of *argslist* items to include in every statement. If there are more items the function will execute more than one statement. :param yield_from_cur: Whether to yield results from the cursor in this function directly. .. __: https://www.postgresql.org/docs/current/static/queries-values.html After the execution of the function the `cursor.rowcount` property will **not** contain a total result. """ # we can't just use sql % vals because vals is bytes: if sql is bytes # there will be some decoding error because of stupid codec used, and Py3 # doesn't implement % on bytes. if not isinstance(sql, bytes): sql = sql.encode(psycopg2.extensions.encodings[cur.connection.encoding]) pre, post = _split_sql(sql) for page in _paginate(argslist, page_size=page_size): if template is None: template = b"(" + b",".join([b"%s"] * len(page[0])) + b")" parts = pre[:] for args in page: parts.append(cur.mogrify(template, args)) parts.append(b",") parts[-1:] = post > cur.execute(b"".join(parts)) E psycopg2.errors.UndefinedTable: relation "content" does not exist E LINE 5: SELECT 1 FROM content c E ^ .tox/py3/lib/python3.7/site-packages/swh/core/db/db_utils.py:150: UndefinedTable