Esempio n. 1
0
    def test_signup_page_flow(self):
        # Check that things are empty
        self.assertLength(0, Profile.all())

        # Sign up with the form
        response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
        self.assertRedirects(response, self.uri_for('dashboard', tour=''))

        # Check that we are actually logged in
        response = self.app.get(response.location)
        self.assertLoggedIn()

        # Check that one of everything was created
        self.assertLength(1, Profile.all())

        profile = Profile.all().get()

        # Check the basic data
        self.assertEqual(self.SIGNUP_DATA['email'], profile.email)
        self.assertEqual(self.SIGNUP_DATA['name'], profile.name)

        # Logout and log back in to test that the password works
        self.logout()
        response = self.login(self.SIGNUP_DATA['email'],
                              self.SIGNUP_DATA['password'])
        self.assertRedirects(response, self.uri_for('dashboard'))
Esempio n. 2
0
  def test_signup_page_flow(self):
    # Check that things are empty
    self.assertLength(0, Profile.all())

    # Sign up with the form
    response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
    self.assertRedirects(response, self.uri_for('dashboard', tour=''))

    # Check that we are actually logged in
    response = self.app.get(response.location)
    self.assertLoggedIn()

    # Check that one of everything was created
    self.assertLength(1, Profile.all())

    profile = Profile.all().get()

    # Check the basic data
    self.assertEqual(self.SIGNUP_DATA['email'], profile.email)
    self.assertEqual(self.SIGNUP_DATA['name'], profile.name)

    # Logout and log back in to test that the password works
    self.logout()
    response = self.login(self.SIGNUP_DATA['email'],
                          self.SIGNUP_DATA['password'])
    self.assertRedirects(response, self.uri_for('dashboard'))
Esempio n. 3
0
    def test_signup_with_existing_email(self):
        response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
        self.assertRedirects(response)
        self.assertLength(1, Profile.all())

        response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
        self.assertOk(response)
        self.assertLength(1, Profile.all())

        email_field = response.pyquery('input#email')
        self.assertLength(1, email_field)
        self.assertNotEqual('', email_field.attr['data-error'])
Esempio n. 4
0
  def test_signup_with_existing_email(self):
    response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
    self.assertRedirects(response)
    self.assertLength(1, Profile.all())

    response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
    self.assertOk(response)
    self.assertLength(1, Profile.all())

    email_field = response.pyquery('input#email')
    self.assertLength(1, email_field)
    self.assertNotEqual('', email_field.attr['data-error'])
Esempio n. 5
0
    def test_signup_sends_welcome_email(self):
        # Sign up successfully
        response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
        self.assertRedirects(response, self.uri_for('dashboard', tour=''))

        # Check that a profile was created
        profile = Profile.get_by_email(self.SIGNUP_DATA['email'])
        self.assertIsNotNone(profile)

        # Check that a mail-sending task is in the queue
        tasks = self.taskqueue_stub.GetTasks('mail')
        self.assertLength(1, tasks)

        # Run the task (it should be a deferred call) and check that an e-mail
        # is sent
        task, = tasks
        deferred.run(base64.b64decode(task['body']))
        messages = self.mail_stub.get_sent_messages()
        self.assertLength(1, messages)

        message, = messages
        self.assertEqual('"%s" <%s>' % (profile.name, profile.email),
                         message.to)
        self.assertEqual('Welcome to Daily Meeting!', message.subject)
        self.assertEqual('"Daily Meeting" <*****@*****.**>',
                         message.sender)
        self.assertEqual(
            '"Daily Meeting Support" <*****@*****.**>',
            message.reply_to)
        activation_key = Profile.all().get().activation_key
        activation_url = self.uri_for('profile.activate', k=activation_key)
        self.assertIn(activation_url, message.body.decode())
        self.assertIn(activation_url, message.html.decode())
Esempio n. 6
0
  def test_signup_sends_welcome_email(self):
    # Sign up successfully
    response = self.app.post(self.uri_for('signup'), self.SIGNUP_DATA)
    self.assertRedirects(response, self.uri_for('dashboard', tour=''))

    # Check that a profile was created
    profile = Profile.get_by_email(self.SIGNUP_DATA['email'])
    self.assertIsNotNone(profile)

    # Check that a mail-sending task is in the queue
    tasks = self.taskqueue_stub.GetTasks('mail')
    self.assertLength(1, tasks)

    # Run the task (it should be a deferred call) and check that an e-mail
    # is sent
    task, = tasks
    deferred.run(base64.b64decode(task['body']))
    messages = self.mail_stub.get_sent_messages()
    self.assertLength(1, messages)

    message, = messages
    self.assertEqual('"%s" <%s>' % (profile.name, profile.email), message.to)
    self.assertEqual('Welcome to Daily Meeting!', message.subject)
    self.assertEqual('"Daily Meeting" <*****@*****.**>',
                     message.sender)
    self.assertEqual('"Daily Meeting Support" <*****@*****.**>',
                     message.reply_to)
    activation_key = Profile.all().get().activation_key
    activation_url = self.uri_for('profile.activate', k=activation_key)
    self.assertIn(activation_url, message.body.decode())
    self.assertIn(activation_url, message.html.decode())
Esempio n. 7
0
  def get(self):	
	path = os.path.join(os.path.dirname(__file__),
	                    '../views/admin/index.html')
	
	template_values = {
		'name': self.__class__.__name__,
		'profiles': Profile.all(),
	}
	
	self.response.out.write(template.render(path, template_values))
Esempio n. 8
0
 def list(self):
     editors = Profile.all().filter('is_editor = ', True)
     return self.render_to_response('editors/list.haml',
                                    {'editors': editors})
Esempio n. 9
0
 def get_profiles(self):
   return Profile.all().ancestor(self)
Esempio n. 10
0
 def get_profiles(self):
     return Profile.all().ancestor(self)
Esempio n. 11
0
 def list(self):
   editors = Profile.all().filter('is_editor = ', True)
   return self.render_to_response('editors/list.haml', {'editors': editors})