How to use _check_tags method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

core.py

Source:core.py Github

copy

Full Screen

...80 return ret81 def reset(self) -> 'Results':82 self.df = self._extract_df()83 return self84 def _check_tags(self, tags: Iterable, f: Callable) -> 'Results':85 86 def _ok(row):87 assigned = row.rich_id.tags88 return f(assigned, tags)89 df = self.df[self.df.apply(_ok, axis=1)]90 return self._from_self(df)91 def _from_self(self, df) -> 'Results':92 return Results(db=self.db, df=df, name=self.name)93 def has_all(self, *tags) -> 'Results':94 def _f(assigned, tags):95 return len(set(assigned) - set(tags)) == 096 return self._check_tags(tags, _f)97 def has_any(self, *tags) -> 'Results':98 def _f(assigned, tags):99 return len(set(assigned) & set(tags)) > 0100 return self._check_tags(tags, _f)101 def top_k(self, metrics: Iterable[str] = None, k=5, ascending=False) -> 'Results':102 results = self.df['results']103 if metrics is None:104 metrics = list(results.columns)105 sort_by = [('results', c) for c in metrics]106 df = self.df.sort_values(by=sort_by, ascending=ascending).iloc[:k, :]107 return self._from_self(df)108 def only_ok(self, allowed=(States.OK, )) -> 'Results':109 if len(allowed) == 0:110 return self111 cond = (self.df.details.status == allowed[0])112 for status in allowed[1:]:113 cond |= (self.df.details.status == status)114 df = self.df[cond]...

Full Screen

Full Screen

test_tags.py

Source:test_tags.py Github

copy

Full Screen

...14 init_tests( webdriver, flask_app, dbconn )15 # create a test publication and article16 create_publication( { "name": "publication 1" } )17 create_article( { "title": "article 1" } )18 _check_tags( flask_app, {19 "publication 1": [],20 "article 1": []21 } )22 # add some tags to the publication23 edit_publication( find_search_result( "publication 1" ), {24 "tags": [ "+aaa", "+bbb" ]25 } )26 _check_tags( flask_app, {27 "publication 1": [ "aaa", "bbb" ],28 "article 1": []29 } )30 # add some tags to the article31 edit_article( find_search_result( "article 1" ), {32 "tags": [ "+bbb", "+ccc" ]33 } )34 _check_tags( flask_app, {35 "publication 1": [ "aaa", "bbb" ],36 "article 1": [ "bbb", "ccc" ]37 } )38 # remove some tags from the publication39 edit_publication( find_search_result( "publication 1" ), {40 "tags": [ "-bbb" ]41 } )42 _check_tags( flask_app, {43 "publication 1": [ "aaa" ],44 "article 1": [ "bbb", "ccc" ]45 } )46 # remove some tags from the article47 edit_article( find_search_result( "article 1" ), {48 "tags": [ "-ccc", "-bbb" ]49 } )50 _check_tags( flask_app, {51 "publication 1": [ "aaa" ],52 "article 1": []53 } )54 # add duplicate tags to the publication55 edit_publication( find_search_result( "publication 1" ), {56 "tags": [ "+bbb", "+aaa", "+eee" ]57 } )58 _check_tags( flask_app, {59 "publication 1": [ "aaa","bbb","eee" ],60 "article 1": []61 } )62# ---------------------------------------------------------------------63def test_clean_html( webdriver, flask_app, dbconn ):64 """Test cleaning HTML from tags."""65 # initialize66 init_tests( webdriver, flask_app, dbconn )67 # try to create a publication with HTML tags68 create_publication( {69 "name": "test publication",70 "tags": [ "+<b>bold</b>" ]71 }, toast_type="warning" )72 _check_tags( flask_app, {73 "test publication": [ "bold" ]74 } )75 # try to create an article with HTML tags76 create_article( {77 "title": "test article",78 "tags": [ "+<i>italic</i>" ]79 }, toast_type="warning" )80 _check_tags( flask_app, {81 "test publication": [ "bold" ],82 "test article": [ "italic" ]83 } )84# ---------------------------------------------------------------------85def _check_tags( flask_app, expected ): #pylint: disable=too-many-locals86 """Check the tags in the UI and database."""87 # get the complete list of expected tags88 expected_available = set()89 for tags in expected.values():90 expected_available.update( tags )91 def check_tags( sr ):92 name = get_search_result_names( [sr] )[ 0 ]93 tags = [ t.text for t in find_children( ".tag", sr ) ]94 if tags == expected[name]:95 return name96 return None97 # check the tags in the UI98 results = get_search_results()99 assert set( get_search_result_names( results ) ) == set( expected.keys() )...

Full Screen

Full Screen

chunk.py

Source:chunk.py Github

copy

Full Screen

...31 super().__init__(nbt_data)32 area.Area.__init__(self, self.data["xPos"].value * CHUNK_SIZE, self.data["zPos"].value * CHUNK_SIZE, CHUNK_SIZE, CHUNK_SIZE)33 def search_nbt(self, tags, keys = None, verbose = 0):34 if(keys):35 yield from self._check_tags(tags, keys, verbose = verbose)36 else:37 yield from self._check_tags(tags, self.data, verbose = verbose)38 39 def search_blocks(self, id, verbose = 0):40 isOld = type(self.get_block(0, 255, 0)) is anvil.OldBlock41 matchID = StringMatch.fromStr(id)42 for index, block in enumerate(self.stream_chunk(index = 0, section = None)):43 if(isOld):44 block = anvil.Block.from_numeric_id(block_id = block.id, data = block.data)45 if(matchID.equals(block.name())):46 pos = self._index_to_pos(index)47 yield ((pos[0] + self.x, pos[1], pos[2] + self.z), block, self.get_tile_entity(pos[0] + self.x, pos[1], pos[2] + self.z))48 def _index_to_pos(self, index, offx = 0, offy = 0, offz = 0):49 # y * 256 + z * 16 + x50 return ((index % 16) + offx, index // 256 + offy, (index % 256) // 16 + offz)51 52 def _check_tags(self, tags, keys, verbose = 0):53 for key in keys:54 data = self._lookup_names_in_tag(key if type(key) is list else [key], self.data, verbose = verbose)55 if(issubclass(data.__class__, nbt.TAG)):56 yield from self._check_tag(data.tags, tags, verbose = verbose)57 else:58 yield from self._check_tag(data, tags, verbose = verbose)59 def _check_tag(self, nbt_tags, tags, verbose = 0):60 for tag in nbt_tags:61 if(nbt_util.nbt_tag_contains_tags(tag, tags)):62 pos = nbt_util.nbt_tag_get_pos(tag)63 if(pos):64 pos = tuple(map(round, pos))65 yield (pos, tag)66 ...

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