def test_access_advisor_get(): ds = AccessAdvisorDatasource() arn = "pretend_arn" expected = [{"a": "b"}] ds._data = {arn: expected} result = ds.get(arn) assert result == expected
def test_access_advisor_get_fallback_not_found(mock_fetch): ds = AccessAdvisorDatasource() arn = "pretend_arn" mock_fetch.return_value = {} with pytest.raises(NotFoundError): _ = ds.get(arn) mock_fetch.assert_called_once() assert mock_fetch.call_args[1]["arn"] == arn
def test_access_advisor_get_fallback(mock_fetch): ds = AccessAdvisorDatasource() arn = "pretend_arn" expected = [{"a": "b"}] mock_fetch.return_value = {arn: expected} result = ds.get(arn) mock_fetch.assert_called_once() assert mock_fetch.call_args[1]["arn"] == arn assert result == expected # make sure fetched data gets cached assert arn in ds._data assert ds._data[arn] == expected
def fetch_aa_data(self) -> None: if not self.arn: raise ModelError( "missing arn on Role instance, cannot retrieve Access Advisor data" ) aardvark_data = AccessAdvisorDatasource() try: self.aa_data = aardvark_data.get(self.arn) except NotFoundError: self.aa_data = []
def fetch_aa_data(self) -> None: if not self.arn: raise ModelError( "missing arn on Role instance, cannot retrieve Access Advisor data" ) aardvark_data = AccessAdvisorDatasource() if self.account: # We'll go ahead and seed this whole account aardvark_data.seed(self.account) try: self.aa_data = aardvark_data.get(self.arn) except NotFoundError: self.aa_data = []