Skip to content

Commit

Permalink
Another try to fix CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goerch committed Nov 10, 2023
1 parent a804d28 commit 3e13ba5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
11 changes: 5 additions & 6 deletions tests/fixtures/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ def insert_model1_data(session: Session, count: int) -> List[Model1]:


@contextmanager
def model1_data(session: Session, count: int = MODEL1_DATA_SIZE) -> List[Model1]:
def model1_data(session: Session, count: int = MODEL1_DATA_SIZE, delete: bool = False) -> List[Model1]:
if delete:
session.query(Model1).delete()
session.commit()

model1_collection = insert_model1_data(session, count)
model_ids = [model.id for model in model1_collection]

Expand All @@ -49,11 +53,6 @@ def model1_data(session: Session, count: int = MODEL1_DATA_SIZE) -> List[Model1]
if model:
session.delete(model)
session.commit()
models = session.query(Model1).all()
if models:
# raise RuntimeError(f"model data contains {models}")
session.query(Model1).delete()
session.commit()


def insert_model2_data(session: Session, count: int) -> List[Model2]:
Expand Down
9 changes: 4 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,9 +960,8 @@ def test_get_item_not_found(self):
"""
client = self.app.test_client()
token = self.login(client, USERNAME_ADMIN, PASSWORD_ADMIN)
with model1_data(self.appbuilder.session, 1) as models:
with model1_data(self.appbuilder.session, 1, True):
model_id = MODEL1_DATA_SIZE + 1
self.assertTrue(model_id not in [model.id for model in models])
rv = self.auth_client_get(client, token, f"api/v1/model1api/{model_id}")
self.assertEqual(rv.status_code, 404)

Expand Down Expand Up @@ -2512,9 +2511,9 @@ def test_create_item(self):
self.assertEqual(model.field_integer, 4)
self.assertEqual(model.field_float, 4.0)

# Revert data changes
self.appbuilder.session.delete(model)
self.appbuilder.session.commit()
# Revert data changes
self.appbuilder.session.delete(model)
self.appbuilder.session.commit()

def test_create_item_bad_request(self):
"""
Expand Down

0 comments on commit 3e13ba5

Please sign in to comment.