How to use get_db_name method in autotest

Best Python code snippet using autotest_python

test_totp.py

Source: test_totp.py Github

copy

Full Screen

...40 # 1. Enable 2FA41 self.start_tour('/​web', 'totp_tour_setup', login='demo')42 # 2. Verify that RPC is blocked because 2FA is on.43 self.assertFalse(44 self.xmlrpc_common.authenticate(get_db_name(), 'demo', 'demo', {}),45 "Should not have returned a uid"46 )47 self.assertFalse(48 self.xmlrpc_common.authenticate(get_db_name(), 'demo', 'demo', {'interactive': True}),49 'Trying to fake the auth type should not work'50 )51 uid = self.env.ref('base.user_demo').id52 with self.assertRaisesRegex(Fault, r'Access Denied'):53 self.xmlrpc_object.execute_kw(54 get_db_name(), uid, 'demo',55 'res.users', 'read', [uid, ['login']]56 )57 # 3. Check 2FA is required58 self.start_tour('/​', 'totp_login_enabled', login=None)59 # 4. Check 2FA is not requested on saved device and disable it60 self.start_tour('/​', 'totp_login_device', login=None)61 # 5. Finally, check that 2FA is in fact disabled62 self.start_tour('/​', 'totp_login_disabled', login=None)63 # 6. Check that rpc is now re-allowed64 uid = self.xmlrpc_common.authenticate(get_db_name(), 'demo', 'demo', {})65 self.assertEqual(uid, self.env.ref('base.user_demo').id)66 [r] = self.xmlrpc_object.execute_kw(67 get_db_name(), uid, 'demo',68 'res.users', 'read', [uid, ['login']]69 )70 self.assertEqual(r['login'], 'demo')71 def test_totp_administration(self):72 self.start_tour('/​web', 'totp_tour_setup', login='demo')73 self.start_tour('/​web', 'totp_admin_disables', login='admin')74 self.start_tour('/​', 'totp_login_disabled', login=None)75 def test_totp_authenticate(self):76 """77 Ensure that JSON-RPC authentication works and don't return the user id78 without TOTP check79 """80 self.start_tour('/​web', 'totp_tour_setup', login='demo')81 self.url_open('/​web/​session/​logout')82 headers = {83 "Content-Type": "application/​json",84 }85 payload = {86 "jsonrpc": "2.0",87 "method": "call",88 "id": 0,89 "params": {90 "db": get_db_name(),91 "login": "demo",92 "password": "demo",93 "context": {},94 },95 }96 response = self.url_open("/​web/​session/​authenticate", data=json.dumps(payload), headers=headers)97 data = response.json()...

Full Screen

Full Screen

test_xmlrpc.py

Source: test_xmlrpc.py Github

copy

Full Screen

...7 super(TestXMLRPC, self).setUp()8 self.admin_uid = self.env.ref('base.user_admin').id9 def test_01_xmlrpc_login(self):10 """ Try to login on the common service. """11 db_name = common.get_db_name()12 uid = self.xmlrpc_common.login(db_name, 'admin', 'admin')13 self.assertEqual(uid, self.admin_uid)14 def test_xmlrpc_ir_model_search(self):15 """ Try a search on the object service. """16 o = self.xmlrpc_object17 db_name = common.get_db_name()18 ids = o.execute(db_name, self.admin_uid, 'admin', 'ir.model', 'search', [])19 self.assertIsInstance(ids, list)20 ids = o.execute(db_name, self.admin_uid, 'admin', 'ir.model', 'search', [], {})21 self.assertIsInstance(ids, list)22 def test_xmlrpc_read_group(self):23 groups = self.xmlrpc_object.execute(24 common.get_db_name(), self.admin_uid, 'admin',25 'res.partner', 'read_group', [], ['is_company', 'color'], ['parent_id']26 )27 def test_xmlrpc_name_search(self):28 self.xmlrpc_object.execute(29 common.get_db_name(), self.admin_uid, 'admin',30 'res.partner', 'name_search', "admin"31 )32 def test_jsonrpc_read_group(self):33 self._json_call(34 common.get_db_name(), self.admin_uid, 'admin',35 'res.partner', 'read_group', [], ['is_company', 'color'], ['parent_id']36 )37 def test_jsonrpc_name_search(self):38 # well that's some sexy sexy call right there39 self._json_call(40 common.get_db_name(),41 self.admin_uid, 'admin',42 'res.partner', 'name_search', 'admin'43 )44 def _json_call(self, *args):45 self.opener.post("http:/​/​%s:%s/​jsonrpc" % (common.HOST, common.PORT), json={46 'jsonrpc': '2.0',47 'id': None,48 'method': 'call',49 'params': {50 'service': 'object',51 'method': 'execute',52 'args': args53 }54 })

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Scala Testing: A Comprehensive Guide

Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

How To Choose The Right Mobile App Testing Tools

Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

Appium Testing Tutorial For Mobile Applications

The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.

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