Exemplo n.º 1
0
def client() -> FlaskClient:
    app = Flask(__name__)
    ctx = app.app_context()
    ctx.push()
    app.register_blueprint(bp)
    client = app.test_client()
    return client
Exemplo n.º 2
0
 def test_login_as_visit(self):
     taster = app.test_client(self)
     rv = taster.post('/login',
                      data=dict(email="*****@*****.**", password="******"),
                      follow_redirects=True)
     rv = taster.get('/login', follow_redirects=True)
     self.assertFalse('משתמשים'.encode() in rv.data)
     rv = taster.get('/logout', follow_redirects=True)
Exemplo n.º 3
0
 def test_login_as_admin(self):
     taster = app.test_client(self)
     rv = taster.post('/login',
                      data=dict(email="*****@*****.**",
                                password="******"),
                      follow_redirects=True)
     rv = taster.get('/login', follow_redirects=True)
     rv = taster.get('/logout', follow_redirects=True)
     self.assertFalse('test'.encode() in rv.data)
Exemplo n.º 4
0
 def test_login_logout(self):
     taster = app.test_client(self)
     rv = taster.post('/login',
                      data=dict(email="*****@*****.**",
                                password="******"),
                      follow_redirects=True)
     self.assertTrue(rv.status, '200 OK')
     self.assertFalse('ברוכים'.encode() in rv.data)
     rv = taster.get('/logout', follow_redirects=True)
     self.assertFalse('התנתקת בהצלחה'.encode() in rv.data)
Exemplo n.º 5
0
 def test_falllogin(self):
     taster = app.test_client(self)
     print("hhhhhhhhhhhhhhhhhhhh")
     rv = taster.post('/login',
                      data=dict(email="*****@*****.**",
                                password="******"),
                      follow_redirects=True)
     rv = taster.get('/login', follow_redirects=True)
     self.assertTrue('משתמשים'.encode() in rv.data)
     rv = taster.get('/logout', follow_redirects=False)
Exemplo n.º 6
0
def client(request):
    app.config['TESTING'] = True
    client = app.test_client()

    def teardown():
        app.config['TESTING'] = False

    request.addfinalizer(teardown)

    return client
Exemplo n.º 7
0
    def setUp(self):
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
            os.path.join(app.config['BASEDIR'], TEST_DB)
        self.app = app.test_client()
        db.drop_all()
        db.create_all()

        # Disable sending emails during unit testing
        mail.init_app(app)
        self.assertEqual(app.debug, False)
Exemplo n.º 8
0
 def test_delete_user(self):
     taster = app.test_client(self)
     rv = taster.post('/register',
                      data=dict(email="*****@*****.**",
                                password="******",
                                name="test",
                                last="test"),
                      follow_redirects=True)
     rv = taster.post('/login',
                      data=dict(email="*****@*****.**", password="******"),
                      follow_redirects=True)
     rv = taster.post('/unregister',
                      data=dict(email="*****@*****.**", password="******"),
                      follow_redirects=True)
     rv = taster.post('/login',
                      data=dict(email="*****@*****.**", password="******"),
                      follow_redirects=True)
     self.assertFalse('שם משתמש או סיסמא לא נכונים'.encode() in rv.data)
Exemplo n.º 9
0
 def test_comment(self):
     taster = app.test_client(self)
     rv = taster.post('/register',
                      data=dict(email="*****@*****.**",
                                password="******",
                                name="test",
                                last="test"),
                      follow_redirects=True)
     rv = taster.post('/login',
                      data=dict(email="*****@*****.**", password="******"),
                      follow_redirects=True)
     rv = taster.post('/comments/פארק%20ליכטנשטיין',
                      data=dict(comment="test"),
                      follow_redirects=True)
     rv = taster.get('/comments/פארק%20ליכטנשטיין')
     self.assertFalse('test'.encode() in rv.data)
     rv = taster.post('/unregister',
                      data=dict(email="*****@*****.**", password="******"),
                      follow_redirects=True)
Exemplo n.º 10
0
 def test_add_admin(self):
     taster = app.test_client(self)
     rv = taster.post('/login',
                      data=dict(email="*****@*****.**",
                                password="******"),
                      follow_redirects=True)
     rv = taster.get('/login', follow_redirects=True)
     rv = taster.post('/registerByAdmin',
                      data=dict(name="טסט",
                                last="טסט",
                                email="*****@*****.**",
                                password="******",
                                Admin="true"),
                      follow_redirects=True)
     rv = taster.get('/logout', follow_redirects=True)
     rv = taster.post('/login',
                      data=dict(email="*****@*****.**", password="******"),
                      follow_redirects=True)
     self.assertFalse('ברוכים'.encode() in rv.data)
     rv = taster.post('/unregister',
                      data=dict(email="*****@*****.**", password="******"),
                      follow_redirects=True)
Exemplo n.º 11
0
 def setUp(self):
     app.testing = True
     self.app = app.test_client()
Exemplo n.º 12
0
 def setUpfall(self):
     app.testing = False
     self.app = app.test_client()
Exemplo n.º 13
0
 def test_home(self):
     tester = app.test_client(self)
     response = tester.get('/', content_type='html/text')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data, b'Hello World!')
Exemplo n.º 14
0
 def test_other(self):
     tester = app.test_client(self)
     response = tester.get('a', content_type='html/text')
     self.assertEqual(response.status_code, 404)
     self.assertTrue(b'does not exist' in response.data)