def test_six(self): """ Verify that a file uploaded to one server can be Deleted from another server """ self.test_name = self.test_six.__doc__ try: txn.test_configs.API_SERVER_URL = self.servers[0] response = txn.upload_a_file( config.TEST_DATA.milestone_1b.file_to_upload_2) assert (response.status_code == 200) id = response.text r = txn.retrive_a_file_by_id(id) assert (r.status_code == 200) txn.test_configs.API_SERVER_URL = self.servers[1] delete = txn.delete_a_file_by_id(id) assert (delete.status_code == 200) txn.test_configs.API_SERVER_URL = self.servers[0] r = txn.retrive_a_file_by_id(id) assert (r.status_code == 404) txn.test_configs.API_SERVER_URL = self.servers[2] list_of_files = txn.list_available_files().json() assert (str(id) not in str(list_of_files)) self.status = 'Pass' except Exception as e: self.status = 'Fail' raise e
def test_five(self): """ Verify that when there are files , the list call displays the files correctly """ self.test_name = self.test_five.__doc__ try: count = txn.list_available_files().json() assert (count.__len__() > 0) self.status = 'Pass' except Exception as e: self.status = 'Fail' raise e
def test_two(self): """ Verify that the list Files returns no files when there are no files to be displayed """ self.test_name = self.test_two.__doc__ try: response = txn.list_available_files().json() assert (response.__len__() == 0) self.status = 'Pass' except Exception as e: self.status = 'Fail' raise e
def test_two(self): """ Verify that when all files are deleted from one server, the changes are reflected on other servers """ self.test_name = self.test_two.__doc__ try: txn.test_configs.API_SERVER_URL = self.servers[1] response = txn.list_available_files().json() assert (response.__len__() == 0) self.status = 'Pass' except Exception as e: self.status = 'Fail' raise e
def test_five(self): """ Verify that when there are files uploaded to one server, the data is listed on the other server """ self.test_name = self.test_five.__doc__ try: txn.test_configs.API_SERVER_URL = self.servers[1] count = txn.list_available_files().json() assert (count.__len__() > 0) assert (config.TEST_DATA.milestone_1b.file_name_1 in str(count)) self.status = 'Pass' except Exception as e: self.status = 'Fail' raise e
def test_one(self): """ Delete all the files on the server_M3 """ self.test_name = self.test_one.__doc__ try: files = txn.list_available_files().json() for items in files: rs = txn.delete_a_file_by_id(items['id']) assert(rs.status_code==200) self.status = 'Pass' except Exception as e: self.status = 'Fail' raise e
def test_list(self): """ Verify that list operation of files works fine """ self.test_name = self.test_list.__doc__ try: list_response = txn.list_available_files() # , "The uploaded file was not listed on the /upload/list route") assert (config.TEST_DATA.sanity_test.file_name in list_response.text) self.status = 'Pass' except Exception as e: self.status = 'Fail' raise e
def test_eleven(self): """ Verify that files of various names are accepted during upload """ self.test_name = self.test_eleven.__doc__ try: file_names = list(config.TEST_DATA.test_eleven.file_names) for items in file_names: open("Test/TestData/" + items, 'w+') upload_stat = txn.upload_a_file("Test/TestData/" + items) assert (upload_stat.status_code == 200) list_of_files = txn.list_available_files().json() file_names_Actual = [] for files in list_of_files: file_names_Actual.append(files['file_name']) assert (txn.is_slice_in_list(file_names, file_names_Actual), True) self.status = 'Pass' except Exception as e: self.status = 'Fail' raise e
def test_six(self): """ Verify that a delete operation happens successfully """ self.test_name = self.test_six.__doc__ try: response = txn.upload_a_file( config.TEST_DATA.test_five.file_to_upload) assert (response.status_code == 200) id = response.text r = txn.retrive_a_file_by_id(id) assert (r.status_code == 200) delete = txn.delete_a_file_by_id(id) assert (delete.status_code == 200) r = txn.retrive_a_file_by_id(id) assert (r.status_code == 404) list_of_files = txn.list_available_files().json() assert (str(id) not in str(list_of_files)) self.status = 'Pass' except Exception as e: self.status = 'Fail' raise e