def test_delete_shapshot(self): id = dataset.create_from_dict(self.test_data, author_id=self.test_user_id) snap_id = dataset.create_snapshot(id) snapshots = dataset.get_snapshots_for_dataset(id) self.assertEqual(len(snapshots), 1) with db.engine.connect() as connection: dataset._delete_snapshots_for_dataset(connection, id) snapshots = dataset.get_snapshots_for_dataset(id) self.assertEqual(len(snapshots), 0) with self.assertRaises(db.exceptions.NoDataFoundException): dataset.get_snapshot(snap_id)
def test_create_snapshot(self): id = dataset.create_from_dict(self.test_data, author_id=self.test_user_id) snapshots = dataset.get_snapshots_for_dataset(id) self.assertEqual(len(snapshots), 0) snap_id = dataset.create_snapshot(id) snapshots = dataset.get_snapshots_for_dataset(id) self.assertEqual(len(snapshots), 1) self.assertEqual(snapshots[0]["id"], snap_id) snap = dataset.get_snapshot(snap_id) dataset_snap = copy.deepcopy(self.test_data) del dataset_snap["public"] self.assertDictEqual(snap["data"], dataset_snap)