Exemplo n.º 1
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.tester = self.app.test_client()
     with self.app.app_context():
         db.drop_all()
         db.create_all()
         dummy_user()
Exemplo n.º 2
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.tester = self.app.test_client()
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.drop_all()
     db.create_all()
     dummy_post()
     dummy_post(is_published=False, slug='draft_dummy_post')
     dummy_user()
     add_social('Twitter', 'https://twitter.com/nytimes')
Exemplo n.º 3
0
    def test_someone_is_already_registered(self):
        """Testing that only one user can register as the admin.

        Will test that we are redirected away from the /register page if a
        registration already exist.
        """
        dummy_user()
        with self.app.test_client() as tester:
            response = tester.get('/register', follow_redirects=True)
            self.assertIn(b'Someone has already registered', response.data,
                          "Content of the response doesn't tell you that a "
                          "registration already occurred.")
            self.assertEqual(request.path, url_for('main.index'),
                             "Redirect to the /index page failed.")
Exemplo n.º 4
0
 def test_user(self):
     """Testing of the ``User`` class model.
     """
     user = dummy_user()
     query = User.query.get(1)
     self.assertEqual(query, user, "Adding user failed.")
     self.assertTrue(query.check_password('pass'),
                     "Checking the password failed.")
Exemplo n.º 5
0
 def test_load_user(self):
     """Testing that our function to load a user to flask login works.
     """
     user = dummy_user()
     loaded_user = load_user('1')
     self.assertEqual(user, loaded_user, "Adding new category failed.")