Esempio n. 1
0
    def test_set_config(self):
        expected_conf = {
            "url": "http://abc",
            "smtpServer": "abc",
            "smtpUser": "******",
            "toEmail": "abc",
            "smtpPw": "Password",
        }

        with mock.patch("__builtin__.raw_input", return_value="abc"):
            with mock.patch("getpass.getpass", return_value="Password"):
                self.assertEquals(expected_conf["url"], set_config()["url"])
                self.assertEquals(
                    expected_conf["smtpServer"], set_config()["smtpServer"])
                self.assertEquals(
                    expected_conf["smtpUser"], set_config()["smtpUser"])
                self.assertEquals(
                    expected_conf["toEmail"], set_config()["toEmail"])
                self.assertEquals(
                    expected_conf["smtpPw"], set_config()["smtpPw"])
Esempio n. 2
0
def main(argv):
    
    if len(sys.argv) == 1:
        conf = set_config()
        s_pw = conf["smtpPw"]
        write_config(conf)
    else:
        """if exist argv, set password and execute with default configure"""
        s_pw = extract_password_with_argv(argv)
        conf = read_config()
        
    conf["smtpPw"] = s_pw
    smtp_login_with_conf_test(conf)

    checker(conf)