class TestCollection(BehanceTestCase): def test_search(self): collections = self.api.collection_search('apple') self.assertGreaterEqual(len(collections), 1) for collection in collections: for key in COLLECTION_KEYS: self.assertTrue(collection.has_key(key)) self.assertTrue(hasattr(collection, key)) def test_collection(self): collection = self.api.get_collection(COLLECTION_ID) self.assertIsNotNone(collection) for key in COLLECTION_KEYS: self.assertTrue(hasattr(collection, key)) self.assertTrue(collection.has_key(key)) def test_collection_projects(self): collection = self.api.get_collection(COLLECTION_ID) projects = collection.get_projects() for project in projects: for key in PROJECT_KEYS: self.assertTrue(project.has_key(key)) self.assertTrue(hasattr(project, key)) def test_exception(self): with self.assertRaises(NotFound): collection = self.api.get_collection('asdf1234') with self.assertRaises(Forbidden): self.api = API('12345') collections = self.api.collection_search('apple')