File: test_backup.py

package info (click to toggle)
pyroute2 0.8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,704 kB
  • sloc: python: 50,245; makefile: 280; javascript: 183; ansic: 81; sh: 44; awk: 17
file content (21 lines) | stat: -rw-r--r-- 664 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sqlite3
import sys
import uuid

import pytest


@pytest.mark.skipif(
    sys.version_info < (3, 7),
    reason='SQLite3 backup not supported on this Python version',
)
def test_file_backup(context):
    filename = str(uuid.uuid4()) + '-backup.db'
    context.ndb.backup(filename)
    backup = sqlite3.connect(filename)
    cursor = backup.cursor()
    cursor.execute('SELECT f_IFLA_IFNAME FROM interfaces WHERE f_index > 0')
    interfaces_from_backup = {x[0] for x in cursor.fetchall()}
    with context.ndb.interfaces.summary() as summary:
        interfaces_from_ndb = {x.ifname for x in summary}
    assert interfaces_from_ndb == interfaces_from_backup