Exemple #1
0
def test_catchphrase_present():
    with app.test_client() as test_client:
        response = test_client.get("/home")
        result = response.data.decode("utf-8")
    r_soup = BeautifulSoup(result, "html.parser")
    tag = r_soup.h1
    assert tag.string == "GrandPyBot raconte moi une histoire!"
Exemple #2
0
def test_mock_all_function_and_returns_no_page_id(monkeypatch):
    results = b'{"address":"test adresse",' \
              b'"error":"no pageid",' \
              b'"latlng":{"lat":1,"lng":2},' \
              b'"place":"test_lieu"}\n'
    client = app.test_client()

    def mock_parser(text):
        return "test_lieu"

    monkeypatch.setattr('app.routes.function_parser', mock_parser)

    def mock_get_location(place):
        return {'location': {'lat': 1, 'lng': 2}, 'address': 'test adresse'}

    monkeypatch.setattr('app.routes.get_location', mock_get_location)

    def mock_get_pageid(lat, long):
        return False

    monkeypatch.setattr('app.routes.get_pageid', mock_get_pageid)

    response = client.post('/Coord', data={"question": "test"})
    data = response.get_data()

    assert data == results
Exemple #3
0
 def setUp(self) -> None:
     app.config['TESTING'] = True
     app.config['DEBUG'] = False
     self.app = app.test_client()
     db.session.close()
     db.drop_all()
     db.create_all()
Exemple #4
0
 def setUp(self):
     """
     Function called when the class is initialized. Generates responses using the application test client for
     various endpoint inputs.
     """
     test_app = app.test_client()
     self.response_no_date_given = test_app.get("/analytics")
     self.response_date_given = test_app.get("/analytics?date=2019-08-01")
     # Try a Malformed date
     self.response_bad_date_given = test_app.get("/analytics?date=20219-028-222")
Exemple #5
0
 def _set_route(route, method='GET', data=dict):
     client = app.test_client()
     if method == 'GET':
         return client.get(route)
     if method == 'POST':
         return client.post(route, json=data)
     if method == 'PUT':
         return client.put(route, json=data)
     if method == 'DELETE':
         return client.delete(route)
Exemple #6
0
def test_mock_all_function_and_returns_no_place(monkeypatch):
    results = b'{"error":"no place"}\n'
    client = app.test_client()

    def mock_parser(value):
        return False

    monkeypatch.setattr('app.routes.function_parser', mock_parser)
    response = client.post('/Coord', data={"question": "test"})
    data = response.get_data()
    assert data == results
Exemple #7
0
def test_mock_all_function_and_returns_no_lat_long(monkeypatch):
    results = b'{"error":"no lat-lng","place":"test lieu"}\n'
    client = app.test_client()

    def mock_parser(text):
        return "test lieu"

    monkeypatch.setattr('app.routes.function_parser', mock_parser)

    def mock_get_location(place):
        return False

    monkeypatch.setattr('app.routes.get_location', mock_get_location)

    response = client.post('/Coord', data={"question": "test"})
    data = response.get_data()

    assert data == results
Exemple #8
0
def test_page_home_status_code_is_ok():
    with app.test_client() as test_client:
        response = test_client.get("/home")
        assert response.status_code == 200
Exemple #9
0
 def test_root(self):
     tester = app.test_client(self)
     response = tester.get('/')
     self.assertEqual(response.status_code, 200)
Exemple #10
0
 def test_register(self):
     tester = app.test_client(self)
     response = tester.get('/cohorts', content_type='html/test')
     self.assertEqual(response.status_code, 200)
Exemple #11
0
 def test_home(self):
     tester = app.test_client(self)
     response = tester.get('/index', content_type='html/text')
     self.assertEqual(response.status_code, 200)
Exemple #12
0
 def setUp(self):
     self.app = app.test_client()
     self.attrs_list = [
         'public_repos_count', 'forked_repos_count', 'followers_count',
         'original_repos_count', 'list_languages', 'repos'
     ]
Exemple #13
0
 def setUp(self):
     self.app = app.test_client()
Exemple #14
0
 def test_index(self):
     response = app.test_client().get('/')
     assert response.status_code == 200
Exemple #15
0
 def test_login(self):
     response = app.test_client().get('/')
     user = {'name': 'developer5', 'password': '******'}
     assert response.status_code == 200