Пример #1
0
 def test_choose_blog_no_publications(self):
   self.expect_get_publications({})
   ChooseBlog(self.request, self.response).finish(self.auth_entity)
   self.assertEquals(302, self.response.status_int)
   loc = urllib.unquote_plus(self.response.headers['Location'])
   self.assertTrue(loc.startswith('http://localhost/'), loc)
   self.assert_created_profile()
Пример #2
0
 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']))
Пример #3
0
    def test_choose_blog_no_publications(self):
        self.expect_get_publications({})

        with app.test_request_context():
            with self.assertRaises(RequestRedirect) as rr:
                ChooseBlog('/unused').finish(self.auth_entity)
            self.assertEqual(302, rr.exception.code)
            self.assertEqual('http://localhost/medium/@ry',
                             rr.exception.new_url)
            self.assert_created_profile()
Пример #4
0
 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())
Пример #5
0
  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())
Пример #6
0
    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())