Skip to content

Commit

Permalink
Fixed the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ineentho committed May 24, 2015
1 parent 918844f commit b75d955
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions tests/base_test.py
Expand Up @@ -21,12 +21,13 @@ def tearDown(self):

# Utils used across all tests

def create_channel(self, slug='test-channel', password='test123'):
def create_channel(self, slug='test-channel', password='test123', hosted_by='undefined'):
return self.post_json('/channel/register', {
'name': 'test-channel',
'slug': slug,
'url': 'http://test-channel-servrer.opid.io/test-channel',
'password': password
'password': password,
'hosted-by': hosted_by
})

def create_video(self, slug='test-channel', password='test123', video_slug='video-slug', video_name='video_name'):
Expand Down
19 changes: 10 additions & 9 deletions tests/test_api_channel.py
Expand Up @@ -28,12 +28,12 @@ def test_register_name(self):
"""

# Too long name
rv = self.post_json('/channel/register', {'name': 'abc'*50, 'slug': 'a', 'url': 'a', 'password': 'a'})
rv = self.post_json('/channel/register', {'name': 'abc'*50, 'slug': 'a', 'url': 'a', 'password': 'a', 'hosted-by': 'a'})
self.assertIn(b'may not be longer than', rv.data)
self.assertEqual(rv.status_code, 400)

# No name parameter
rv = self.post_json('/channel/register', {'slug': 'a', 'url': 'a', 'password': 'a'})
rv = self.post_json('/channel/register', {'slug': 'a', 'url': 'a', 'password': 'a', 'hosted-by': 'a'})
self.assertIn(b'name is required', rv.data)
self.assertEqual(rv.status_code, 400)

Expand All @@ -43,17 +43,17 @@ def test_register_slug(self):
"""

# No slug parameter
rv = self.post_json('/channel/register', {'name': 'a', 'url': 'a', 'password': 'a'})
rv = self.post_json('/channel/register', {'name': 'a', 'url': 'a', 'password': 'a', 'hosted-by': 'a'})
self.assertIn(b'slug is required', rv.data)
self.assertEqual(rv.status_code, 400)

# Slug with invalid characters
rv = self.post_json('/channel/register', {'slug': 'C', 'name': 'a', 'url': 'a', 'password': 'a'})
rv = self.post_json('/channel/register', {'slug': 'C', 'name': 'a', 'url': 'a', 'password': 'a', 'hosted-by': 'a'})
self.assertIn(b'slug may only contain', rv.data)
self.assertEqual(rv.status_code, 400)

# Too long slug
rv = self.post_json('/channel/register', {'slug': 'a' * 100, 'name': 'a', 'url': 'a', 'password': 'a'})
rv = self.post_json('/channel/register', {'slug': 'a' * 100, 'name': 'a', 'url': 'a', 'password': 'a', 'hosted-by': 'a'})
self.assertIn(b'slug may not be longer than', rv.data)
self.assertEqual(rv.status_code, 400)

Expand All @@ -63,12 +63,12 @@ def test_register_url(self):
"""

# No url parameter
rv = self.post_json('/channel/register', {'name': 'a', 'slug': 'a', 'password': 'a'})
rv = self.post_json('/channel/register', {'name': 'a', 'slug': 'a', 'password': 'a', 'hosted-by': 'a'})
self.assertIn(b'url is required', rv.data)
self.assertEqual(rv.status_code, 400)

# Too long url
rv = self.post_json('/channel/register', {'url': 'a' * 300, 'name': 'a', 'slug': 'a', 'password': 'a'})
rv = self.post_json('/channel/register', {'url': 'a' * 300, 'name': 'a', 'slug': 'a', 'password': 'a', 'hosted-by': 'a'})
self.assertIn(b'url may not be longer than', rv.data)
self.assertEqual(rv.status_code, 400)

Expand All @@ -78,7 +78,7 @@ def test_register_password(self):
"""

# No password parameter
rv = self.post_json('/channel/register', {'name': 'a', 'slug': 'a', 'url': 'a'})
rv = self.post_json('/channel/register', {'name': 'a', 'slug': 'a', 'url': 'a', 'hosted-by': 'a'})
self.assertIn(b'password is required', rv.data)
self.assertEqual(rv.status_code, 400)

Expand All @@ -96,7 +96,8 @@ def test_valid_parameters(self):
'name': 'test-channel',
'slug': 'test-channel',
'url': 'http://test-channel-servrer.opid.io/test-channel',
'password': 'test123'
'password': 'test123',
'hosted-by': 'hosted-by'
})
self.assertIn(b'Channel created', rv.data)
self.assertEqual(rv.status_code, 200)
Expand Down

0 comments on commit b75d955

Please sign in to comment.