Esempio n. 1
0
 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'
            }]
        }
Esempio n. 3
0
 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)
Esempio n. 4
0
 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"
     }
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)
Esempio n. 9
0
 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)
Esempio n. 10
0
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'
Esempio n. 11
0
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
     }
Esempio n. 13
0
 def setUp(self):
     self.test_client = app.test_client()
     self.user_register_data = {
         "name": "Kato",
         "email": "*****@*****.**",
         "password": "******"
     }
     self.user_login_data = {
         "email": "*****@*****.**",
         "password": "******"
     }
Esempio n. 14
0
 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})
Esempio n. 15
0
    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']
Esempio n. 16
0
    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'
        }
Esempio n. 17
0
 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)
Esempio n. 18
0
 def setUp(self):
     self.tester = app.test_client(self)
Esempio n. 19
0
 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"}
Esempio n. 20
0
 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)
Esempio n. 21
0
 def setUp(self):
     """Initialisez app and defines variables"""
     app.testing = True
     self.tester = app.test_client()
     self.database = Database()
     self.database.create_user_table()
Esempio n. 22
0
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
Esempio n. 24
0
 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)
Esempio n. 26
0
 def setUp(self):
     # create a test client
     self.app = app.test_client()
     self.app.testing = True
Esempio n. 27
0
 def setUp(self):
     app.config['TESTING'] = True
     self.app = app.test_client()
Esempio n. 28
0
def client():
    app.config['TESTING'] = True
    return app.test_client()