Beispiel #1
0
def main():
    while True:
        try:
            email_client = GmailClient(Configuration.get_email_address(), Configuration.get_password())
            task = raw_input("What task? ")
            TaskMailer(task=task, email_client=email_client).send()
            print  "Task sent successfully!"
        except MissingTaskException:
            print "Seriously we need a task..."
        except EmailNotSetException:
            Configuration.set_email_address(raw_input("We need your GMail username.  What is it? "))
        except PasswordNotSetException:
            Configuration.set_password(raw_input("We need your GMail password.  Give it up! "))
        except BadUsernamePasswordException:
            Configuration.set_password(raw_input("Google said your password was garbage. Want to try a new one? "))
        except CorruptConfigFileException:
            sys.stderr.write("Your config is corrupt.  Why don't you fix it? ")
            return
 def setUp(self):
     Configuration.gateway = InMemoryConfigFileGateway()
     Configuration.set_email_address('*****@*****.**')
 def test_updating_config_does_not_override_other_entries(self):
     Configuration.set_password('existed')
     Configuration.set_email_address('some_attribute_value')
     self.assertEquals('some_attribute_value', Configuration.get_email_address())
     self.assertEquals('existed', Configuration.get_password())
     
 def test_can_set_config_value_on_empty_file(self):
     Configuration.set_email_address('some_attribute_value')
     self.assertEquals('some_attribute_value', Configuration.get_email_address())