How to use ltk - 10 common examples

To help you get started, we’ve selected a few ltk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Lingotek / filesystem-connector / tests / test_actions / test_init.py View on Github external
def test_init_api(self):
        create_config()
        action = actions.Action(os.getcwd())
        assert action.api
        action.close()
        cleanup()
github Lingotek / filesystem-connector / tests / test_actions / test_init.py View on Github external
def test_init_doc_manager(self):
        create_config()
        action = actions.Action(os.getcwd())
        assert action.doc_manager
        action.close()
        cleanup()
github Lingotek / filesystem-connector / tests / test_actions / test_init.py View on Github external
def test_init_host(self):
        create_config()
        action = actions.Action(os.getcwd())
        print (action.host)
        action.close()
        cleanup()
github Lingotek / filesystem-connector / tests / test_actions / test_push.py View on Github external
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
github Lingotek / filesystem-connector / tests / test_actions / test_push.py View on Github external
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
github Lingotek / filesystem-connector / tests / test_actions / test_push.py View on Github external
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
github Lingotek / filesystem-connector / tests / test_actions / test_status.py View on Github external
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__
github Lingotek / filesystem-connector / tests / test_actions / test_download.py View on Github external
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()
github Lingotek / filesystem-connector / tests / test_actions / test_init.py View on Github external
def test_uninitialized(self):
        cwd = os.getcwd()
        os.chdir('/')
        self.assertRaises(exceptions.UninitializedError, actions.Action, os.getcwd())
        os.chdir(cwd)  # change back to this directory so rest of the tests will work
github Lingotek / filesystem-connector / tests / test_actions / test_clone.py View on Github external
def setUp(self):
        self.action = CloneAction(os.getcwd())
        self.add_action = AddAction(os.getcwd())
        self.added_directories = []
        self.config_action = ConfigAction(os.getcwd())
        self.rm_action = RmAction(os.getcwd())
        self.dir_path1 = os.path.join(os.getcwd(), 'dir1')
        self.added_directories.append(self.dir_path1)
        create_directory(self.dir_path1)
        self.dir_path2 = os.path.join(os.getcwd(), 'dir2')
        self.added_directories.append(self.dir_path2)
        create_directory(self.dir_path2)
        self.dir_path3 = os.path.join(os.getcwd(), 'dir1','dir3')
        self.added_directories.append(self.dir_path3)
        create_directory(self.dir_path3)
        self.delete_directory(os.path.join(os.getcwd(), 'ja-JP'))
        self.delete_directory(os.path.join(os.getcwd(), 'es-MX'))
        self.delete_directory(os.path.join(os.getcwd(), 'downloads'))