| 64 | redis_connection.flushdb() |
| 65 | |
| 66 | def make_request( |
| 67 | self, |
| 68 | method, |
| 69 | path, |
| 70 | org=None, |
| 71 | user=None, |
| 72 | data=None, |
| 73 | is_json=True, |
| 74 | follow_redirects=False, |
| 75 | ): |
| 76 | if user is None: |
| 77 | user = self.factory.user |
| 78 | |
| 79 | if org is None: |
| 80 | org = self.factory.org |
| 81 | |
| 82 | if org is not False: |
| 83 | path = "/{}{}".format(org.slug, path) |
| 84 | |
| 85 | if user: |
| 86 | authenticate_request(self.client, user) |
| 87 | |
| 88 | method_fn = getattr(self.client, method.lower()) |
| 89 | headers = {} |
| 90 | |
| 91 | if data and is_json: |
| 92 | data = json_dumps(data) |
| 93 | |
| 94 | if is_json: |
| 95 | content_type = "application/json" |
| 96 | else: |
| 97 | content_type = None |
| 98 | |
| 99 | response = method_fn( |
| 100 | path, |
| 101 | data=data, |
| 102 | headers=headers, |
| 103 | content_type=content_type, |
| 104 | follow_redirects=follow_redirects, |
| 105 | ) |
| 106 | return response |
| 107 | |
| 108 | def get_request(self, path, org=None, headers=None, client=None): |
| 109 | if org: |