Exemple #1
0
 def test_negative_route_person(self):
     """Verify that the API returns error on wrong link for person favorite fruits and vegetables."""
     tester = APP.test_client(self)
     response = tester.get(
         "paranuara/persON/Decker%20Mckenzie", content_type="application/json"
     )
     self.assertNotEqual(response.status_code, 200)
    def setUp(self):
        APP.config['TESTING'] = True
        APP.config['DEBUG'] = False
        APP.config[
            'SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/transport_test'

        self.app = APP.test_client()

        DB.drop_all()
        DB.create_all()

        self.lifegoup1 = {
            'name': 'uq1',
            'password': '******',
            'email': '*****@*****.**'
        }
        self.lifegoup2 = {
            'name': 'uq2',
            'password': '******',
            'email': '*****@*****.**'
        }
        self.lifegoup3 = {
            'name': 'uq3',
            'password': '******',
            'email': '*****@*****.**'
        }

        DB.session.add(LifegroupModel(**self.lifegoup1))
        DB.session.add(LifegroupModel(**self.lifegoup2))
        DB.session.add(LifegroupModel(**self.lifegoup3))
        DB.session.commit()

        self.assertFalse(APP.debug)
Exemple #3
0
 def test_positive_route_person(self):
     """Verify that the API works for person favorite fruits and vegetables."""
     tester = APP.test_client(self)
     response = tester.get(
         "/paranuara/person/Decker%20Mckenzie", content_type="application/json"
     )
     self.assertEqual(response.status_code, 200)
Exemple #4
0
 def test_positive_route_company(self):
     """Verify that the API works for company employees."""
     tester = APP.test_client(self)
     response = tester.get(
         "/paranuara/company/COWTOWN", content_type="application/json"
     )
     self.assertEqual(response.status_code, 200)
def socketio_test1():
    """ Tests to see if server adds users properly """
    # log the user in through Flask test client
    flask_test_client = APP.test_client()
    # connect to Socket.IO without being logged in
    socketio_test_client = SOCKETIO.test_client(
        APP, flask_test_client=flask_test_client)
    # makes a connection to the client
    assert socketio_test_client.is_connected()
    #test data to see if function works
    data = {'joined': 'test'}
    #go through on connection to get your logged in player
    result1 = on_connection1(data)
    #tests adding second player
    data2 = {'joined': 'test2'}
    result2 = on_connection1(data2)
    #tests adding spectator
    data3 = {'joined': 'test3'}
    result3 = on_connection1(data3)
    print(result1, result2, result3)
    """we could see that it runs through th function put's test3 as a spectator
    and returns the login list of current added players"""
    assert result1 == result2
    assert not result1[0] == result2[1]
    assert not result3[2] == result2[1]
    assert not result3[2] == result1[0]
Exemple #6
0
    def setUp(self):
        APP.config['TESTING'] = True
        APP.config['WTF_CSRF_ENABLED'] = False
        self.app = APP.test_client()

        DB.Prod.delete_many({})
        DB.Logs.delete_many({})

        DB.User.insert_one({
            'name': 'Alice',
            'email': '*****@*****.**',
            'password': '******',
            'age': 22
        })

        DB.User.insert_one({
            'name': 'Bob',
            'email': '*****@*****.**',
            'password': '******',
            'age': 22
        })

        DB.User.insert_one({
            'name': 'Charlie',
            'email': '*****@*****.**',
            'password': '******',
            'age': 22
        })

        DB.Session.insert_one({
            'session_id': 'abcdefghijklmnopqrstuvwyzabcdef',
            'email': '*****@*****.**'
        })
Exemple #7
0
 def test_request_a_ride(self):
     """test to request a ride"""
     tester = APP.test_client(self)
     info = dict(rideID=4)
     response = tester.post('/v1/ride/4/request', data=json.dumps(info),
                            content_type="application/json")
     self.assertEqual(response.status_code, 200)
    def setUp(self):
        APP.config['TESTING'] = True
        APP.config['DEBUG'] = False
        APP.config[
            'SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/transport_test'

        self.app = APP.test_client()

        DB.drop_all()
        DB.create_all()

        self.lifegoup1 = {
            'name': 'uq1',
            'password': '******',
            'email': '*****@*****.**'
        }
        self.lifegoup2 = {
            'name': 'uq2',
            'password': '******',
            'email': '*****@*****.**'
        }
        self.lifegoup3 = {
            'name': 'uq3',
            'password': '******',
            'email': '*****@*****.**'
        }

        DB.session.add(LifegroupModel(**self.lifegoup1))
        DB.session.add(LifegroupModel(**self.lifegoup2))
        DB.session.add(LifegroupModel(**self.lifegoup3))
        DB.session.commit()

        self.member1 = {
            'id': '1',
            'lifegroup': 'uq1',
            'name': 'Kenneth Guo',
            'suburb': 'Sunnybank QLD, 4109'
        }
        self.member2 = {
            'id': '2',
            'lifegroup': 'uq2',
            'name': 'Ken Guo',
            'suburb': 'Sunnybank QLD, 4109'
        }
        self.note1 = {
            'id': '1',
            'lifegroup': 'uq1',
            'text': "A and B stay at the same place"
        }
        self.note2 = {
            'id': '2',
            'lifegroup': 'uq2',
            'text': "C and D stay at the same place"
        }
        DB.session.add(MemberModel(**self.member1))
        DB.session.add(MemberModel(**self.member2))
        DB.session.add(NoteModel(**self.note1))
        DB.session.add(NoteModel(**self.note2))
        DB.session.commit()
        self.assertFalse(APP.debug)
Exemple #9
0
 def setUp(self):
     with APP.app_context():
         self.app = APP.test_client()
         self.request_headers = RequestHeaders(
             {'Authorization': 'Bearer ' + AuthToken.generate('testsource')})
         self.log_file = 'test/fixtures/example-1.log'
         self.log_data = open(self.log_file, 'rb').read()
Exemple #10
0
    def test_get_all_request(self):
        """test get all requests"""

        tester = APP.test_client(self)
        response = tester.get('/api/v1/users/requests',
                              content_type='application/json')
        self.assertEqual(response.status_code, 200)
Exemple #11
0
    def setUp(self):
        APP.config['TESTING'] = True
        APP.config['WTF_CSRF_ENABLED'] = False
        self.app = APP.test_client()
        DB.Logs.delete_many({})

        DB.Session.insert_one({
            'session_id': 'abcdefghijklmnopqrstuvwyzabcdef',
            'email': '*****@*****.**'
        })

        DB.User.insert_one({
            'name': 'Test User',
            'email': '*****@*****.**',
            'password': '******',
            'age': 22,
            'genre': ['Mystery', 'Horror']
        })

        DB.User.insert_one({
            'name': 'Test User2',
            'email': '*****@*****.**',
            'password': '******',
            'age': 22,
            'genre': ['Mystery', 'Horror']
        })

        DB.User.insert_one({
            'name': 'weird name',
            'email': '*****@*****.**',
            'password': '******',
            'age': 22,
            'genre': ['Mystery', 'Horror']
        })
Exemple #12
0
 def test_negative_route_company(self):
     """Verify that the API returns error on wrong link for company employees."""
     tester = APP.test_client(self)
     response = tester.get(
         "/paranuara/companIES/COWTOWN", content_type="application/json"
     )
     self.assertNotEqual(response.status_code, 200)
 def setUp(self):
     with APP.app_context():
         self.app = APP.test_client()
         self.request_headers = RequestHeaders({
             'Authorization':
             'Bearer ' + AuthToken.generate('testsource')
         })
 def test_register(self):
     """ Hitting Register API """
     tester = APP.test_client(self)
     url = '/register?userName=Rutu&password=rotadu'
     response = tester.post(url, content_type="application/json")
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data.decode("UTF-8"),
                      "This UserName Already exists.")
 def test_logout(self):
     """ 
         A test for loading of the editrecipe page
         The url endpoint is;
             =>    /logout (get)
     """
     r = APP.test_client(self)
     return r.get('/logout', follow_redirects=True)
Exemple #16
0
 def test_positive_route_people(self):
     """Verify that the API works for the friends names."""
     tester = APP.test_client(self)
     response = tester.get(
         "/paranuara/people/?person1=Decker%20Mckenzie&person2=Rosemary%20Hayes",
         content_type="application/json",
     )
     self.assertEqual(response.status_code, 200)
 def test_url_not_in_form_data_post(self):
     """
         Asserts the endpoint fails when the url is not in the form data
     """
     with APP.test_client() as client:
         sent = {}
         result = client.post('/scrape_reviews', data=sent)
         self.assertEqual(result.status_code, 400)
Exemple #18
0
 def test_valid_user_registration(self):
     """test registration api"""
     tester = APP.test_client(self)
     info = dict(firstname="john", lastname="Smith", username="******",
                 password="******", gender="male", id=4)
     response = tester.post('/v1/register', data=json.dumps(info),
                            content_type="application/json")
     self.assertEqual(response.status_code, 200)
Exemple #19
0
 def test_create_a_ride(self):
     """test to create a ride"""
     tester = APP.test_client(self)
     info = dict(From="mukono", To="kampala", Time="4:00pm", Date="4/4/2018",
                 Driver_Username="******", Cost="4000", rideID=4)
     response = tester.post('/v1/create_ride', data=json.dumps(info),
                            content_type="application/json")
     self.assertEqual(response.status_code, 200)
Exemple #20
0
 def setUp(self):
     """Set up tests"""
     CATEGORIES.clear()
     self.user_email = "*****@*****.**"
     self.username = "******"
     self.user_password = "******"
     APP.config['TESTING'] = True
     self.test_app = APP.test_client()
 def test_url_is_not_restaurant_page_fails(self):
     """
         Asserts the endpoint fails when the url is a not a restaurant or review url
     """
     with APP.test_client() as client:
         sent = {"url": "www.google.com"}
         result = client.post('/scrape_reviews', data=sent)
         self.assertEqual(result.status_code, 400)
Exemple #22
0
 def test_negative_route_people(self):
     """Verify that the API returns error on wrong link for friends names."""
     tester = APP.test_client(self)
     response = tester.get(
         "paranuara//peOPle/person1=Decker%20Mckenzie&person2=Rosemary%20Hayes",
         content_type="application/json",
     )
     self.assertNotEqual(response.status_code, 200)
Exemple #23
0
 def setUp(self):
     """set up for each test"""
     APP.config['TESTING'] = True
     APP.config['WTF_CSRF_ENABLED'] = False
     self.test_app = APP.test_client()
     self.user_email = "*****@*****.**"
     self.username = "******"
     self.user_password = "******"
     self.user = User()
Exemple #24
0
 def setUp(self):
     """setting up all necessary variables"""
     self.driver = webdriver.PhantomJS()
     self.driver.set_window_size(1120, 550)
     APP.config['TESTING'] = True
     APP.config['WTF_CSRF_ENABLED'] = False
     APP.config['DEBUG'] = False
     APP.config['SERVER_NAME'] = "http://localhost:5000"
     self.APP = APP.test_client()
Exemple #25
0
def client(db):
    # create temp upload folder
    upload_dir = tempfile.mkdtemp()
    APP.config['UPLOAD_FOLDER'] = upload_dir

    yield APP.test_client()

    # delete temp upload folder
    shutil.rmtree(upload_dir)
 def test_signup(self):
     """ 
         A test for loading of the signup page
         The url endpoint is;
             =>    /signup (get, post)
     """
     tester = APP.test_client(self)
     response = tester.get('/signup', content_type='html/text')
     self.assertEqual(response.status_code, 200)
Exemple #27
0
def a_client():
    APP.config['TESTING'] = True
    disconnect()
    connect('mongoenginetest', host='mongomock://localhost')
    client = APP.test_client()

    yield client

    disconnect()
Exemple #28
0
 def test_create_user_missing_password(self):
     with app.test_client() as c:
         req_json = {
             'username': CORRECT_USERNAME_1,
             'email': CORRECT_EMAIL_1
         }
         repository.create_user = MagicMock(side_effect=KeyError)
         rv = c.post('/api/users', json=req_json)
         assert rv._status_code == 400
 def test_get(self):
     """ Hitting GET API """
     tester = APP.test_client(self)
     test_jwt_tocken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRlc3RpbmdfdXNlciJ9.se88Y8n4MxTRSVmC3UFVLOnTwYj5h1s_mN_tWSSP_L0"
     response = tester.get('/?userName=testing_user&jwt=' + test_jwt_tocken,
                           content_type="application/json")
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data.decode("UTF-8"),
                      "username = testing_user\nData : \ntesting_data")
 def test_home(self):
     """ 
         A test for loading of the home page
         The url endpoint is;
             =>    /index (get)
     """
     tester = APP.test_client(self)
     response = tester.get('/index', content_type='html/text')
     self.assertEqual(response.status_code, 200)
 def test_addcategory(self):
     """ 
         A test for loading of the addcategory page
         The url endpoint is;
             =>    /addcategory (get, post)
     """
     tester = APP.test_client(self)
     response = tester.get('/addcategory', content_type='html/text')
     self.assertEqual(response.status_code, 302)
Exemple #32
0
	def test_default_route(self):  
		tester = APP.test_client(self)
		response = tester.get('/', content_type='application/json')

		# Check 200 response from default route
		self.assertEqual(response.status_code, 200)

		# Check default route message output
		self.assertEqual(json.loads(response.data.decode('utf-8')), 
			{
			    "message" : "Hello pythonistic world"
			}
		)

		# Check number of characters in message
		response.json = json.loads(response.data.decode('utf-8'))
		self.assertEqual(len(response.json['message']), 23)
 def setUp(self):
     app_de_teste.config['TESTING'] = True
     app_de_teste.config['WTF_CSRF_ENABLED'] = False
     app_de_teste.config['DEBUG'] = False
     self.app = app_de_teste.test_client()
Exemple #34
0
 def setUp(self):
     APP.config["TESTING"] = True
     self.app = APP.test_client()