def get_user_token(): user = { 'username': '******', 'email': '*****@*****.**', 'password': '******', 'role': 'admin' } response = app.test_client().post('/api/v1/auth/signup', data=user) response = app.test_client().post('/api/v1/auth/login', data=user) token = json.loads(response.data)['token'] return token
def setUp(self): self.app = app.test_client() self.app.testing = True self.weather_data = { "currently": { "time": 1580260089, "summary": "Mostly Cloudy", "temperature": 60.28, "humidity": 0.97, "windSpeed": 3.72, "cloudCover": 0.85, "visibility": 10, "pressure": 1013.8 }, "hourly": { "summary": "Possible light rain starting this evening, continuing until tomorrow morning." }, "daily": { "summary": "Rain throughout the week." }, "timezone": "Africa/Nairobi" } self.location_data = { "results": [{ "geometry": { "location": { "lat": -1.2920659, "lng": 36.8219462 } }, "formatted_address": 'Nairobi, Kenya' }] }
def test_wrong_input_nsd(self): tester = app.test_client(self) filename_version = 'tester.yaml' response = tester.post('/on-board-nsd', data={'filedat': open(filename_version)}) self.assertEqual(response.status_code, 200) expected_msg = 'An error with input parameter.' self.assertEqual(response.data, expected_msg)
def setUp(self): self.test_client = app.test_client() self.diary_entry_data={ "diaryTitle": "wedding Dm", "date": "1/2/2017", "diaryEntryBody": "This some message for the entry in the diary", "entry_id": "1" }
def test_not_allowed_file_nsd(self): tester = app.test_client(self) test_file = 'tester.py' response = tester.post('/on-board-nsd', data={'nsd_file': open(test_file)}) self.assertEqual(response.status_code, 200) expected_msg = 'tester.py is not a "yaml" file.' self.assertEqual(response.data, expected_msg)
def setUp(self): tester = app.test_client(self) test_file = 'tester.yaml' response = tester.post('/on-board-nsd', data={'nsd_file': open(test_file)}) self.assertEqual(response.status_code, 200) expected_msg = 'SUCCESS' self.assertEqual(response.data, expected_msg)
def test_wrong_nsd_name_version_enable_nsd(self): tester = app.test_client(self) filename_version = 'tester.yaml_1.0' response = tester.post('/enable-nsd', data={'nsd_name_vesion': filename_version}) self.assertEqual(response.status_code, 200) expected_msg = 'An error with input parameter.' self.assertEqual(response.data, expected_msg)
def tearDown(self): tester = app.test_client(self) filename_version = 'tester.yaml_1.0' response = tester.post('/delete-nsd', data={'nsd_name_version': filename_version}) self.assertEqual(response.status_code, 200) expected_msg = 'NSD Deleted' self.assertEqual(response.data, expected_msg)
def test_no_package_enable_nsd(self): tester = app.test_client(self) filename_version = 'test.yaml_1.0' response = tester.post('/enable-nsd', data={'nsd_name_version': filename_version}) self.assertEqual(response.status_code, 200) expected_msg = 'No NSD of given ID is found' self.assertEqual(response.data, expected_msg)
def test_home(): """ GIVEN a return text WHEN the landing page is hit THEN ensure hello world! is returned """ response = app.test_client().get('/') assert response.status_code == 200 assert response.data == b'hello world'
def test_status(): """ GIVEN check for metadata WHEN the metadata endpoint is hit THEN json payload with metadata is returned """ response = app.test_client().get('/meta') assert response.status_code == 200 assert b"version" in response.data assert b"description" in response.data assert b"lastcommitsha" in response.data
def setUp(self): self.client = app.test_client(self) self.test_data_question1 = dict(question='Test question 1') self.test_data_question2 = dict(question='Test question 2') self.test_data_question3 = dict(question='Test question 3') self.test_data_answer = { "date_posted": "Fri, 03 Aug 2018 00:00:00 GMT", "answer": "Test answer 1", "id": 1, "question_id": 1 }
def setUp(self): self.test_client = app.test_client() self.user_register_data = { "name": "Kato", "email": "*****@*****.**", "password": "******" } self.user_login_data = { "email": "*****@*****.**", "password": "******" }
def test_update_nsd(self): tester = app.test_client(self) test_file = 'tester.yaml' response = tester.post('/update-nsd', data={'nsd_file': open(test_file)}) self.assertEqual(response.status_code, 200) expected_msg = 'NSD Updated' self.assertEqual(response.data, expected_msg) filename_version = 'tester.yaml_2.0' response = tester.post('/delete-nsd', data={'nsd_name_version': filename_version})
def setUp(self): self.client = app.test_client(self) # RUN 'set APP_SETTINGS=testing' to set testing environment (for database) self.database_obj = Database(app) # get Authorization token (used for all protected endpoints) signup_response = self.client.post('/api/v1/auth/signup', data=json.dumps( TestData.user_data2), content_type='application/json') token_json_dict = json.loads(signup_response.data.decode()) self.access_token = token_json_dict['access_token']
def setUp(self): """Initialisez app and defines variables""" app.testing = True self.tester = app.test_client() self.database = DatabaseConnection() self.database.create_user_table() self.user = { 'username': '', 'email': '*****@*****.**', 'password': '******', 'role': 'user' }
def test_enable_and_disable_NSD(self): tester = app.test_client(self) filename_version = 'tester.yaml_1.0' response = tester.post('/enable-nsd', data={'nsd_name_version': filename_version}) self.assertEqual(response.status_code, 200) expected_msg = "NSD Enabled" self.assertEqual(response.data, expected_msg) response = tester.post('/enable-nsd', data={'nsd_name_version': filename_version}) self.assertEqual(response.status_code, 200) expected_msg = "NSD is already Enabled" self.assertEqual(response.data, expected_msg) response = tester.post('/disable-nsd', data={'nsd_name_version': filename_version}) self.assertEqual(response.status_code, 200) expected_msg = "NSD Disabled" self.assertEqual(response.data, expected_msg) response = tester.post('/disable-nsd', data={'nsd_name_version': filename_version}) self.assertEqual(response.status_code, 200) expected_msg = "NSD is already Disabled" self.assertEqual(response.data, expected_msg)
def setUp(self): self.tester = app.test_client(self)
def setUp(self): self.client = app.test_client() self.test_order = {"order":"matooke"} self.test_order2 = {"order":"rice"} self.test_order3 = {"order":"chips"} self.test_status1 = {"completed_status":"yes"}
def test_no_input_disable_nsd(self): tester = app.test_client(self) response = tester.post('/disable-nsd', data={}) self.assertEqual(response.status_code, 200) expected_msg = 'An error with input parameter.' self.assertEqual(response.data, expected_msg)
def setUp(self): """Initialisez app and defines variables""" app.testing = True self.tester = app.test_client() self.database = Database() self.database.create_user_table()
class rides_test(unittest.TestCase): app.app_context().push() client = app.test_client()
def test_signup(): data = {"username": "******", "password": "******"} test_client = app.test_client() response = test_client.post('/signup', json=data) assert response.status_code == 201
def setUp(self): # creates a test client self.app = app.test_client() # propagate the exceptions to the test client self.app.testing = True
'consist', 'land', 'exuberant', 'kitty', 'party', 'meddle', 'ants', 'weather', 'gaping', 'letter', 'friends', 'harmonious', 'command', 'rice', 'calculate', 'oval', 'hop', 'wacky', 'damaging', 'temporary', 'grip', 'sail', 'political', 'frightening', 'superficial', 'advise', 'unequaled', 'long', 'soap', 'start', 'mixed', 'scarce', 'guide', 'things', 'verse', 'early', 'sharp', 'teeny', 'discover', 'hair', 'humorous', 'tall', 'boundary', 'synonymous', 'flowers', 'receive', 'efficient', 'special', 'condemned', 'blood', 'stingy', 'downtown', 'shape', 'mint', 'diligent', 'big', 'spray', 'brown', 'tour', 'stretch', 'pass', 'depressed', 'trouble', 'clap' ] app.config['WTF_CSRF_ENABLED'] = False PASS = '******' test_client = app.test_client() def get_all_post_id(): query = """ MATCH (p:Post) RETURN COLLECT(p.id) """ return graph.run(query).evaluate() def like_post(post_id): return test_client.post('/like-post', data=dict(post_id=post_id), follow_redirects=True)
def setUp(self): # create a test client self.app = app.test_client() self.app.testing = True
def setUp(self): app.config['TESTING'] = True self.app = app.test_client()
def client(): app.config['TESTING'] = True return app.test_client()