How to use filters method in tempest

Best Python code snippet using tempest_python

test_ir_filters.py

Source:test_ir_filters.py Github

copy

Full Screen

...17 def setUp(self):18 super(TestGetFilters, self).setUp()19 self.USER_NG = self.env['res.users'].name_search('demo')[0]20 self.USER_ID = self.USER_NG[0]21 def test_own_filters(self):22 self.build(23 'ir.filters',24 dict(name='a', user_id=self.USER_ID, model_id='ir.filters'),25 dict(name='b', user_id=self.USER_ID, model_id='ir.filters'),26 dict(name='c', user_id=self.USER_ID, model_id='ir.filters'),27 dict(name='d', user_id=self.USER_ID, model_id='ir.filters'))28 filters = self.env['ir.filters'].with_user(self.USER_ID).get_filters('ir.filters')29 self.assertItemsEqual(noid(filters), [30 dict(name='a', is_default=False, user_id=self.USER_NG, domain='[]', context='{}', sort='[]'),31 dict(name='b', is_default=False, user_id=self.USER_NG, domain='[]', context='{}', sort='[]'),32 dict(name='c', is_default=False, user_id=self.USER_NG, domain='[]', context='{}', sort='[]'),33 dict(name='d', is_default=False, user_id=self.USER_NG, domain='[]', context='{}', sort='[]'),34 ])35 def test_global_filters(self):36 self.build(37 'ir.filters',38 dict(name='a', user_id=False, model_id='ir.filters'),39 dict(name='b', user_id=False, model_id='ir.filters'),40 dict(name='c', user_id=False, model_id='ir.filters'),41 dict(name='d', user_id=False, model_id='ir.filters'),42 )43 filters = self.env['ir.filters'].with_user(self.USER_ID).get_filters('ir.filters')44 self.assertItemsEqual(noid(filters), [45 dict(name='a', is_default=False, user_id=False, domain='[]', context='{}', sort='[]'),46 dict(name='b', is_default=False, user_id=False, domain='[]', context='{}', sort='[]'),47 dict(name='c', is_default=False, user_id=False, domain='[]', context='{}', sort='[]'),48 dict(name='d', is_default=False, user_id=False, domain='[]', context='{}', sort='[]'),49 ])50 def test_no_third_party_filters(self):51 self.build(52 'ir.filters',53 dict(name='a', user_id=False, model_id='ir.filters'),54 dict(name='b', user_id=ADMIN_USER_ID, model_id='ir.filters'),55 dict(name='c', user_id=self.USER_ID, model_id='ir.filters'),56 dict(name='d', user_id=ADMIN_USER_ID, model_id='ir.filters') )57 filters = self.env['ir.filters'].with_user(self.USER_ID).get_filters('ir.filters')58 self.assertItemsEqual(noid(filters), [59 dict(name='a', is_default=False, user_id=False, domain='[]', context='{}', sort='[]'),60 dict(name='c', is_default=False, user_id=self.USER_NG, domain='[]', context='{}', sort='[]'),61 ])62class TestOwnDefaults(FiltersCase):63 def setUp(self):64 super(TestOwnDefaults, self).setUp()65 self.USER_NG = self.env['res.users'].name_search('demo')[0]66 self.USER_ID = self.USER_NG[0] 67 def test_new_no_filter(self):68 """69 When creating a @is_default filter with no existing filter, that new70 filter gets the default flag71 """72 Filters = self.env['ir.filters'].with_user(self.USER_ID)73 Filters.create_or_replace({74 'name': 'a',75 'model_id': 'ir.filters',76 'user_id': self.USER_ID,77 'is_default': True,78 })79 filters = Filters.get_filters('ir.filters')80 self.assertItemsEqual(noid(filters), [81 dict(name='a', user_id=self.USER_NG, is_default=True,82 domain='[]', context='{}', sort='[]')83 ])84 def test_new_filter_not_default(self):85 """86 When creating a @is_default filter with existing non-default filters,87 the new filter gets the flag88 """89 self.build(90 'ir.filters',91 dict(name='a', user_id=self.USER_ID, model_id='ir.filters'),92 dict(name='b', user_id=self.USER_ID, model_id='ir.filters'),93 )94 Filters = self.env['ir.filters'].with_user(self.USER_ID)95 Filters.create_or_replace({96 'name': 'c',97 'model_id': 'ir.filters',98 'user_id': self.USER_ID,99 'is_default': True,100 })101 filters = Filters.get_filters('ir.filters')102 self.assertItemsEqual(noid(filters), [103 dict(name='a', user_id=self.USER_NG, is_default=False, domain='[]', context='{}', sort='[]'),104 dict(name='b', user_id=self.USER_NG, is_default=False, domain='[]', context='{}', sort='[]'),105 dict(name='c', user_id=self.USER_NG, is_default=True, domain='[]', context='{}', sort='[]'),106 ])107 def test_new_filter_existing_default(self):108 """109 When creating a @is_default filter where an existing filter is already110 @is_default, the flag should be *moved* from the old to the new filter111 """112 self.build(113 'ir.filters',114 dict(name='a', user_id=self.USER_ID, model_id='ir.filters'),115 dict(name='b', is_default=True, user_id=self.USER_ID, model_id='ir.filters'),116 )117 Filters = self.env['ir.filters'].with_user(self.USER_ID)118 Filters.create_or_replace({119 'name': 'c',120 'model_id': 'ir.filters',121 'user_id': self.USER_ID,122 'is_default': True,123 })124 filters = Filters.get_filters('ir.filters')125 self.assertItemsEqual(noid(filters), [126 dict(name='a', user_id=self.USER_NG, is_default=False, domain='[]', context='{}', sort='[]'),127 dict(name='b', user_id=self.USER_NG, is_default=False, domain='[]', context='{}', sort='[]'),128 dict(name='c', user_id=self.USER_NG, is_default=True, domain='[]', context='{}', sort='[]'),129 ])130 def test_update_filter_set_default(self):131 """132 When updating an existing filter to @is_default, if an other filter133 already has the flag the flag should be moved134 """135 self.build(136 'ir.filters',137 dict(name='a', user_id=self.USER_ID, model_id='ir.filters'),138 dict(name='b', is_default=True, user_id=self.USER_ID, model_id='ir.filters'),139 )140 Filters = self.env['ir.filters'].with_user(self.USER_ID)141 Filters.create_or_replace({142 'name': 'a',143 'model_id': 'ir.filters',144 'user_id': self.USER_ID,145 'is_default': True,146 })147 filters = Filters.get_filters('ir.filters')148 self.assertItemsEqual(noid(filters), [149 dict(name='a', user_id=self.USER_NG, is_default=True, domain='[]', context='{}', sort='[]'),150 dict(name='b', user_id=self.USER_NG, is_default=False, domain='[]', context='{}', sort='[]'),151 ])152class TestGlobalDefaults(FiltersCase):153 def setUp(self):154 super(TestGlobalDefaults, self).setUp()155 self.USER_NG = self.env['res.users'].name_search('demo')[0]156 self.USER_ID = self.USER_NG[0]157 def test_new_filter_not_default(self):158 """159 When creating a @is_default filter with existing non-default filters,160 the new filter gets the flag161 """162 self.build(163 'ir.filters',164 dict(name='a', user_id=False, model_id='ir.filters'),165 dict(name='b', user_id=False, model_id='ir.filters'),166 )167 Filters = self.env['ir.filters'].with_user(self.USER_ID)168 Filters.create_or_replace({169 'name': 'c',170 'model_id': 'ir.filters',171 'user_id': False,172 'is_default': True,173 })174 filters = Filters.get_filters('ir.filters')175 self.assertItemsEqual(noid(filters), [176 dict(name='a', user_id=False, is_default=False, domain='[]', context='{}', sort='[]'),177 dict(name='b', user_id=False, is_default=False, domain='[]', context='{}', sort='[]'),178 dict(name='c', user_id=False, is_default=True, domain='[]', context='{}', sort='[]'),179 ])180 def test_new_filter_existing_default(self):181 """182 When creating a @is_default filter where an existing filter is already183 @is_default, an error should be generated184 """185 self.build(186 'ir.filters',187 dict(name='a', user_id=False, model_id='ir.filters'),188 dict(name='b', is_default=True, user_id=False, model_id='ir.filters'),189 )190 Filters = self.env['ir.filters'].with_user(self.USER_ID)191 with self.assertRaises(exceptions.Warning):192 Filters.create_or_replace({193 'name': 'c',194 'model_id': 'ir.filters',195 'user_id': False,196 'is_default': True,197 })198 def test_update_filter_set_default(self):199 """200 When updating an existing filter to @is_default, if an other filter201 already has the flag an error should be generated202 """203 self.build(204 'ir.filters',205 dict(name='a', user_id=False, model_id='ir.filters'),206 dict(name='b', is_default=True, user_id=False, model_id='ir.filters'),207 )208 Filters = self.env['ir.filters'].with_user(self.USER_ID)209 with self.assertRaises(exceptions.Warning):210 Filters.create_or_replace({211 'name': 'a',212 'model_id': 'ir.filters',213 'user_id': False,214 'is_default': True,215 })216 def test_update_default_filter(self):217 """218 Replacing the current default global filter should not generate any error219 """220 self.build(221 'ir.filters',222 dict(name='a', user_id=False, model_id='ir.filters'),223 dict(name='b', is_default=True, user_id=False, model_id='ir.filters'),224 )225 Filters = self.env['ir.filters'].with_user(self.USER_ID)226 context_value = "{'some_key': True}"227 Filters.create_or_replace({228 'name': 'b',229 'model_id': 'ir.filters',230 'user_id': False,231 'context': context_value,232 'is_default': True,233 })234 filters = Filters.get_filters('ir.filters')235 self.assertItemsEqual(noid(filters), [236 dict(name='a', user_id=False, is_default=False, domain='[]', context='{}', sort='[]'),237 dict(name='b', user_id=False, is_default=True, domain='[]', context=context_value, sort='[]'),238 ])239class TestReadGroup(TransactionCase):240 """Test function read_group with groupby on a many2one field to a model241 (in test, "user_id" to "res.users") which is ordered by an inherited not stored field (in242 test, "name" inherited from "res.partners").243 """244 def test_read_group_1(self):245 Users = self.env['res.users']246 self.assertEqual(Users._order, "name, login", "Model res.users must be ordered by name, login")247 self.assertFalse(Users._fields['name'].store, "Field name is not stored in res.users")248 Filters = self.env['ir.filters']...

Full Screen

Full Screen

__main__.py

Source:__main__.py Github

copy

Full Screen

1#!/usr/bin/env python32# -*- coding: utf-8 -*-3# (c) Shrimadhav U K | gautamajay524import io5import logging6import os7import sys8import traceback9from pyrogram import Client, filters, idle10from pyrogram.raw import functions, types11from pyrogram.handlers import CallbackQueryHandler, MessageHandler12from tobrot import app13from tobrot import (14 AUTH_CHANNEL,15 CANCEL_COMMAND_G,16 CLEAR_THUMBNAIL,17 CLONE_COMMAND_G,18 DOWNLOAD_LOCATION,19 GET_SIZE_G,20 GLEECH_COMMAND,21 GLEECH_UNZIP_COMMAND,22 GLEECH_ZIP_COMMAND,23 LEECH_COMMAND,24 LEECH_UNZIP_COMMAND,25 LEECH_ZIP_COMMAND,26 LOG_COMMAND,27 LOGGER,28 PYTDL_COMMAND,29 RENEWME_COMMAND,30 RENAME_COMMAND,31 SAVE_THUMBNAIL,32 STATUS_COMMAND,33 TELEGRAM_LEECH_UNZIP_COMMAND,34 TELEGRAM_LEECH_COMMAND,35 UPLOAD_COMMAND,36 YTDL_COMMAND,37 GYTDL_COMMAND,38 GPYTDL_COMMAND,39 TOGGLE_VID,40 RCLONE_COMMAND,41 TOGGLE_DOC,42 HELP_COMMAND,43 SPEEDTEST44)45from tobrot.helper_funcs.download import down_load_media_f46from tobrot.plugins.call_back_button_handler import button47# the logging things48from tobrot.plugins.choose_rclone_config import rclone_command_f49from tobrot.plugins.custom_thumbnail import clear_thumb_nail, save_thumb_nail50from tobrot.plugins.incoming_message_fn import (g_clonee, g_yt_playlist,51 incoming_message_f,52 incoming_purge_message_f,53 incoming_youtube_dl_f,54 rename_tg_file)55from tobrot.plugins.new_join_fn import help_message_f, new_join_f56from tobrot.plugins.speedtest import get_speed57from tobrot.plugins.rclone_size import check_size_g, g_clearme58from tobrot.plugins.status_message_fn import (59 cancel_message_f,60 eval_message_f,61 exec_message_f,62 status_message_f,63 upload_document_f,64 upload_log_file,65 upload_as_doc,66 upload_as_video67)68if __name__ == "__main__":69 # create download directory, if not exist70 if not os.path.isdir(DOWNLOAD_LOCATION):71 os.makedirs(DOWNLOAD_LOCATION)72 # Starting The Bot73 app.start()74 ##############################################################################75 incoming_message_handler = MessageHandler(76 incoming_message_f,77 filters=filters.command(78 [79 LEECH_COMMAND,80 LEECH_UNZIP_COMMAND,81 LEECH_ZIP_COMMAND,82 GLEECH_COMMAND,83 GLEECH_UNZIP_COMMAND,84 GLEECH_ZIP_COMMAND,85 ]86 )87 & filters.chat(chats=AUTH_CHANNEL),88 )89 app.add_handler(incoming_message_handler)90 ##############################################################################91 incoming_telegram_download_handler = MessageHandler(92 down_load_media_f,93 filters=filters.command([TELEGRAM_LEECH_COMMAND, TELEGRAM_LEECH_UNZIP_COMMAND])94 & filters.chat(chats=AUTH_CHANNEL),95 )96 app.add_handler(incoming_telegram_download_handler)97 ##############################################################################98 incoming_purge_message_handler = MessageHandler(99 incoming_purge_message_f,100 filters=filters.command(["purge"]) & filters.chat(chats=AUTH_CHANNEL),101 )102 app.add_handler(incoming_purge_message_handler)103 ##############################################################################104 incoming_clone_handler = MessageHandler(105 g_clonee,106 filters=filters.command([f"{CLONE_COMMAND_G}"])107 & filters.chat(chats=AUTH_CHANNEL),108 )109 app.add_handler(incoming_clone_handler)110 ##############################################################################111 incoming_size_checker_handler = MessageHandler(112 check_size_g,113 filters=filters.command([f"{GET_SIZE_G}"]) & filters.chat(chats=AUTH_CHANNEL),114 )115 app.add_handler(incoming_size_checker_handler)116 ##############################################################################117 incoming_g_clear_handler = MessageHandler(118 g_clearme,119 filters=filters.command([f"{RENEWME_COMMAND}"])120 & filters.chat(chats=AUTH_CHANNEL),121 )122 app.add_handler(incoming_g_clear_handler)123 ##############################################################################124 incoming_youtube_dl_handler = MessageHandler(125 incoming_youtube_dl_f,126 filters=filters.command([YTDL_COMMAND, GYTDL_COMMAND])127 & filters.chat(chats=AUTH_CHANNEL),128 )129 app.add_handler(incoming_youtube_dl_handler)130 ##############################################################################131 incoming_youtube_playlist_dl_handler = MessageHandler(132 g_yt_playlist,133 filters=filters.command([PYTDL_COMMAND, GPYTDL_COMMAND])134 & filters.chat(chats=AUTH_CHANNEL),135 )136 app.add_handler(incoming_youtube_playlist_dl_handler)137 ##############################################################################138 status_message_handler = MessageHandler(139 status_message_f,140 filters=filters.command([f"{STATUS_COMMAND}"])141 & filters.chat(chats=AUTH_CHANNEL),142 )143 app.add_handler(status_message_handler)144 ##############################################################################145 cancel_message_handler = MessageHandler(146 cancel_message_f,147 filters=filters.command([f"{CANCEL_COMMAND_G}"])148 & filters.chat(chats=AUTH_CHANNEL),149 )150 app.add_handler(cancel_message_handler)151 ##############################################################################152 exec_message_handler = MessageHandler(153 exec_message_f,154 filters=filters.command(["exec"]) & filters.chat(chats=AUTH_CHANNEL),155 )156 app.add_handler(exec_message_handler)157 ##############################################################################158 eval_message_handler = MessageHandler(159 eval_message_f,160 filters=filters.command(["eval"]) & filters.chat(chats=AUTH_CHANNEL),161 )162 app.add_handler(eval_message_handler)163 ##############################################################################164 rename_message_handler = MessageHandler(165 rename_tg_file,166 filters=filters.command([f"{RENAME_COMMAND}"]) & filters.chat(chats=AUTH_CHANNEL),167 )168 app.add_handler(rename_message_handler)169 ##############################################################################170 upload_document_handler = MessageHandler(171 upload_document_f,172 filters=filters.command([f"{UPLOAD_COMMAND}"])173 & filters.chat(chats=AUTH_CHANNEL),174 )175 app.add_handler(upload_document_handler)176 ##############################################################################177 upload_log_handler = MessageHandler(178 upload_log_file,179 filters=filters.command([f"{LOG_COMMAND}"]) & filters.chat(chats=AUTH_CHANNEL),180 )181 app.add_handler(upload_log_handler)182 ##############################################################################183 help_text_handler = MessageHandler(184 help_message_f,185 filters=filters.command([f"{HELP_COMMAND}"]) & filters.chat(chats=AUTH_CHANNEL),186 )187 app.add_handler(help_text_handler)188 ##############################################################################189 new_join_handler = MessageHandler(190 new_join_f, filters=~filters.chat(chats=AUTH_CHANNEL)191 )192 app.add_handler(new_join_handler)193 ##############################################################################194 '''195 group_new_join_handler = MessageHandler(196 help_message_f,197 filters=filters.chat(chats=AUTH_CHANNEL) & filters.new_chat_members,198 )199 app.add_handler(group_new_join_handler)200 '''201 ##############################################################################202 call_back_button_handler = CallbackQueryHandler(button)203 app.add_handler(call_back_button_handler)204 ##############################################################################205 save_thumb_nail_handler = MessageHandler(206 save_thumb_nail,207 filters=filters.command([f"{SAVE_THUMBNAIL}"])208 & filters.chat(chats=AUTH_CHANNEL),209 )210 app.add_handler(save_thumb_nail_handler)211 ##############################################################################212 clear_thumb_nail_handler = MessageHandler(213 clear_thumb_nail,214 filters=filters.command([f"{CLEAR_THUMBNAIL}"])215 & filters.chat(chats=AUTH_CHANNEL),216 )217 app.add_handler(clear_thumb_nail_handler)218 ##############################################################################219 rclone_config_handler = MessageHandler(220 rclone_command_f, filters=filters.command([f"{RCLONE_COMMAND}"])221 )222 app.add_handler(rclone_config_handler)223 ##############################################################################224 upload_as_doc_handler = MessageHandler(225 upload_as_doc,226 filters=filters.command([f"{TOGGLE_DOC}"])227 & filters.chat(chats=AUTH_CHANNEL),228 )229 app.add_handler(upload_as_doc_handler)230 ##############################################################################231 upload_as_video_handler = MessageHandler(232 upload_as_video,233 filters=filters.command([f"{TOGGLE_VID}"])234 & filters.chat(chats=AUTH_CHANNEL),235 )236 app.add_handler(upload_as_video_handler)237 ##############################################################################238 get_speed_handler = MessageHandler(239 get_speed,240 filters=filters.command([f"{SPEEDTEST}"])241 & filters.chat(chats=AUTH_CHANNEL),242 )243 app.add_handler(get_speed_handler)244 ##############################################################################245 logging.info(f"@{(app.get_me()).username} Has Started Running...🏃💨💨")246 247 idle()248 ...

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