Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_push_mult(self):
append_file(self.files[0])
append_file(self.files[1])
locales = ['es-AR']
test_doc_id_0 = self.action.doc_manager.get_doc_by_prop('file_name',self.files[0])['id']
test_doc_id_1 = self.action.doc_manager.get_doc_by_prop('file_name',self.files[1])['id']
self.request_action = RequestAction(os.getcwd(), self.files[0], None, locales, False, False, None, None, test_doc_id_0)
target1 = self.request_action.target_action()
self.request_action = RequestAction(os.getcwd(), self.files[1], None, locales, False, False, None, None, test_doc_id_1)
target2 = self.request_action.target_action()
push = self.action.push_action()
assert check_updated_ids(self.action, [test_doc_id_0, test_doc_id_1]) # Poll and wait until the modification has taken effect on the cloud
dl_path_0 = self.download_action.download_action(test_doc_id_0, locales[0], False)
dl_path_1 = self.download_action.download_action(test_doc_id_1, locales[0], False)
self.downloaded = [dl_path_0, dl_path_1]
for path in self.downloaded:
with open(path, 'r') as f:
downloaded_text = f.read()
#print("downloaded_text: "+downloaded_text)
assert "Texto agregado." in downloaded_text
assert "Este es un ejemplo de archivo de texto." in downloaded_text
def test_push_1(self):
append_file(self.files[0])
locales = ['es-AR']
test_doc_id = self.action.doc_manager.get_doc_by_prop('file_name',self.files[0])['id']
self.request_action = RequestAction(os.getcwd(), self.files[0], None, locales, False, False, None, None, test_doc_id)
self.request_action.target_action()
with open(self.files[0]) as f:
downloaded = f.read()
self.action.push_action()
assert check_updated_ids(self.action, [test_doc_id]) # Poll and wait until the modification has taken effect in the cloud
downloaded_path = self.download_action.download_action(test_doc_id, locales[0], False)
#print("downloaded_path: "+str(downloaded_path))
self.downloaded.append(downloaded_path)
with open(downloaded_path, 'r') as f:
downloaded_text = f.read()
#print ("Downloaded_text: " + downloaded)
assert "Texto agregado." in downloaded_text
assert "Este es un ejemplo de archivo de texto." in downloaded_text
def test_push_mult(self):
append_file(self.files[0])
append_file(self.files[1])
locales = ['es-AR']
test_doc_id_0 = self.action.doc_manager.get_doc_by_prop('file_name',self.files[0])['id']
test_doc_id_1 = self.action.doc_manager.get_doc_by_prop('file_name',self.files[1])['id']
self.request_action = RequestAction(os.getcwd(), self.files[0], None, locales, False, False, None, None, test_doc_id_0)
target1 = self.request_action.target_action()
self.request_action = RequestAction(os.getcwd(), self.files[1], None, locales, False, False, None, None, test_doc_id_1)
target2 = self.request_action.target_action()
push = self.action.push_action()
assert check_updated_ids(self.action, [test_doc_id_0, test_doc_id_1]) # Poll and wait until the modification has taken effect on the cloud
dl_path_0 = self.download_action.download_action(test_doc_id_0, locales[0], False)
dl_path_1 = self.download_action.download_action(test_doc_id_1, locales[0], False)
self.downloaded = [dl_path_0, dl_path_1]
for path in self.downloaded:
with open(path, 'r') as f:
downloaded_text = f.read()
#print("downloaded_text: "+downloaded_text)
assert "Texto agregado." in downloaded_text
assert "Este es un ejemplo de archivo de texto." in downloaded_text
def test_status_detailed(self):
# see that there are targets
# request translations
self.request_action = RequestAction(os.getcwd(), None, self.file_name, self.targets, False, None, None)
self.request_action.target_action()
try:
out = StringIO()
sys.stdout = out
self.action.get_status(detailed=True)
status = out.getvalue()
assert 'Status of {0}'.format(self.file_name) in status
for target in self.targets:
assert 'Locale: {0}'.format(target) in status
finally:
sys.stdout = sys.__stdout__
def setUp(self):
self.config_action = ConfigAction(os.getcwd())
self.config_action.config_action(clone_option='off')
self.config_action.config_action(download_folder='--none')
self.downloaded_files = []
self.locales = ['ja-JP', 'zh-CN']
self.action = DownloadAction(os.getcwd())
self.clean_action = CleanAction(os.getcwd())
self.request_action = RequestAction(os.getcwd(), None, None, self.locales, False, False, None, None)
self.pull_action = PullAction(os.getcwd(), self.action)
self.clean_action.clean_action(False, False, None)
self.files = ['sample.txt', 'sample1.txt']
self.first_doc = 'sample.txt'
for fn in self.files:
create_txt_file(fn)
os.system('ltk add sample*.txt -o') # Let the command line handle parsing the file pattern
self.doc_ids = self.action.doc_manager.get_doc_ids()
for doc_id in self.doc_ids:
assert poll_doc(self.action, doc_id)
self.request_action.target_action()
title = os.path.basename(file_name)
if document_id not in self.watch_queue:
self.watch_queue.append(document_id)
# Only add target if doc exists on the cloud
if self.check_remote_doc_exist(title, document_id):
locales_to_add = self.get_watch_locales(document_id)
if locales_to_add == ['[]']: locales_to_add = []
# if len(locales_to_add) == 1:
# printStr = "Adding target "+locales_to_add[0]
# else:
# printStr = "Adding targets "
# for target in locales_to_add:
# printStr += target+","
# print(printStr)
if self.api.get_document(document_id):
request = request_action.RequestAction(self.path, title, file_name, locales_to_add, None, None, None, None, document_id, True)
if request.target_action() and document_id in self.watch_queue:
self.watch_queue.remove(document_id)
title = os.path.basename(file_name)
if document_id not in self.watch_queue:
self.watch_queue.append(document_id)
# Only add target if doc exists on the cloud
if self.check_remote_doc_exist(title, document_id):
locales_to_add = self.get_watch_locales(document_id)
if locales_to_add == ['[]']: locales_to_add = []
# if len(locales_to_add) == 1:
# printStr = "Adding target "+locales_to_add[0]
# else:
# printStr = "Adding targets "
# for target in locales_to_add:
# printStr += target+","
# print(printStr)
if self.api.get_document(document_id):
request = request_action.RequestAction(self.path, title, file_name, locales_to_add, None, None, None, None, document_id, True)
if request.target_action() and document_id in self.watch_queue:
self.watch_queue.remove(document_id)