File size: 1,022 Bytes
b2add11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pytest
from crud_operations import CRUDOperations


@pytest.fixture
def crud_operations():
    return CRUDOperations("sample.db")


def test_create(crud_operations):
    crud_operations.create("users", ["id", "name", "age"], [1, "Alice", 25])
    assert crud_operations.read("users", ["id", "name", "age"]) == [(1, "Alice", 25)]


def test_read(crud_operations):
    crud_operations.create("users", ["id", "name", "age"], [1, "Alice", 25])
    assert crud_operations.read("users", ["id", "name", "age"]) == [(1, "Alice", 25)]


def test_update(crud_operations):
    crud_operations.create("users", ["id", "name", "age"], [1, "Alice", 25])
    crud_operations.update("users", {"name": "Bob"}, "id = 1")
    assert crud_operations.read("users", ["id", "name", "age"]) == [(1, "Bob", 25)]


def test_delete(crud_operations):
    crud_operations.create("users", ["id", "name", "age"], [1, "Alice", 25])
    crud_operations.delete("users", "id = 1")
    assert crud_operations.read("users", ["id", "name", "age"]) == []