def test_from_json_invalid_value(self):
     """
     Test that LibraryList raises Value error if invalid library key is given
     """
     lib_list = LibraryList()
     with self.assertRaises(ValueError):
         lib_list.from_json(["Not-a-library-key,whatever"])
 def test_from_json_invalid_value(self):
     """
     Test that LibraryList raises Value error if invalid library key is given
     """
     lib_list = LibraryList()
     with self.assertRaises(ValueError):
         lib_list.from_json(["Not-a-library-key,whatever"])
 def test_from_json_studio_editor_style(self):
     """
     Test that LibraryList can parse raw libraries list as passed by studio editor
     """
     lib_list = LibraryList()
     lib1_key, lib1_version = u'library-v1:Org1+Lib1', '5436ffec56c02c13806a4c1b'
     lib2_key, lib2_version = u'library-v1:Org2+Lib2', '112dbaf312c0daa019ce9992'
     raw = [lib1_key + ',' + lib1_version, lib2_key + ',' + lib2_version]
     parsed = lib_list.from_json(raw)
     self.assertEqual(len(parsed), 2)
     self.assertEquals(parsed[0].library_id, LibraryLocator.from_string(lib1_key))
     self.assertEquals(parsed[0].version, ObjectId(lib1_version))
     self.assertEquals(parsed[1].library_id, LibraryLocator.from_string(lib2_key))
     self.assertEquals(parsed[1].version, ObjectId(lib2_version))
 def test_from_json_studio_editor_style(self):
     """
     Test that LibraryList can parse raw libraries list as passed by studio editor
     """
     lib_list = LibraryList()
     lib1_key, lib1_version = u'library-v1:Org1+Lib1', '5436ffec56c02c13806a4c1b'
     lib2_key, lib2_version = u'library-v1:Org2+Lib2', '112dbaf312c0daa019ce9992'
     raw = [lib1_key + ',' + lib1_version, lib2_key + ',' + lib2_version]
     parsed = lib_list.from_json(raw)
     self.assertEqual(len(parsed), 2)
     self.assertEquals(parsed[0].library_id, LibraryLocator.from_string(lib1_key))
     self.assertEquals(parsed[0].version, ObjectId(lib1_version))
     self.assertEquals(parsed[1].library_id, LibraryLocator.from_string(lib2_key))
     self.assertEquals(parsed[1].version, ObjectId(lib2_version))