def test_login_required(self): base.base_authentication(self) response = self.client.post( '/api/v1.0/bucketlists/', data=json.dumps(dict( name="new bucketlist", )) ) data = json.loads(response.data.decode()) self.assertEqual(data['message'], 'Unauthorized Access!')
def test_get_bucketlist_by_id(self): user_token = base.base_authentication(self) base.base_add_bucketlist(self) response = self.client.get( '/api/v1.0/bucketlists/1/', headers={'Authorization': user_token}, ) self.assertIn('new bucketlist', str(response.data))
def test_update_item(self): user_token = base.base_authentication(self) base.base_add_item(self) update = self.client.put( '/api/v1.0/bucketlists/1/items/1/', data=json.dumps(dict(name="Climb mount kenya", )), headers={'Authorization': user_token}, ) data = json.loads(update.data.decode()) self.assertEqual(data['message'], 'Successfully updated the item')
def test_pass_invalid_parameter(self): user_token = base.base_authentication(self) response = self.client.post( '/api/v1.0/bucketlists/', data=json.dumps(dict( email="*****@*****.**" )), headers={'Authorization': user_token}, ) data = json.loads(response.data.decode()) self.assertEqual(data['message'], 'Invalid parameter entered')
def test_unnamed_bucetlist(self): user_token = base.base_authentication(self) response = self.client.post( '/api/v1.0/bucketlists/', data=json.dumps(dict( name="", )), headers={'Authorization': user_token}, ) data = json.loads(response.data.decode()) self.assertEqual(data['message'], 'Missing required parameters.')
def test_delete_bucketlist(self): user_token = base.base_authentication(self) base.base_add_bucketlist(self) response = self.client.delete( '/api/v1.0/bucketlists/1/', headers={'Authorization': user_token}, ) data = json.loads(response.data.decode()) self.assertEqual(data['message'], 'Bucketlist successfully deleted')
def test_add_existing_bucketlist(self): user_token = base.base_authentication(self) base.base_add_bucketlist(self) response = self.client.post( '/api/v1.0/bucketlists/', data=json.dumps(dict( name="new bucketlist", )), headers={'Authorization': user_token}, ) data = json.loads(response.data.decode()) self.assertEqual(data['message'], 'bucketlist already exists')
def test_update_bucketlist(self): user_token = base.base_authentication(self) base.base_add_bucketlist(self) response = self.client.put( '/api/v1.0/bucketlists/1/', data=json.dumps(dict( name="revised bucketlist" )), headers={'Authorization': user_token}, ) data = json.loads(response.data.decode()) self.assertEqual( data['message'], 'Successfully updated the bucketlist')