bc.request
Request
Mixin with the purpose of cover all the related with the request
Source code in breathecode/tests/mixins/breathecode_mixin/request.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
authenticate(user)
Forces authentication in a request inside a APITestCase.
Usage:
# setup the database
model = self.bc.database.create(user=1)
# that setup the request to use the credential of user passed
self.client.force_authenticate(model.user)
Keywords arguments:
- user: a instance of user model
breathecode.authenticate.models.User
Source code in breathecode/tests/mixins/breathecode_mixin/request.py
manual_authentication(user)
Generate a manual authentication using a token, this method is more slower than authenticate
.
# setup the database
model = self.bc.database.create(user=1)
# that setup the request to use the credential with tokens of user passed
self.bc.request.manual_authentication(model.user)
Keywords arguments:
- user: a instance of user model
breathecode.authenticate.models.User
.
Source code in breathecode/tests/mixins/breathecode_mixin/request.py
set_headers(**kargs)
Set headers.
# It set the headers with:
# Academy: 1
# ThingOfImportance: potato
self.bc.request.set_headers(academy=1, thing_of_importance='potato')
Source code in breathecode/tests/mixins/breathecode_mixin/request.py
sign_jwt_link(app, user_id=None, reverse=False, client=None)
Set Json Web Token in the request.
Usage:
# setup the database
model = self.bc.database.create(app=1, user=1)
# that setup the request to use the credential of user passed
self.bc.request.authenticate(model.app, model.user.id)
Keywords arguments:
- user: a instance of user model
breathecode.authenticate.models.User