| Testing method | Time to run test suite |
|---|---|
| SetUp | 0.354s |
| Demo Data | 0.025s |
| Patch Method | 0.002s |
| Testing method | Time to run test suite |
| from openerp.tests.common import TransactionCase | |
| class TestTheFoo(TransactionCase): | |
| def setUp(self): | |
| super(TestTheFoo, self).setUp() | |
| self.module_reg = self.registry('my.odoo.module') | |
| def test_01_call_a_module_method(self): | |
| test_foo = self.module_reg.get_foo() # should return 'foo' |
| def setUp(self): | |
| cr, uid = self.cr, self.uid | |
| super(TestTheFoo, self).setUp() | |
| self.module_reg = self.registry('my.odoo.module') | |
| self.user_reg = self.registry('res.user') | |
| test_uid = self.user_reg.search(cr, uid, [['name', '=', 'Test User']]) | |
| if not test_uid | |
| raise ValueError('Test User not found in database') | |
| def test_01_call_a_module_method(self): |
| def res_user_read_mock(*args, **kwargs): | |
| return [{'name': 'Test User'}] | |
| def setUp(self): | |
| super(TestTheFoo, self).setUp() | |
| self.module_reg = self.registry('my.odoo.module') | |
| self.user_reg = self.registry('res.user') | |
| self.user_reg._patch_method('read', res_user_read_mock) | |
| def tearDown(self): |
| def res_user_read_mock(*args, **kwargs): | |
| return res_user_read_mock.origin(*args, **kwargs) |
| # v7 call Argument mapping = [class, cursor, user id, record id, fields to get] | |
| def res_user_read_mock(*args, **kwargs): | |
| # In this case we want record id or args[3] | |
| if args[3] == 1: | |
| return [{'name': 'Test User'}] | |
| elif args[3] == 2: | |
| return [{'name': 'Another User'}] | |
| else: | |
| return [] | |
| class TestTheFoo(TransactionCase): | |
| calls_to_mock = [] | |
| def setUp(): | |
| super(TestTheFoo, self).setUp() | |
| self.calls_to_mock = [] | |
| def res_user_read_mock(*args, **kwargs): | |
| self.calls_to_mock.append({'args': args, 'kwargs': kwargs}) | |
| if len(self.calls_to_mock) > 2 |
| Answer | Score |
|---|---|
| Finding jobs that meet my needs | 8 |
| The interview | 7 |
| Dealing with tests/assignments set by potential employer | 5 |
| Filling out multi-page application forms | 4 |
| Dealing with recruiters | 3 |
| Getting and understanding feedback | 3 |
| Keeping track of the people I talk to at companies I apply for | 3 |
| Keeping my CV up to date | 2 |
| --Please note - I'm using PostgreSQL for these examples | |
| -- Question 1: Write a query that returns the total number of api_requests where the status code was 200 | |
| SELECT | |
| count(status_code) | |
| FROM api_requests | |
| WHERE status_code = 200; | |
| -- Question 2: Write a query that gives the count, and average response_ms for every api_endpoint. Sorted by the average | |
| -- I assumed here that ordering we'd be wanting to highlight the highest average | |
| SELECT |
| [ | |
| { | |
| "startDate": "2018-08-01T21:00:00", | |
| "endDate": "2018-09-01T21:00:00", | |
| "name": "Raikou Research Breakthrough" | |
| }, | |
| { | |
| "startDate": "2018-08-09T01:00:00", | |
| "endDate": "2018-08-23T01:00:00", | |
| "name": "Nest Migration #59" |