def test_delete_recordings_other_class(self): """ If there are two datasets with the same class names, the correct one is deleted. """ ds1id = dataset.create_from_dict(self.test_data, author_id=self.test_user_id) ds2id = dataset.create_from_dict(self.test_data, author_id=self.test_user_id) class_name = "Class #1", recordings = ["19e698e7-71df-48a9-930e-d4b1a2026c82"] dataset.delete_recordings(ds2id, class_name, recordings) # Dataset 1 has both initial recordings, but it's been removed from dataset 2 ds1 = dataset.get(ds1id) ds2 = dataset.get(ds2id) self.assertEqual(2, len(ds1["classes"][0]["recordings"])) self.assertEqual(1, len(ds2["classes"][0]["recordings"]))
def test_delete_recordings(self): """ Delete recordings from a class """ dsid = dataset.create_from_dict(self.test_data, author_id=self.test_user_id) originaldataset = dataset.get(dsid) class_name = "Class #1", recordings = ["19e698e7-71df-48a9-930e-d4b1a2026c82"] dataset.delete_recordings(dsid, class_name, recordings) updateddataset = dataset.get(dsid) # Original dataset has the 2 recordings in Class #1, but the updated one only has 1 remaining self.assertEqual(2, len(originaldataset["classes"][0]["recordings"])) expected_recordings = ["0dad432b-16cc-4bf0-8961-fd31d124b01b"] self.assertEqual(set(expected_recordings), set(updateddataset["classes"][0]["recordings"]))