def get_metadata(): if settings.MOCK_METADATA: file = f"{settings.BASE_DIR}/../core/fixtures/metadata.json" return Metadata(json.loads(memfiles.open(file))) metadata = redis_client.get("metadata") if metadata: return Metadata(json.loads(metadata)) url = f"{settings.MARKET_ACCESS_API_URI}metadata" sender = Sender( settings.MARKET_ACCESS_API_HAWK_CREDS, url, "GET", content="", content_type="text/plain", always_hash_content=False, ) response = requests.get( url, verify=not settings.DEBUG, headers={ "Authorization": sender.request_header, "Content-Type": "text/plain", }, ) if not response.ok: raise HawkException(f"Call to fetch metadata failed {response}") metadata = response.json() redis_client.set("metadata", json.dumps(metadata), ex=settings.METADATA_CACHE_TIME) return Metadata(metadata)
def draft_barriers(self): if not self._draft_barriers: file = f"{settings.BASE_DIR}/../tests/reports/fixtures/draft_barriers.json" self._draft_barriers = json.loads(memfiles.open(file)) return self._draft_barriers
def users(self): if self._users is None: file = f"{settings.BASE_DIR}/../tests/barriers/fixtures/users.json" users = json.loads(memfiles.open(file)) self._users = [User(user) for user in users] return self._users
def team_members(self): if self._team_members is None: file = f"{settings.BASE_DIR}/../tests/barriers/fixtures/team_members.json" self._team_members = json.loads(memfiles.open(file)) return self._team_members
def all_history(self): if self._history is None: file = f"{settings.BASE_DIR}/../tests/barriers/fixtures/history.json" self._history = json.loads(memfiles.open(file)) return self._history