Example #1
0
 def test_link_endpoint_malformed_url(self):
     # a bad URL
     test_url = ""
     with app.test_client() as request:
         response = request.post("/api/link", json={"url": test_url})
         response_json = response.get_json()
         assert response_json["status"] == 1
Example #2
0
    def setUp(self):
        self.client = app.test_client()
        db.create_all()

        # log in as viewer
        login_response = test_utils.create_user_and_login(username='******',
                                                          password='******',
                                                          role='viewer',
                                                          client=self.client)
        login_response_dict = json.loads(login_response.data)
        self.viewer_token = login_response_dict['access_token']

        # log in as writer
        login_response = test_utils.create_user_and_login(username='******',
                                                          password='******',
                                                          role='writer',
                                                          client=self.client)
        login_response_dict = json.loads(login_response.data)
        self.writer_token = login_response_dict['access_token']

        # log in as admin
        login_response = test_utils.create_user_and_login(username='******',
                                                          password='******',
                                                          role='admin',
                                                          client=self.client)
        login_response_dict = json.loads(login_response.data)
        self.admin_token = login_response_dict['access_token']
Example #3
0
 def test_link_endpoint_proper_url(self):
     # a good URL
     test_url = "https://www.google.com"
     with app.test_client() as request:
         response = request.post("/api/link", json={"url": test_url})
         response_json = response.get_json()
         assert response_json["status"] == 0
Example #4
0
        def setUp(self) -> None:
            config = Config()
            MongoClient(host=config.get_dbhost(), port=config.get_dbport(), database='amazondashtest')
            app.config['TESTING'] = True
            app.config['WTF_CSRF_ENABLED'] = False
            app.config['DEBUG'] = False

            self.app = app.test_client()
def test_client():
    testing_client = flask_app.test_client()
    # Establish an application context before running the tests.
    ctx = flask_app.app_context()
    ctx.push()

    yield testing_client  # this is where the testing happens!

    ctx.pop()
def client():
    db_fd, app.config['DATABASE'] = tempfile.mkstemp()
    app.config['TESTING'] = True

    with app.test_client() as client:
        yield client

    os.close(db_fd)
    os.unlink(app.config['DATABASE'])
Example #7
0
 def test_missing_query_params(self):
     """ Test missing query params returns error and error message """
     tester = app.test_client(self)
     response = tester.get(DUMMY_ROUTE_MISSING)
     self.assertEqual(response.status_code, 400)
     self.assertTrue(b'error' in response.data)
Example #8
0
 def test_incorrect_query_params(self):
     """ Test incorrect query params returns error and error message """
     tester = app.test_client(self)
     response = tester.get(DUMMY_ROUTE_INCORRECT)
     self.assertEqual(response.status_code, 400)
     self.assertTrue(b'error' in response.data)
Example #9
0
 def test_response_data(self):
     """ Test response data contains sections i.e format is correct """
     tester = app.test_client(self)
     response = tester.get(DUMMY_ROUTE)
     self.assertTrue(b'sections' in response.data)
Example #10
0
 def test_response_type(self):
     """ Test response type is JSON """
     tester = app.test_client(self)
     response = tester.get(DUMMY_ROUTE)
     self.assertEqual(response.content_type, "application/json")
Example #11
0
def client():
    db_fd, app.config['DATABASE'] = tempfile.mkstemp()
    app.config['TESTING'] = True
    with app.test_client() as client:
        yield client
Example #12
0
 def setUp(self):
     super().setUp()
     self.client = app.test_client()
     db.create_all()
Example #13
0
 def setUp(self):
     self.app = app.test_client()
     self.access_token = self.token()
Example #14
0
 def setUp(self):
     self.client = app.test_client()
     db.create_all()
Example #15
0
def client():
    app.config['TESTING'] = True
    client = app.test_client()
    yield client
Example #16
0
 def setUp(self):
     # self.app = configure_app(app, 'testing')
     self.app = app.test_client()
     self.access_token = self.token()
 def test_link_endpoint_proper_url(self):
     with app.test_client() as request:
         response = request.get("/api/health")
         response_json = response.get_json()
         assert response_json["status"] == 0
Example #18
0
 def test_index(self):
     """ Test that Flask returns endpoint """
     tester = app.test_client(self)
     response = tester.get(DUMMY_ROUTE)
     self.assertEqual(response.status_code, 200)
Example #19
0
def client():
    client = app.test_client()
    return client
Example #20
0
def client():
    from backend.app import app
    app.config["TESTING"] = True
    with app.test_client() as client:
        yield client