Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from api import create_app, db
from api.models.user import User
from api.models.cell import Cell
from api.models.sensor import Sensor
from api.models.data import Data

Expand Down Expand Up @@ -166,21 +165,6 @@ def clear_data(test_client):
yield test_client


@pytest.fixture(scope="module")
def setup_cells(test_client):
# db.drop_all()
# Create the database and the database table
db.create_all()
cell = Cell("cell_1", "", 1, 1, False, None)
cell2 = Cell("cell_2", "", 2, 2, False, None)
db.session.add(cell)
db.session.add(cell2)
db.session.commit()

# context for testing fixure
yield test_client


@pytest.fixture(scope="module")
def cli_test_client():
# Set the Testing configuration prior to creating the Flask application
Expand Down
17 changes: 13 additions & 4 deletions backend/tests/test_cell.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
from api import db
from api.models.cell import Cell


def test_cell_search_by_name(setup_cells):
def test_cell_search_by_name(init_database):
"""
GIVEN cells exist in the database
WHEN searching cells by name pattern
THEN only cells whose names match the pattern are returned
"""
results = Cell.search_by_name("cell")
cell1 = Cell("search_cell_alpha", "", 1, 1, False, None)
cell2 = Cell("search_cell_beta", "", 2, 2, False, None)
db.session.add(cell1)
db.session.add(cell2)
db.session.commit()

results = Cell.search_by_name("search_cell")
assert len(results) == 2

results = Cell.search_by_name("cell_1")
results = Cell.search_by_name("alpha")
assert len(results) == 1
assert results[0].name == "cell_1"
assert results[0].name == "search_cell_alpha"

results = Cell.search_by_name("nonexistent")
assert len(results) == 0

db.session.remove()


# def test_cell_post_returns_id_and_name(init_database):
# """
Expand Down
Loading