def test_choose_blog_decline(self): ChooseBlog(self.request, self.response).finish(None) self.assertEquals(0, Medium.query().count()) self.assertEquals(302, self.response.status_int) self.assertEquals( "http://localhost/#!OK, you're not signed up. Hope you reconsider!", urllib.unquote_plus(self.response.headers['Location']))
def test_choose_blog_decline(self): with app.test_request_context(): with self.assertRaises(RequestRedirect) as rr: ChooseBlog('/unused').finish(None) self.assertEqual(0, Medium.query().count()) self.assertEqual(302, rr.exception.code) self.assertEqual('http://localhost/', rr.exception.new_url) self.assertEqual( ["OK, you're not signed up. Hope you reconsider!"], get_flashed_messages())
def test_choose_blog_publications(self): self.expect_get_publications(PUBLICATIONS) ChooseBlog(self.request, self.response).finish(self.auth_entity) self.assert_equals(200, self.response.status_code) for expected in ('action="/medium/add" method="post"', '<input type="radio" name="blog" id="@ry"', '<input type="radio" name="blog" id="b969ac62a46b"', '<input type="radio" name="blog" id="b45573563f5a"', ): self.assertIn(expected, self.response.text) self.assertEquals(0, Medium.query().count())
def assert_created_publication(self, medium=None): if not medium: mediums = list(Medium.query()) self.assertEquals(1, len(mediums)) medium = mediums[0] self.assertEquals('b45573563f5a', medium.key.id()) self.assertEquals(self.auth_entity.key, medium.auth_entity) self.assertEquals('Developers', medium.name) self.assertEquals('https://medium.com/developers', medium.url) self.assertEquals('https://developers/image.png', medium.picture) self.assertTrue(medium.is_publication()) self.assertEquals('https://medium.com/feed/developers', medium.feed_url()) self.assertEquals('https://medium.com/developers', medium.silo_url())
def assert_created_profile(self, medium=None): if not medium: mediums = list(Medium.query()) self.assertEquals(1, len(mediums)) medium = mediums[0] self.assertEquals('@ry', medium.key.id()) self.assertEquals(self.auth_entity.key, medium.auth_entity) self.assertEquals('Ryan', medium.name) self.assertEquals('http://medium.com/@ry', medium.url) self.assertEquals('http://ava/tar', medium.picture) self.assertFalse(medium.is_publication()) self.assertEquals('http://medium.com/feed/@ry', medium.feed_url()) self.assertEquals('http://medium.com/@ry', medium.silo_url())
def test_choose_blog_publications(self): self.expect_get_publications(PUBLICATIONS) with app.test_request_context(): resp = ChooseBlog('/unused').finish(self.auth_entity) for expected in ( 'action="/medium/add" method="post"', '<input type="radio" name="blog" id="@RY"', '<input type="radio" name="blog" id="b969ac62a46b"', '<input type="radio" name="blog" id="b45573563f5a"', ): self.assertIn(expected, resp) self.assertEqual(0, Medium.query().count())