|
@@ -289,9 +289,47 @@ class ClientTests(BaseTestCase):
|
|
|
|
|
|
self._post(
|
|
|
f"/projects/{project_id}/labels",
|
|
|
- json=dict(
|
|
|
- name=f"Label {i}",
|
|
|
- )
|
|
|
+ json=dict(name=f"Label {i}")
|
|
|
)
|
|
|
|
|
|
self.assertEqual(i, Label.query.filter(Label.project_id == project_id).count())
|
|
|
+
|
|
|
+ def test_label_removal(self):
|
|
|
+ self._post(
|
|
|
+ "/projects",
|
|
|
+ json=dict(
|
|
|
+ name="some project",
|
|
|
+ description="project description",
|
|
|
+ model=self.model_id,
|
|
|
+ label=None,
|
|
|
+ external=None,
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ project = Project.query.first()
|
|
|
+ project_id = project.id
|
|
|
+ self.assertIsNotNone(project)
|
|
|
+
|
|
|
+ self.assertEqual(0, Label.query.filter(Label.project_id == project_id).count())
|
|
|
+
|
|
|
+ for i in range(1, 11):
|
|
|
+
|
|
|
+ self._post(
|
|
|
+ f"/projects/{project_id}/labels",
|
|
|
+ json=dict(name=f"Label {i}")
|
|
|
+ )
|
|
|
+ self.assertEqual(10, Label.query.filter(Label.project_id == project_id).count())
|
|
|
+
|
|
|
+ label = Label.query.get(5)
|
|
|
+ label_id = label.id
|
|
|
+ self.assertIsNotNone(label)
|
|
|
+
|
|
|
+ self._post(
|
|
|
+ f"/projects/{project_id}/labels/{label_id}/remove",
|
|
|
+ json=dict(remove=True)
|
|
|
+ )
|
|
|
+
|
|
|
+ self.assertEqual(9, Label.query.filter(Label.project_id == project_id).count())
|
|
|
+ label = Label.query.get(5)
|
|
|
+ self.assertIsNone(label)
|
|
|
+
|