def test_get_collection_manifest(self): collection_name = "dummy" StorageServer.add_collection(self.__account_id, collection_name, callback=self.stop) response = self.wait() self.assertEqual(StorageResponse.OK, response) collection_file = open("../test_resources/collection.xml") StorageServer.save_collection_manifest(self.__account_id, collection_name, collection_file, callback=self.stop) response = self.wait() self.assertEqual(StorageResponse.OK, response) StorageServer.get_collection_manifest(self.__account_id, collection_name, callback=self.stop) response = self.wait() self.assertTrue(response is not None) # clean up StorageServer.remove_collection(self.__account_id, collection_name, callback=self.stop) self.wait()
def __get_collection_manifest_content(self, account_id, collection_name): StorageServer.get_collection_manifest(account_id, collection_name, callback=self.stop) response = self.wait(timeout=100) if response is None: print 'GOT NONE; retrying' try: self.wait(timeout=10) except Exception: pass StorageServer.get_collection_manifest(account_id, collection_name, callback=self.stop) response = self.wait(timeout=100) if response is None: print 'Still None, failing' return None else: return response.read() else: return response.read()
def test_update_manifest(self): collection_name = str(uuid.uuid4()) subscriber_list = [self.__subscriber_id] sharing_secret, subscribers_collections =\ self.__create_sharing_record(subscriber_list, collection_name) joker = JokerHelper.get_instance() joker.get_sharing_space_server(sharing_secret, callback=self.stop) server_adrs = self.wait(timeout=10000) self.assertIn(server_adrs, Properties.sharing_space_servers) manifest_file = open('../test_resources/sharing_template1.xml') expected_manifest_body = manifest_file.read() joker.update_manifest(server_adrs, sharing_secret, self.__account_id, collection_name, manifest_file, callback=self.stop) response = self.wait(timeout=1000) self.assertEqual(StorageResponse.OK, response) #wait for a while self.__wait(10) #try to retrieve the file StorageServer.get_collection_manifest(self.__account_id, collection_name, callback=self.stop) actual_manifest_file = self.wait() actual_manifest_body = actual_manifest_file.read() self.assertEqual(actual_manifest_body, expected_manifest_body) #cleanup SharingController.remove_sharing_record_by_secret(sharing_secret, callback =self.stop) self.wait() StorageServer.remove_collection(self.__account_id, collection_name, callback=self.stop) for subscriber_id in subscribers_collections: subscriber_collection = subscribers_collections[subscriber_id] StorageServer.remove_collection(subscriber_id, subscriber_collection, callback=self.stop) self.wait()
def test_get_collection_manifest_non_existing(self): StorageServer.get_collection_manifest(self.__account_id, "dummy", callback=self.stop) response = self.wait() self.assertTrue(response is None)