How to use test_tags method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

test_classes.py

Source:test_classes.py Github

copy

Full Screen

1from mayan.apps.documents.permissions import permission_document_view2from mayan.apps.documents.search import document_search3from mayan.apps.documents.tests.mixins.document_mixins import DocumentTestMixin4from mayan.apps.tags.tests.mixins import TagTestMixin5from mayan.apps.testing.tests.base import BaseTestCase6from ..classes import SearchBackend7class ScopedSearchTestCase(DocumentTestMixin, TagTestMixin, BaseTestCase):8 auto_upload_test_document = False9 def setUp(self):10 super().setUp()11 self.search_backend = SearchBackend.get_instance()12 self._create_test_document_stub()13 self._create_test_tag()14 self._create_test_tag()15 self.test_tags[0].documents.add(self.test_document)16 self.test_tags[1].documents.add(self.test_document)17 self.grant_access(18 obj=self.test_document, permission=permission_document_view19 )20 def test_AND_scope(self):21 query = {22 '__0_tags__label': self.test_tags[0].label,23 '__operator_0_1': 'AND_901',24 '__result': '901',25 '__1_tags__label': self.test_tags[1].label26 }27 queryset = self.search_backend.search(28 search_model=document_search, query_string=query,29 user=self._test_case_user30 )31 self.assertEqual(queryset.count(), 1)32 self.test_tags[1].documents.remove(self.test_document)33 query = {34 '__0_tags__label': self.test_tags[0].label,35 '__operator_0_1': 'AND_901',36 '__result': '901',37 '__1_tags__label': self.test_tags[1].label38 }39 queryset = self.search_backend.search(40 search_model=document_search, query_string=query,41 user=self._test_case_user42 )43 self.assertEqual(queryset.count(), 0)44 def test_OR_scope(self):45 query = {46 '__0_tags__label': self.test_tags[0].label,47 '__operator_0_1': 'OR_901',48 '__result': '901',49 '__1_tags__label': self.test_tags[1].label50 }51 queryset = self.search_backend.search(52 search_model=document_search, query_string=query,53 user=self._test_case_user54 )55 self.assertEqual(queryset.count(), 1)56 def test_letter_scopes(self):57 query = {58 '__a_tags__label': self.test_tags[0].label,59 '__operator_a_b': 'OR_c',60 '__result': 'c',61 '__b_tags__label': self.test_tags[1].label62 }63 queryset = self.search_backend.search(64 search_model=document_search, query_string=query,65 user=self._test_case_user66 )67 self.assertEqual(queryset.count(), 1)68 def test_multi_letter_scopes(self):69 query = {70 '__ab_tags__label': self.test_tags[0].label,71 '__operator_ab_bc': 'OR_cc',72 '__result': 'cc',73 '__bc_tags__label': self.test_tags[1].label74 }75 queryset = self.search_backend.search(76 search_model=document_search, query_string=query,77 user=self._test_case_user78 )...

Full Screen

Full Screen

test_models.py

Source:test_models.py Github

copy

Full Screen

1from pathlib import Path2from bidict import frozenbidict3from tbm_utils import DataReader4from ward import test5from audio_metadata.models import (6 Format,7 Picture,8 StreamInfo,9 Tags10)11from tests.utils import strip_repr12test_image = (Path(__file__).parent / 'image' / 'test.png').resolve()13@test(14 "Format",15 tags=['unit', 'models', 'Format'],16)17def _():18 format_bytes = Format._load(test_image.read_bytes())19 format_bytes_datareader = Format._load(DataReader(test_image.read_bytes()))20 format_fileobj = Format._load(test_image.open('rb'))21 format_fileobj_datareader = Format._load(DataReader(test_image.open('rb')))22 assert isinstance(format_bytes._obj, DataReader)23 assert isinstance(format_bytes_datareader._obj, DataReader)24 assert isinstance(format_fileobj._obj, DataReader)25 assert isinstance(format_fileobj_datareader._obj, DataReader)26 assert format_bytes.filepath is format_bytes_datareader.filepath is None27 assert format_fileobj.filepath == format_fileobj_datareader.filepath == str(test_image)28 assert format_bytes.filesize == format_bytes_datareader.filesize == 9629 assert format_fileobj.filesize == format_fileobj_datareader.filesize == 9630 assert repr(format_bytes) == repr(format_bytes_datareader)31 assert repr(format_fileobj) == repr(format_fileobj_datareader)32@test(33 "Picture",34 tags=['unit', 'models', 'Picture'],35)36def _():37 picture = Picture(38 _test='test',39 height=16,40 width=16,41 data=test_image.read_bytes()42 )43 assert repr(picture) == "<Picture({'data': '96.00 B', 'height': 16, 'width': 16})>"44@test(45 "StreamInfo",46 tags=['unit', 'models', 'StreamInfo'],47)48def _():49 stream_info = StreamInfo(50 _start=0,51 bitrate=320000,52 duration=100,53 sample_rate=44100,54 channels=255 )56 assert strip_repr(stream_info) == "<StreamInfo({'bitrate': '320 Kbps', 'channels': 2, 'duration': '01:40', 'sample_rate': '44.1 KHz',})>"57@test(58 "Tags",59 tags=['unit', 'models', 'Tags'],60)61def _():62 test_tags = Tags(key1='value1', key2='value2')63 test_tags.FIELD_MAP = frozenbidict({'artist': 'key1', 'title': 'key2'})64 assert test_tags['artist'] == test_tags['key1'] == test_tags.artist == test_tags.key165 assert test_tags['title'] == test_tags['key2'] == test_tags.title == test_tags.key266 test_tags['key3'] = 'value3'67 del test_tags['key3']68 assert 'key3' not in test_tags69 test_tags.key3 = 'value3'70 delattr(test_tags, 'key3')71 assert not hasattr(test_tags, 'key3')72 assert list(iter(test_tags)) == ['artist', 'title']...

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