def test_add_recordings(self): """ Add recordings to an existing class """ dsid = dataset.create_from_dict(self.test_data, author_id=self.test_user_id) originaldataset = dataset.get(dsid) class_name = "Class #1", recordings = ["1c085555-3805-428a-982f-e14e0a2b18e6"] dataset.add_recordings(dsid, class_name, recordings) updateddataset = dataset.get(dsid) # Class 1 has been updated with the new recording id self.assertEqual(2, len(originaldataset["classes"][0]["recordings"])) expected_recordings = [ "0dad432b-16cc-4bf0-8961-fd31d124b01b", "19e698e7-71df-48a9-930e-d4b1a2026c82", "1c085555-3805-428a-982f-e14e0a2b18e6" ] self.assertEqual(set(expected_recordings), set(updateddataset["classes"][0]["recordings"])) # Class #2 stays the same as `test_data` expected_recordings = [ "fd528ddb-411c-47bc-a383-1f8a222ed213", "96888f9e-c268-4db2-bc13-e29f8b317c20", "ed94c67d-bea8-4741-a3a6-593f20a22eb6" ] self.assertEqual(set(expected_recordings), set(updateddataset["classes"][1]["recordings"]))
def test_add_recordings_duplicate(self): """ A recording id which already exists is skipped """ dsid = dataset.create_from_dict(self.test_data, author_id=self.test_user_id) class_name = "Class #1", recordings = ["0dad432b-16cc-4bf0-8961-fd31d124b01b", "1c085555-3805-428a-982f-e14e0a2b18e6"] dataset.add_recordings(dsid, class_name, recordings) updateddataset = dataset.get(dsid) expected_recordings = ["0dad432b-16cc-4bf0-8961-fd31d124b01b", "19e698e7-71df-48a9-930e-d4b1a2026c82", "1c085555-3805-428a-982f-e14e0a2b18e6"] self.assertEqual(set(expected_recordings), set(updateddataset["classes"][0]["recordings"]))
def test_add_recordings(self): """ Add recordings to an existing class """ dsid = dataset.create_from_dict(self.test_data, author_id=self.test_user_id) originaldataset = dataset.get(dsid) class_name = "Class #1", recordings = ["1c085555-3805-428a-982f-e14e0a2b18e6"] dataset.add_recordings(dsid, class_name, recordings) updateddataset = dataset.get(dsid) # Class 1 has been updated with the new recording id self.assertEqual(2, len(originaldataset["classes"][0]["recordings"])) expected_recordings = ["0dad432b-16cc-4bf0-8961-fd31d124b01b", "19e698e7-71df-48a9-930e-d4b1a2026c82", "1c085555-3805-428a-982f-e14e0a2b18e6"] self.assertEqual(set(expected_recordings), set(updateddataset["classes"][0]["recordings"])) # Class #2 stays the same as `test_data` expected_recordings = ["fd528ddb-411c-47bc-a383-1f8a222ed213", "96888f9e-c268-4db2-bc13-e29f8b317c20", "ed94c67d-bea8-4741-a3a6-593f20a22eb6"] self.assertEqual(set(expected_recordings), set(updateddataset["classes"][1]["recordings"]))