How to use mark_changed method in hypothesis

Best Python code snippet using hypothesis

initdb.py

Source:initdb.py Github

copy

Full Screen

...58 t = odo('systems.csv', url, dshape=ds)59 # Reapplying uppercase to systems, as the index being uppercased slows down searches again.60 print("Uppercasing system names...")61 DBSession.execute("UPDATE systems SET name = UPPER(name)")62 mark_changed(DBSession())63 transaction.commit()64 print("Creating indexes...")65 DBSession.execute("CREATE INDEX index_system_names_trigram ON systems USING GIN(name gin_trgm_ops)")66 mark_changed(DBSession())67 transaction.commit()68 DBSession.execute("CREATE INDEX index_system_names_btree ON systems (name)")69 mark_changed(DBSession())70 transaction.commit()71 print("Done!")72 #73 # Factions74 #75 if os.path.isfile('factions.json'):76 if datetime.fromtimestamp(os.path.getmtime('factions.json')) > datetime.today() - timedelta(days=7):77 print("Using cached factions.json")78 else:79 print("Downloading factions.jsonl from EDDB.io...")80 r = requests.get("https://eddb.io/archive/v5/factions.jsonl", stream=True)81 with open('factions.json', 'wb') as f:82 for chunk in r.iter_content(chunk_size=4096):83 if chunk:84 f.write(chunk)85 print("Saved factions.json. Converting JSONL to SQL.")86 url = str(engine.url) + "::" + Faction.__tablename__87 ds = dshape("var *{ id: ?int64, name: ?string, updated_at: ?int64, government_id: ?int64, "88 "government: ?string, allegiance_id: ?int64, allegiance: ?string, "89 "state_id: ?int64, state: ?string, home_system_id: ?int64, "90 "is_player_faction: ?bool }")91 t = odo('jsonlines://factions.json', url, dshape=ds)92 print("Done!")93 DBSession.execute("CREATE INDEX factions_idx ON factions(id)")94 mark_changed(DBSession())95 transaction.commit()96 #97 # Populated Systems98 #99 if os.path.isfile('systems_populated.json'):100 if datetime.fromtimestamp(os.path.getmtime('systems_populated.json')) > datetime.today() - timedelta(days=7):101 print("Using cached systems.csv")102 else:103 print("Downloading systems_populated.jsonl from EDDB.io...")104 r = requests.get("https://eddb.io/archive/v5/systems_populated.jsonl", stream=True)105 with open('systems_populated.json', 'wb') as f:106 for chunk in r.iter_content(chunk_size=4096):107 if chunk:108 f.write(chunk)109 print("Saved systems_populated.json. Converting JSONL to SQL.")110 url = str(engine.url) + "::" + PopulatedSystem.__tablename__111 ds = dshape("var *{ id: ?int64, edsm_id: ?int64, name: ?string, x: ?float64, y: ?float64, "112 "z: ?float64, population: ?int64, is_populated: ?bool, government_id: ?int64, "113 "government: ?string, allegiance_id: ?int64, allegiance: ?string, "114 "state_id: ?int64, state: ?string, security_id: ?float64, security: ?string, "115 "primary_economy_id: ?float64, primary_economy: ?string, power: ?string, "116 "power_state: ?string, power_state_id: ?string, needs_permit: ?int64, "117 "updated_at: ?int64, simbad_ref: ?string, controlling_minor_faction_id: ?string, "118 "controlling_minor_faction: ?string, reserve_type_id: ?float64, reserve_type: ?string,"119 "minor_faction_presences: ?json }")120 t = odo('jsonlines://systems_populated.json', url, dshape=ds)121 print("Uppercasing system names...")122 DBSession.execute("UPDATE populated_systems SET name = UPPER(name)")123 mark_changed(DBSession())124 transaction.commit()125 print("Creating indexes...")126 DBSession.execute("CREATE INDEX index_populated_system_names_trigram ON populated_systems "127 "USING GIN(name gin_trgm_ops)")128 mark_changed(DBSession())129 transaction.commit()130 DBSession.execute("CREATE INDEX index_populated_system_names_btree ON populated_systems (name)")131 mark_changed(DBSession())132 transaction.commit()133 print("Done!")134 #135 # Bodies136 #137 if os.path.isfile('bodies.json'):138 if datetime.fromtimestamp(os.path.getmtime('bodies.json')) > datetime.today() - timedelta(days=7):139 print("Using cached bodies.json")140 else:141 print("Downloading bodies.jsonl from EDDB.io...")142 r = requests.get("https://eddb.io/archive/v5/bodies.jsonl", stream=True)143 with open('bodies.json', 'wb') as f:144 for chunk in r.iter_content(chunk_size=4096):145 if chunk:146 f.write(chunk)147 print("Saved bodies.jsonl. Converting JSONL to SQL.")148 ds = dshape("var *{ id: ?int64, created_at: ?int64, updated_at: ?int64, name: ?string, "149 "system_id: ?int64, group_id: ?int64, group_name: ?string, type_id: ?int64, "150 "type_name: ?string, distance_to_arrival: ?int64, full_spectral_class: ?string, "151 "spectral_class: ?string, spectral_sub_class: ?string, luminosity_class: ?string, "152 "luminosity_sub_class: ?string, surface_temperature: ?int64, is_main_star: ?bool, "153 "age: ?int64, solar_masses: ?float64, solar_radius: ?float64, catalogue_gliese_id : ?string, "154 "catalogue_hipp_id: ?string, catalogue_hd_id: ?string, volcanism_type_id: ?int64, "155 "volcanism_type_name: ?string, atmosphere_type_id: ?int64, atmosphere_type_name: ?string, "156 "terraforming_state_id: ?int64, terraforming_state_name: ?string, earth_masses: ?float64, "157 "radius: ?int64, gravity: ?float64, surface_pressure: ?int64, orbital_period: ?float64, "158 "semi_major_axis: ?float64, orbital_eccentricity: ?float64, orbital_inclination: ?float64, "159 "arg_of_periapsis: ?float64, rotational_period: ?float64, "160 "is_rotational_period_tidally_locked: ?bool, axis_tilt: ?float64, eg_id: ?int64, "161 "belt_moon_masses: ?float64, ring_type_id: ?int64, ring_type_name: ?string, "162 "ring_mass: ?int64, ring_inner_radius: ?float64, ring_outer_radius: ?float64, "163 "rings: ?json, atmosphere_composition: ?json, solid_composition: ?json, "164 "materials: ?json, is_landable: ?bool}")165 url = str(engine.url) + "::" + Body.__tablename__166 t = odo('jsonlines://bodies.json', url, dshape=ds)167 print("Creating indexes...")168 DBSession.execute("CREATE INDEX bodies_idx ON bodies(name text_pattern_ops)")169 mark_changed(DBSession())170 transaction.commit()171 DBSession.execute("CREATE INDEX systemid_idx ON bodies(system_id)")172 mark_changed(DBSession())173 transaction.commit()174 print("Done!")175 #176 # Stations177 #178 if os.path.isfile('stations.json'):179 if datetime.fromtimestamp(os.path.getmtime('stations.json')) > datetime.today() - timedelta(days=7):180 print("Using cached stations.json")181 else:182 print("Downloading stations.jsonl from EDDB.io...")183 r = requests.get("https://eddb.io/archive/v5/stations.jsonl", stream=True)184 with open('stations.json', 'wb') as f:185 for chunk in r.iter_content(chunk_size=4096):186 if chunk:187 f.write(chunk)188 print("Saved stations.json. Converting JSONL to SQL.")189 url = str(engine.url) + "::" + Station.__tablename__190 ds = dshape("var *{ id: ?int64, name: ?string, system_id: ?int64, updated_at: ?int64, "191 "max_landing_pad_size: ?string, distance_to_star: ?int64, government_id: ?int64, "192 "government: ?string, allegiance_id: ?int64, allegiance: ?string, "193 "state_id: ?int64, state: ?string, type_id: ?int64, type: ?string, "194 "has_blackmarket: ?bool, has_market: ?bool, has_refuel: ?bool, "195 "has_repair: ?bool, has_rearm: ?bool, has_outfitting: ?bool, "196 "has_shipyard: ?bool, has_docking: ?bool, has_commodities: ?bool, "197 "import_commodities: ?json, export_commodities: ?json, prohibited_commodities: ?json, "198 "economies: ?json, shipyard_updated_at: ?int64, outfitting_updated_at: ?int64, "199 "market_updated_at: ?int64, is_planetary: ?bool, selling_ships: ?json, "200 "selling_modules: ?json, settlement_size_id: ?string, settlement_size: ?int64, "201 "settlement_security_id: ?int64, settlement_security: ?string, body_id: ?int64,"202 "controlling_minor_faction_id: ?int64 }")203 t = odo('jsonlines://stations.json', url, dshape=ds)204 print("Creating indexes...")205 DBSession.execute("CREATE INDEX index_stations_systemid_btree ON stations(system_id)")206 mark_changed(DBSession())207 transaction.commit()208 DBSession.execute("CREATE INDEX index_stations_btree ON stations(id)")209 mark_changed(DBSession())210 transaction.commit()211 print("Done!")212 #213 # Listings214 #215 if os.path.isfile('listings.csv'):216 if datetime.fromtimestamp(os.path.getmtime('listings.csv')) > datetime.today() - timedelta(days=7):217 print("Using cached listings.csv")218 else:219 print("Downloading listings.csv from EDDB.io...")220 r = requests.get("https://eddb.io/archive/v5/listings.csv", stream=True)221 with open('listings.csv', 'wb') as f:222 for chunk in r.iter_content(chunk_size=4096):223 if chunk:224 f.write(chunk)225 print("Saved listings.csv. Converting CSV to SQL.")226 url = str(engine.url) + "::" + Listing.__tablename__227 ds = dshape("var *{ id: ?int64, station_id: ?int64, commodity: ?int64, supply: ?int64, "228 "buy_price: ?int64, sell_price: ?int64, demand: ?int64, collected_at: ?int64 }")229 t = odo('listings.csv', url, dshape=ds)230 print("Creating indexes...")231 DBSession.execute("CREATE INDEX index_listings_stationid_btree ON listings(station_id)")232 mark_changed(DBSession())233 transaction.commit()...

Full Screen

Full Screen

keystore.py

Source:keystore.py Github

copy

Full Screen

...21 data = {}22 self.data = data23 def has_changed(self):24 return self._changed25 def mark_changed(self):26 self._changed = True27 def export(self):28 return self.data29 def has_key(self, name):30 if name in self.data:31 return True32 return False33 def is_trusted_key(self, public_key):34 openssh_key = public_key.export_public_key('openssh')35 for name, entry in self.data.items():36 if entry.get('type') == 'private_key':37 # We're only interested in actual keys38 entry_value = entry.get('public_key')39 elif entry.get('type') == 'public_key':40 entry_value = entry.get('value')41 else:42 # We're only interested in actual keys43 continue44 if entry_value == openssh_key:45 logging.info('Confirming key is trusted with name: {}.'.format(name))46 return True47 return False48 def delete_key(self, name):49 self.data.pop(name, None)50 self.mark_changed()51 def add_private_key(self, name, path, validate=True):52 key = security.load_rsa_key(path)53 assert key.has_private_portion()54 self.mark_changed()55 self.data[name] = {56 'type': 'private_key',57 'value': path,58 'public_key': key.export_public_key('openssh'),59 }60 def add_public_key(self, name, key):61 self.mark_changed()62 self.data[name] = {63 'type': 'public_key',64 'value': key.export_public_key('openssh'),65 }66 def add_alias(self, alias, names):67 self.mark_changed()68 self.data[alias] = {69 'type': 'alias',70 'value': names,71 }72 def add_to_alias(self, alias, names):73 entry = self.data.get(alias, None)74 if not entry or entry['type'] != 'alias':75 raise InvalidAliasError('Cannot add to an alias that doesnt exist')76 self.mark_changed()77 entry['value'].extend(names)78 def resolve_alias(self, root_alias):79 matches = []80 aliases = [root_alias]81 seen_aliases = {root_alias: True}82 # Resolve to entries83 while aliases:84 # Map to values85 next_aliases = []86 for a in aliases:87 entry = self.data.get(a, None)88 if not entry:89 logging.warn('Key alias "{}" does not exist.'.format(a))90 continue...

Full Screen

Full Screen

transform3d.py

Source:transform3d.py Github

copy

Full Screen

...35 relative_matrix = (translation_matrix * scale_matrix * rotation_matrix)36 # self.transform_matrix = relative_matrix * self.initial_matrix37 self.transform_matrix = relative_matrix38 # print('update_transform_matrix: transform_matrix = {}'.format(self.transform_matrix))39 def mark_changed(self):40 self.is_changed = True41 # ======================== Rotation ========================42 def set_euler_rotation(self, new_rotation):43 self.rotation = new_rotation44 new_quaternion = self.rotation.to_quaternion()45 self.set_quaternion(new_quaternion)46 def rotate(self, angle_rotator):47 # new_rotator = self.rotation + angle_rotator48 new_rotator = self.rotation.add(angle_rotator)49 # print("New rotation: {}".format(new_rotator))50 self.set_euler_rotation(new_rotator)51 def set_quaternion(self, new_quaternion):52 # print("New quaternion: {}".format(new_quaternion))53 self.quaternion = new_quaternion54 self.mark_changed()55 # ======================== Scale ========================56 # Scale the mesh with the same amount between all the axis57 def set_scale_uniform(self, uniform_scale):58 self.scale *= uniform_scale59 self.mark_changed()60 61 def set_scale(self, new_scale):62 self.scale = new_scale63 self.mark_changed()64 # ======================== Translation ========================65 def set_location(self, new_location):66 self.location = new_location67 self.mark_changed()68 def move(self, move_vector):69 new_location = self.location + move_vector70 self.set_location(new_location)71 # ======================== Others ========================72 def set_initial_matrix(self, new_initial_matrix):73 self.initial_matrix = new_initial_matrix74 self.mark_changed()75 def reset_transform(self):76 self.set_location(Vector3())77 # self.set_rotation(euler.create(0.0, 0.0, 0.0))78 self.set_quaternion(Quaternion([0, 0, 0, 1]))...

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 hypothesis 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