# Path: common/tests.py
# class CommonViewTest(base.ViewTestCase):
# class UtilTestCase(test.TestCase):
#   def test_redirect_slash(self):
#   def test_confirm(self):
#   def test_get_user_from_topic(self):


from common import messages
from common import profile
from common import util
from common.tests import ViewTestCase

class ChannelJoinTest(ViewTestCase):
  def test_join_channel(self):
    self.login('annoying')  # pick a user that is NOT a member
    r = self.client.post('/channel/popular',
                         {'nick': 'annoying@example.com',
                          'channel_join': '',
                          'channel' : '#popular@example.com',
                          '_nonce' : 
                              util.create_nonce('annoying', 'channel_join'),
                          }
                         )
    r = self.assertRedirectsPrefix(r, '/channel/popular')
    self.assertContains(r, 'You have joined')
    self.assertWellformed(r)

  def test_join_channel_already_member(self):
    self.login('popular')  # pick a user that is a member
    r = self.client.post('/channel/popular',
                         {'nick': 'popular@example.com',
                          'channel_join': '',
                          'channel' : '#popular@example.com',
                          '_nonce' : 
                              util.create_nonce('popular', 'channel_join'),
                          }
                         )    
    self.assertContains(r, 'already a member')
    self.assertWellformed(r)



# Path: common/tests.py
# class CommonViewTest(base.ViewTestCase):
# class UtilTestCase(test.TestCase):
#   def test_redirect_slash(self):
#   def test_confirm(self):
#   def test_get_user_from_topic(self):


# Path: channel/tests.py
from common import messages
from common import profile
from common import util
from common.tests import ViewTestCase


class ChannelJoinTest(ViewTestCase):
  def test_join_channel(self):
    self.login('annoying')  # pick a user that is NOT a member
    r = self.client.post('/channel/popular',
                         {'nick': 'annoying@example.com',
                          'channel_join': '',
                          'channel' : '#popular@example.com',
                          '_nonce' : 
                              util.create_nonce('annoying', 'channel_join'),
                          }
                         )
    r = self.assertRedirectsPrefix(r, '/channel/popular')
    self.assertContains(r, 'You have joined')
    self.assertWellformed(r)

  def test_join_channel_already_member(self):
    self.login('popular')  # pick a user that is a member
    r = self.client.post('/channel/popular',
                         {'nick': 'popular@example.com',
                          'channel_join': '',
                          'channel' : '#popular@example.com',
                          '_nonce' : 
                              util.create_nonce('popular', 'channel_join'),
                          }
                         )    
    self.assertContains(r, 'already a member')
    self.assertWellformed(r)



class ChannelDeleteTest(ViewTestCase):