Skip to content

Commit 104db20

Browse files
committed
Clear caches after corrupting branches or projects
1 parent d679312 commit 104db20

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/unit/test_branches.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ def test_not_found() -> None:
5959
obj.name = "non-existing2"
6060
with pytest.raises(exceptions.ObjectNotFound):
6161
obj.refresh()
62+
branches.Branch.CACHE.clear()
63+
projects.Project.CACHE.clear()
6264

6365
obj.concerned_object.key = "non-existing2"
6466
with pytest.raises(exceptions.ObjectNotFound):
6567
obj.new_code()
68+
branches.Branch.CACHE.clear()
69+
projects.Project.CACHE.clear()
6670

6771

6872
def test_is_main_is_kept():
@@ -99,9 +103,11 @@ def test_set_as_main():
99103

100104
assert main_br.set_as_main()
101105

102-
main_br.name = "non-existing"
106+
main_br.name = "non-existing-main"
103107
with pytest.raises(exceptions.ObjectNotFound):
104108
main_br.set_as_main()
109+
branches.Branch.CACHE.clear()
110+
projects.Project.CACHE.clear()
105111

106112

107113
def test_set_keep_as_inactive():
@@ -120,9 +126,11 @@ def test_set_keep_as_inactive():
120126

121127
assert dev_br.set_keep_when_inactive(True)
122128

123-
dev_br.name = "non-existing"
129+
dev_br.name = "non-existing-develop"
124130
with pytest.raises(exceptions.ObjectNotFound):
125131
dev_br.set_keep_when_inactive(True)
132+
branches.Branch.CACHE.clear()
133+
projects.Project.CACHE.clear()
126134

127135

128136
def test_rename():
@@ -154,9 +162,11 @@ def test_get_findings():
154162
dev_br = branches.Branch.get_object(concerned_object=project, branch_name="develop")
155163
assert len(dev_br.get_findings()) > 0
156164

157-
dev_br.name = "non-existing"
165+
dev_br.name = "non-existing-dev2"
158166
with pytest.raises(exceptions.ObjectNotFound):
159167
dev_br.get_findings()
168+
branches.Branch.CACHE.clear()
169+
projects.Project.CACHE.clear()
160170

161171

162172
def test_audit():
@@ -167,8 +177,10 @@ def test_audit():
167177
dev_br = branches.Branch.get_object(concerned_object=project, branch_name="develop")
168178
assert len(dev_br.audit({"audit.project.branches": False})) == 0
169179

170-
dev_br.name = "non-existing"
180+
dev_br.name = "non-existing-dev3"
171181
assert len(dev_br.audit({})) == 0
182+
branches.Branch.CACHE.clear()
183+
projects.Project.CACHE.clear()
172184

173185

174186
def test_exists():

0 commit comments

Comments
 (0)