Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_storage.py
Show First 20 Lines • Show All 2,208 Lines • ▼ Show 20 Lines | def test_content_update(self): | ||||
with self.storage.get_db().transaction() as cur: | with self.storage.get_db().transaction() as cur: | ||||
cur.execute('SELECT sha1, sha1_git, sha256, length, status' | cur.execute('SELECT sha1, sha1_git, sha256, length, status' | ||||
' FROM content WHERE sha1 = %s', | ' FROM content WHERE sha1 = %s', | ||||
(cont['sha1'],)) | (cont['sha1'],)) | ||||
datum = cur.fetchone() | datum = cur.fetchone() | ||||
self.assertEqual( | self.assertEqual( | ||||
(datum[0].tobytes(), datum[1].tobytes(), datum[2].tobytes(), | (datum[0], datum[1], datum[2], | ||||
datum[3], datum[4]), | datum[3], datum[4]), | ||||
(cont['sha1'], cont['sha1_git'], cont['sha256'], | (cont['sha1'], cont['sha1_git'], cont['sha256'], | ||||
cont['length'], 'visible')) | cont['length'], 'visible')) | ||||
def test_content_update_with_new_cols(self): | def test_content_update_with_new_cols(self): | ||||
with self.storage.get_db().transaction() as cur: | with self.storage.get_db().transaction() as cur: | ||||
cur.execute("""alter table content | cur.execute("""alter table content | ||||
add column test text default null, | add column test text default null, | ||||
Show All 9 Lines | def test_content_update_with_new_cols(self): | ||||
cur.execute( | cur.execute( | ||||
'SELECT sha1, sha1_git, sha256, length, status, test, test2' | 'SELECT sha1, sha1_git, sha256, length, status, test, test2' | ||||
' FROM content WHERE sha1 = %s', | ' FROM content WHERE sha1 = %s', | ||||
(cont['sha1'],)) | (cont['sha1'],)) | ||||
datum = cur.fetchone() | datum = cur.fetchone() | ||||
self.assertEqual( | self.assertEqual( | ||||
(datum[0].tobytes(), datum[1].tobytes(), datum[2].tobytes(), | (datum[0], datum[1], datum[2], | ||||
datum[3], datum[4], datum[5], datum[6]), | datum[3], datum[4], datum[5], datum[6]), | ||||
(cont['sha1'], cont['sha1_git'], cont['sha256'], | (cont['sha1'], cont['sha1_git'], cont['sha256'], | ||||
cont['length'], 'visible', cont['test'], cont['test2'])) | cont['length'], 'visible', cont['test'], cont['test2'])) | ||||
with self.storage.get_db().transaction() as cur: | with self.storage.get_db().transaction() as cur: | ||||
cur.execute("""alter table content drop column test, | cur.execute("""alter table content drop column test, | ||||
drop column test2""") | drop column test2""") |