class TestRegisterAndChangePassword(unittest.TestCase):
    client = app.test_client()

    @classmethod
    def setUpClass(cls):
        app.config['USERNAME'] = th.id_generator()
        app.config['PASSWORD'] = th.id_generator()
        app.config['NEWPASSWORD'] = th.id_generator()

    def test_change_password(self):
        rv = th.register(self.client, app.config['USERNAME'],
                         app.config['PASSWORD'], 'normal')
        print("register new user")
        assert b'{}', (app.config['USERNAME'], ) in rv.data
        th.change_password(self.client, app.config['PASSWORD'],
                           app.config['NEWPASSWORD'])
        th.logout(self.client)
        rv = th.login(self.client, app.config['USERNAME'],
                      app.config['NEWPASSWORD'])
        print("try to log in with new password")
        assert b'{}', (app.config['USERNAME'], ) in rv.data

    @classmethod
    def tearDownClass(cls):
        th.logout(cls.client)
        th.delete_from_sql(app.config['USERNAME'])
Exemple #2
0
def client():
    db_fd, app.config['DATABASE'] = tempfile.mkstemp()
    client = app.test_client()

    yield client

    os.close(db_fd)
    os.unlink(app.config['DATABASE'])
class TestRequestAccesptAndDenide(unittest.TestCase):
    client = app.test_client()

    @classmethod
    def setUpClass(cls):
        app.config['USERNAME'] = th.id_generator()
        app.config['PASSWORD'] = th.id_generator()
        th.register(cls.client, app.config['USERNAME'], app.config['PASSWORD'],
                    'normal')
        th.update_permission_in_sql(app.config['USERNAME'], 'Admin')

    @pytest.mark.run(order=1)
    def test_deny_admin_request(self):

        pass

    @classmethod
    def tearDownClass(cls):
        th.delete_from_sql(app.config['USERNAME'])
class AdminRegister(unittest.TestCase):
    client = app.test_client()

    @classmethod
    def setUpClass(cls):
        app.config['USERNAME'] = th.id_generator()
        app.config['PASSWORD'] = th.id_generator()
        th.register(cls.client, app.config['USERNAME'], app.config['PASSWORD'],
                    'normal')

    def test_admin(self):
        answer = th.update_permission_in_sql(app.config['USERNAME'], 'Admin')
        print(answer.content)
        rv = th.login(self.client, app.config['USERNAME'],
                      app.config['PASSWORD'])
        assert b'Requset Users' in rv.data

    @classmethod
    def tearDownClass(cls):
        th.logout(cls.client)
        th.delete_from_sql(app.config['USERNAME'])
Exemple #5
0
class AdminRegister(unittest.TestCase):
    client = app.test_client()

    @classmethod
    def setUpClass(cls):
        app.config['USERNAME'] = th.id_generator()
        app.config['PASSWORD'] = th.id_generator()
        th.register(cls.client, app.config['USERNAME'], app.config['PASSWORD'],
                    'normal', "*****@*****.**")

    def test_admin(self):
        answer = th.update_permission_in_sql(app.config['USERNAME'], 'Admin')
        assert answer['status'] == 'success'
        print(answer)
        rv = th.login(self.client, app.config['USERNAME'],
                      app.config['PASSWORD'])
        assert b'enter key sender to your email' in rv.data

    @classmethod
    def tearDownClass(cls):
        th.logout(cls.client)
        th.delete_from_sql(app.config['USERNAME'])
Exemple #6
0
 def setUp(self):
     app.config['WTF_CSRF_ENABLED'] = False
     self.app = app.test_client()
     self.login('12345678', 'hard2guess')
def client():
    """Start the fake server"""
    with app.test_client() as client:
        yield client
Exemple #8
0
 def setUp(self):
     app.config['WTF_CSRF_ENABLED'] = False
     self.app = app.test_client()
     self.login('12345678', 'hard2guess')
Exemple #9
0
 def setUp(self):
     app.config["CONTENT_ROOT"] = os.path.join(TEST_DATA_ROOT, u"content")
     app.config["CONFIG_ROOT"] = os.path.join(TEST_DATA_ROOT, u"config")
     app.config["TESTING"] = True
     self.app = app.test_client()
Exemple #10
0
def test_home() -> None:
    """The home view test method.
    Checks that the home route returns a correct http code 200"""
    client = app.test_client()
    response = client.get("/")
    assert response.status_code == 200
Exemple #11
0
 def setUp(self):
     self.app = app.test_client()
     self.app.testing = True
Exemple #12
0
 def setUp(self):
     app.config['CONTENT_ROOT'] = os.path.join(TEST_DATA_ROOT, u'content')
     app.config['CONFIG_ROOT'] = os.path.join(TEST_DATA_ROOT, u'config')
     self.app = app.test_client()
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     self.app = app.test_client()
     db.create_all()
Exemple #14
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['DEBUG'] = True
     self.app = app.test_client()