Example #1
0
 def test_remove_favourite_with_not_added_favourite(self):
     """ Testing API's remove a favourite when the show wasn't added to favourites """
     with self.client:
         resp_register = register_user(self, '*****@*****.**', '123456')
         response = remove_favourite(
             self, 69740,
             json.loads(resp_register.data.decode())['auth_token'])
         data = json.loads(response.data.decode())
         self.assertTrue(data['status'] == 'fail')
         self.assertEqual(response.status_code, 500)
Example #2
0
 def test_add_favourite(self):
     """ Testing API's add a favourite """
     with self.client:
         resp_register = register_user(self, '*****@*****.**', '123456')
         response = add_favourite(
             self, 69740,
             json.loads(resp_register.data.decode())['auth_token'])
         data = json.loads(response.data.decode())
         self.assertTrue(data['status'] == 'success')
         self.assertEqual(response.status_code, 200)
Example #3
0
 def test_delete_job(self):
     user = register_user(self, '*****@*****.**', '123456')
     job = send_job(self, user)
     userdata = json.loads(user_data(self, user).data.decode())
     response = self.client.delete(
         '/users/{}/offers/{}'.format(userdata["data"]["user_id"], 1),
         headers=dict(Authorization='Bearer ' +
                      json.loads(user.data.decode())['auth_token']))
     data = json.loads(response.data.decode())
     self.assertTrue(data['status'] == 'success')
     self.assertEqual(response.status_code, 200)
Example #4
0
 def test_secured_hello_world_with_user_from_auth(self):
     with self.client:
         token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOiIxMTExMSIsIlVzZXJuYW1lIjoidGVzdEFkbWluIn0.9VgNkIVQgCluHUQgpit8YQp0WaZf5q3F_h7GcdMqLJ0'
         User.delete_one('testAdmin')
         resp_register = register_user(self, 'testAdmin', '*****@*****.**',
                                       'password2')
         response = self.client.get('/hello_secured?user=me',
                                    headers=dict(Authorization='Bearer ' +
                                                 token))
         data = json.loads(response.data.decode())
         self.assertTrue(data is not None)
         self.assertTrue(data['hello'] == 'world me')
         self.assertEqual(response.status_code, 200)
         User.delete_one('joe')
Example #5
0
 def test_secured_hello_world1(self):
     with self.client:
         User.delete_one('joe')
         resp_register = register_user(self, 'joe', '*****@*****.**',
                                       '123456')
         response = self.client.get(
             '/hello_secured?user=me',
             headers=dict(
                 Authorization='Bearer ' +
                 json.loads(resp_register.data.decode())['auth_token']))
         data = json.loads(response.data.decode())
         self.assertTrue(data is not None)
         self.assertTrue(data['hello'] == 'world me')
         self.assertEqual(response.status_code, 200)
         User.delete_one('joe')
Example #6
0
 def test_add_job(self):
     with self.client:
         user = register_user(self, '*****@*****.**', '123456')
         response = self.client.post(
             '/users/{}/offers'.format(1),
             headers=dict(Authorization='Bearer ' +
                          json.loads(user.data.decode())['auth_token']),
             data=json.dumps(
                 dict(user_id=1, title="Titre", description="description")),
             content_type='application/json',
         )
         data = json.loads(response.data.decode())
         self.assertTrue(data['status'] == 'success')
         self.assertTrue(data['message'] == 'Successfully added.')
         self.assertEqual(response.status_code, 200)
Example #7
0
 def test_list_favourites(self):
     """ Testing API's list a user's all favourite shows """
     with self.client:
         resp_register = register_user(self, '*****@*****.**', '123456')
         auth_token = json.loads(resp_register.data.decode())['auth_token']
         add_favourite(self, 69740, auth_token)
         response = self.client.get(
             '/user/favourites',
             headers={'Authorization': 'Bearer ' + auth_token})
         data = json.loads(response.data.decode())
         self.assertEqual(response.status_code, 200)
         self.assertTrue(data['status'] == 'success')
         self.assertTrue(len(data['results']) > 0)
         show = data['results'].pop()
         self.assertTrue(show['tmdb_id'])
         self.assertEqual(show['name'], 'Ozark')
Example #8
0
 def test_edit_job(self):
     user = register_user(self, '*****@*****.**', '123456')
     job = send_job(self, user)
     userdata = json.loads(user_data(self, user).data.decode())
     response = self.client.put(
         '/users/{}/offers/{}'.format(userdata["data"]["user_id"], 1),
         headers=dict(Authorization='Bearer ' +
                      json.loads(user.data.decode())['auth_token']),
         data=json.dumps(
             dict(user_id=userdata["data"]["user_id"],
                  title="Titre info",
                  description="description changé")),
         content_type='application/json',
     )
     data = json.loads(response.data.decode())
     self.assertTrue(data['status'] == 'success')
     self.assertEqual(response.status_code, 200)