Ejemplo n.º 1
0
    def test_load_config(self):
        httpretty.register_uri(httpretty.GET, 'http://jira.atlassian.com', status=200)
        jira_url = 'jira.atlassian.com'
        username = '******'
        password = '******'
        configuration._save_config(jira_url, username, password, True)
        config_dict = configuration.load_config()

        assert username == config_dict.get('jira').get('username')
        assert base64.b64encode(password) == config_dict.get('jira').get('password')
Ejemplo n.º 2
0
    def test__save_config_url_redirect(self):
        https_url = 'https://jira.atlassian.com'
        httpretty.register_uri(httpretty.GET, 'http://jira.atlassian.com',
                               status=301, location=https_url)
        httpretty.register_uri(httpretty.GET, https_url)
        configuration._save_config('http://jira.atlassian.com', '', '', True)

        assert os.path.exists(self.config_file_path)
        config_dict = configuration.load_config()
        assert config_dict.get('jira').get('url') == https_url
Ejemplo n.º 3
0
def configure():
    """
    Update config
    """
    jira_url = utils.get_input(raw_input, "Jira url")
    username = utils.get_input(raw_input, "username")
    password = utils.get_input(getpass.getpass, "password")
    error_reporting = True \
        if 'n' not in raw_input("Would you like to automatically report errors to help improve the software? [y]/N: ").lower() \
        else False
    configuration._save_config(jira_url, username, password, error_reporting)

    try:
        connection.jira_connection(configuration.load_config())
    except jira_exceptions.JIRAError as e:
        configuration._delete_config()
        logging.error(
            "You have an error in your jira connection/configuration: {error}. Please fix the configuration before attempting to use jtime.\n We suggest trying your username without using the email address."
            .format(error=e))
Ejemplo n.º 4
0
 def test_load_config__NotConfigured(self):
     with self.assertRaises(custom_exceptions.NotConfigured):
         configuration.load_config()
Ejemplo n.º 5
0
def init():
    global configured, jira, git
    # Initialize the connectors
    configured = configuration.load_config()
    jira = connection.jira_connection(configured)
    git = git_ext.GIT()