コード例 #1
0
 def test_no_token(self):
     """ No token provided -- throw exception """
     args = mock.Mock()
     args.token = None
     env = {}
     with self.assertRaises(Exception):
         app_utils.get_token(args, env=env)
コード例 #2
0
 def test_env_token(self):
     """ Token from passed environment """
     args = mock.Mock()
     args.token = None
     env = {"DYNALIST_TOKEN": "abcdef123"}
     self.assertEqual("abcdef123",
                      app_utils.get_token(args, env))
コード例 #3
0
 def test_arg_token(self):
     """ Token from arg.token """
     args = mock.Mock()
     args.token = "abcdef123"
     env = {}
     self.assertEqual("abcdef123",
                      app_utils.get_token(args, env))
コード例 #4
0
def main():
    """ Check args and download doc """
    try:
        args = get_arguments()
        token = app_utils.get_token(args, os.environ)
        url = app_utils.get_url(args, os.environ)
        doc = dynalist.Document.from_url(url, token)
        args.outfile.write(doc.to_json())
    except Exception:  # pylint: disable=broad-except
        logging.exception("An error occured.")
        sys.exit(1)
コード例 #5
0
def main():
    """ Check args and download doc """
    try:
        args = get_arguments()
        logging.basicConfig(
            format=app_utils.LOGGING_FORMAT,
            level=logging.DEBUG if args.trace else logging.WARNING)
        doc = app_utils.read_doc(args)
        mirror_nodes = find_mirror_nodes(doc)
        token = app_utils.get_token(args, os.environ)
        update_dynalist(doc, token, mirror_nodes)
    except Exception:  # pylint: disable=broad-except
        logging.exception("An error occured.")
        sys.exit(1)