How to use extract_metadata method in lisa

Best Python code snippet using lisa_python

test_extract_metadata.py

Source:test_extract_metadata.py Github

copy

Full Screen

...93 (time, 2)])94 return cube95 @staticmethod96 def test_return_type_cube(cube_1):97 cube_metadata = data.extract_metadata.extract_metadata(98 cube_1, 1, [], ['cube'], ['netCDF'])99 assert isinstance(cube_metadata, CollectionMetadata)100 @staticmethod101 def test_return_type_cubelist(cube_1, cube_2):102 cubelist_metadata = data.extract_metadata.extract_metadata(103 CubeList([cube_1, cube_2]), 1, [], ['cube'], ['netCDF'], 'title', 'desc')104 assert isinstance(cubelist_metadata, CollectionMetadata)105 @staticmethod106 def test_title_cube(cube_1):107 cube_metadata = data.extract_metadata.extract_metadata(108 cube_1, 1, [], ['cube'], ['netCDF'])109 assert cube_metadata.title == "mass_concentration_of_ozone_in_air"110 @staticmethod111 def test_title_cubelist(cube_1, cube_2):112 cubelist_metadata = data.extract_metadata.extract_metadata(113 CubeList([cube_1, cube_2]), 1, [], ['cube'], ['netCDF'], 'title', 'desc')114 assert cubelist_metadata.title == "title"115 @staticmethod116 def test_total_time_extent(cube_1):117 cube_metadata = data.extract_metadata.extract_metadata(118 cube_1, 1, [], ['cube'], ['netCDF'])119 assert np.allclose(cube_metadata.extent.temporal.values, np.linspace(1, 24, 24))120 @staticmethod121 def test_total_time_extent_gap(cube_3):122 cube_metadata = data.extract_metadata.extract_metadata(123 cube_3, 1, [], ['cube'], ['netCDF'])124 assert np.allclose(cube_metadata.extent.temporal.values, [1, 2, 3, 7, 8, 9])125 @staticmethod126 def test_total_vertical_extent(cube_1):127 cube_metadata = data.extract_metadata.extract_metadata(128 cube_1, 1, [], ['cube'], ['netCDF'])129 assert cube_metadata.extent.vertical.values == pytest.approx(3.5)130 @staticmethod131 def test_parameters_length_cube(cube_1):132 cube_metadata = data.extract_metadata.extract_metadata(133 cube_1, 1, [], ['cube'], ['netCDF'])134 assert len(cube_metadata.parameters) == 1135 @staticmethod136 def test_parameters_length_cubelist(cube_1, cube_2):137 cubelist_metadata = data.extract_metadata.extract_metadata(138 CubeList([cube_1, cube_2]), 1, [], ['cube'], ['netCDF'], 'title', 'desc')139 assert len(cubelist_metadata.parameters) == 2140 @staticmethod141 def test_containing_polygon_cube(cube_1):142 cube_metadata = data.extract_metadata.extract_metadata(143 cube_1, 1, [], ['cube'], ['netCDF'])144 assert cube_metadata.extent.spatial.bbox.bounds == (45, -90, 360, 90)145 @staticmethod146 def test_containing_polygon_equal(cube_1):147 # two equal polygons148 cubelist_metadata = data.extract_metadata.extract_metadata(149 CubeList([cube_1, cube_1]), 1, [], ['cube'], ['netCDF'], 'title', 'desc')150 assert cubelist_metadata.extent.spatial.bbox.bounds == (45, -90, 360, 90)151 @staticmethod152 def test_containing_polygon_overlapping(cube_1, cube_2):153 # two partially overlapping polygons154 cubelist_metadata = data.extract_metadata.extract_metadata(155 CubeList([cube_1, cube_2]), 1, [], ['cube'], ['netCDF'], 'title', 'desc')156 assert cubelist_metadata.extent.spatial.bbox.bounds == (1, -90, 360, 100)157 @staticmethod158 def test_containing_polygon_within(cube_1, cube_3):159 # one polygon completely within another polygon160 cubelist_metadata = data.extract_metadata.extract_metadata(161 CubeList([cube_1, cube_3]), 1, [], ['cube'], ['netCDF'], 'title', 'desc')162 assert cubelist_metadata.extent.spatial.bbox.bounds == (-10, -150, 400, 150)163 @staticmethod164 def test_containing_polygon_overlapping_and_within(cube_1, cube_2, cube_3):165 # two partially overlapping polygons completely within a third polygon166 cubelist_metadata = data.extract_metadata.extract_metadata(167 CubeList([cube_1, cube_2, cube_3]), 1, [], ['cube'], ['netCDF'], 'title', 'desc')168 assert cubelist_metadata.extent.spatial.bbox.bounds == (-10, -150, 400, 150)169 @staticmethod170 def test_containing_polygon_separate(cube_1, cube_4):171 # two completely separate polygons172 cubelist_metadata = data.extract_metadata.extract_metadata(173 CubeList([cube_1, cube_4]), 1, [], ['cube'], ['netCDF'], 'title', 'desc')174 assert cubelist_metadata.extent.spatial.bbox.bounds == (45, -90, 430, 175)175 @staticmethod176 def test_containing_polygon_overlap_within_separate(cube_1, cube_2, cube_3, cube_4):177 # two partially overlapping polygons completely within a third polygon, and a completely separate fourth polygon178 cubelist_metadata = data.extract_metadata.extract_metadata(179 CubeList([cube_1, cube_2, cube_3, cube_4]), 1, [], ['cube'], ['netCDF'], 'title', 'desc')180 assert cubelist_metadata.extent.spatial.bbox.bounds == (-10, -150, 430, 175)181class errorTest(unittest.TestCase):182 def test_dimensionless_cube_error(self):183 time = DimCoord(np.linspace(1, 24, 24),184 standard_name='time',185 units="hours since 1970-01-01 00:00:00")186 cube = Cube(np.zeros((24), np.float32),187 standard_name="mass_concentration_of_ozone_in_air",188 units="ug/m3",189 dim_coords_and_dims=[(time, 0)])190 with self.assertRaisesRegex(ValueError, 'The dataset must contain at least one variable with x and y axes.'):191 data.extract_metadata.extract_metadata(...

Full Screen

Full Screen

security.py

Source:security.py Github

copy

Full Screen

...17 if scheme in ("http", "https"):18 return hostname19 return urlunsplit((scheme, hostname, "", None, None))20class SecurityEvent(BaseEvent):21 def extract_metadata(self, data):22 # Relay normalizes the message for security reports into the log entry23 # field, so we grab the message from there.24 # (https://github.com/getsentry/relay/pull/558)25 message = strip(26 get_path(data, "logentry", "formatted") or get_path(data, "logentry", "message")27 )28 return {"message": message}29 def get_title(self, metadata):30 # Due to a regression (https://github.com/getsentry/sentry/pull/19794)31 # some events did not have message persisted but title. Because of this32 # the title code has to take these into account.33 return metadata.get("message") or metadata.get("title") or "<untitled>"34 def get_location(self, metadata):35 # Try to get location by preferring URI over origin. This covers36 # all the cases below where CSP sets URI and others set origin.37 return metadata.get("uri") or metadata.get("origin")38class CspEvent(SecurityEvent):39 key = "csp"40 def extract_metadata(self, data):41 metadata = SecurityEvent.extract_metadata(self, data)42 metadata["uri"] = _normalize_uri(data["csp"].get("blocked_uri") or "")43 metadata["directive"] = data["csp"].get("effective_directive")44 return metadata45class HpkpEvent(SecurityEvent):46 key = "hpkp"47 def extract_metadata(self, data):48 metadata = SecurityEvent.extract_metadata(self, data)49 metadata["origin"] = data["hpkp"].get("hostname")50 return metadata51class ExpectCTEvent(SecurityEvent):52 key = "expectct"53 def extract_metadata(self, data):54 metadata = SecurityEvent.extract_metadata(self, data)55 metadata["origin"] = data["expectct"].get("hostname")56 return metadata57class ExpectStapleEvent(SecurityEvent):58 key = "expectstaple"59 def extract_metadata(self, data):60 metadata = SecurityEvent.extract_metadata(self, data)61 metadata["origin"] = data["expectstaple"].get("hostname")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful