Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend: fix SAWarnings about autoflush #3654

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions frontend/coprs_frontend/tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def test_update_permissions(self, log):
copr_builder=helpers.PermissionEnum("request"),
copr_admin=helpers.PermissionEnum("request"))

db.session.add(perm)

CoprPermissionsLogic.update_permissions(
self.u2, self.c2, perm,
new_builder=helpers.PermissionEnum("approved"),
Expand Down
42 changes: 29 additions & 13 deletions frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,19 +349,35 @@
def test_add_group_project(self):
flask.g.user = self.u1

# User can create project in a group that he belongs to
self.u1.admin = False
CoprsLogic.add(name="p1", group=self.g1, user=self.u1, selected_chroots=["fedora-rawhide-x86_64"])

# User cannot create a project in a group that he doesn't belong to
self.u1.openid_groups = None
with pytest.raises(AccessRestricted) as ex:
CoprsLogic.add(name="p2", group=self.g1, user=self.u1, selected_chroots=["fedora-rawhide-x86_64"])
assert "User 'user1' doesn't have access to the copr group 'group1' (fas_name='fas_1')" in ex.value.message

# Admin can create a whatever group project
self.u1.admin = True
CoprsLogic.add(name="p3", group=self.g1, user=self.u1, selected_chroots=["fedora-rawhide-x86_64"])
with f_db.session.no_autoflush:

Check warning

Code scanning / vcs-diff-lint

TestCoprsLogicAdminFeatures.test_add_group_project: Undefined variable 'f_db' Warning test

TestCoprsLogicAdminFeatures.test_add_group_project: Undefined variable 'f_db'

Check warning

Code scanning / vcs-diff-lint

Undefined name f_db Warning test

Undefined name f\_db
# User can create project in a group that he belongs to
self.u1.admin = False
CoprsLogic.add(
name="p1", group=self.g1, user=self.u1, selected_chroots=["fedora-rawhide-x86_64"]
)

# User cannot create a project in a group that he doesn't belong to
self.u1.openid_groups = None
with pytest.raises(AccessRestricted) as ex:
CoprsLogic.add(
name="p2",
group=self.g1,
user=self.u1,
selected_chroots=["fedora-rawhide-x86_64"]
)
assert (
"User 'user1' doesn't have access to the copr group 'group1' (fas_name='fas_1')"
in ex.value.message
)

# Admin can create a whatever group project
self.u1.admin = True
CoprsLogic.add(
name="p3",
group=self.g1,
user=self.u1,
selected_chroots=["fedora-rawhide-x86_64"]
)


class TestChrootFormLogic(CoprsTestCase):
Expand Down
1 change: 1 addition & 0 deletions frontend/coprs_frontend/tests/test_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_outdated_chroot_message(self, f_users, f_coprs, f_mock_chroots, f_db):
for i in range(30, 38):
mc = models.MockChroot(os_release="fedora", os_version=i,
arch="x86_64", is_active=True)
f_db.session.add(mc)
mc.distgit_branch = models.DistGitBranch.query.first()
cc = models.CoprChroot()
cc.mock_chroot = mc
Expand Down
Loading