How to use with_services method in testcontainers-python

Best Python code snippet using testcontainers-python_python

test_serialize.py

Source: test_serialize.py Github

copy

Full Screen

...319 device = make_device(with_services=False, with_subdevices=False)320 d = Device()321 d.deserialize(json.loads(JSON_RESULT_TEST_SERIALIZE_DEVICE))322 assert d == device323def test_serialize_device_with_services():324 device = make_device(with_services=True, with_subdevices=False)325 result = json.dumps(device.serialize())326 assert result == JSON_RESULT_TEST_SERIALIZE_DEVICE_WITH_SERVICES327def test_deserialize_device_with_services():328 device = make_device(with_services=True, with_subdevices=False)329 d = Device()330 d.deserialize(json.loads(JSON_RESULT_TEST_SERIALIZE_DEVICE_WITH_SERVICES))331 assert d == device332def test_serialize_device_with_services_and_subdevices():333 device = make_device(with_services=True, with_subdevices=True)334 result = json.dumps(device.serialize())335 assert (336 result == JSON_RESULT_TEST_SERIALIZE_DEVICE_WITH_SERVICES_AND_SUBDEVICES337 )338def test_deserialize_device_with_services_and_subdevices():339 device = make_device(with_services=True, with_subdevices=True)340 d = Device()341 d.deserialize(...

Full Screen

Full Screen

test_vehicle_log.py

Source: test_vehicle_log.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors3# See license.txt4from __future__ import unicode_literals5import unittest6import frappe7from frappe.utils import cstr, flt, nowdate, random_string8from erpnext.hr.doctype.employee.test_employee import make_employee9from erpnext.hr.doctype.vehicle_log.vehicle_log import make_expense_claim10class TestVehicleLog(unittest.TestCase):11 def setUp(self):12 employee_id = frappe.db.sql("""select name from `tabEmployee` where name='testdriver@example.com'""")13 self.employee_id = employee_id[0][0] if employee_id else None14 if not self.employee_id:15 self.employee_id = make_employee("testdriver@example.com", company="_Test Company")16 self.license_plate = get_vehicle(self.employee_id)17 def tearDown(self):18 frappe.delete_doc("Vehicle", self.license_plate, force=1)19 frappe.delete_doc("Employee", self.employee_id, force=1)20 def test_make_vehicle_log_and_syncing_of_odometer_value(self):21 vehicle_log = make_vehicle_log(self.license_plate, self.employee_id)22 #checking value of vehicle odometer value on submit.23 vehicle = frappe.get_doc("Vehicle", self.license_plate)24 self.assertEqual(vehicle.last_odometer, vehicle_log.odometer)25 #checking value vehicle odometer on vehicle log cancellation.26 last_odometer = vehicle_log.last_odometer27 current_odometer = vehicle_log.odometer28 distance_travelled = current_odometer - last_odometer29 vehicle_log.cancel()30 vehicle.reload()31 self.assertEqual(vehicle.last_odometer, current_odometer - distance_travelled)32 vehicle_log.delete()33 def test_vehicle_log_fuel_expense(self):34 vehicle_log = make_vehicle_log(self.license_plate, self.employee_id)35 expense_claim = make_expense_claim(vehicle_log.name)36 fuel_expense = expense_claim.expenses[0].amount37 self.assertEqual(fuel_expense, 50*500)38 vehicle_log.cancel()39 frappe.delete_doc("Expense Claim", expense_claim.name)40 frappe.delete_doc("Vehicle Log", vehicle_log.name)41 def test_vehicle_log_with_service_expenses(self):42 vehicle_log = make_vehicle_log(self.license_plate, self.employee_id, with_services=True)43 expense_claim = make_expense_claim(vehicle_log.name)44 expenses = expense_claim.expenses[0].amount45 self.assertEqual(expenses, 27000)46 vehicle_log.cancel()47 frappe.delete_doc("Expense Claim", expense_claim.name)48 frappe.delete_doc("Vehicle Log", vehicle_log.name)49def get_vehicle(employee_id):50 license_plate=random_string(10).upper()51 vehicle = frappe.get_doc({52 "doctype": "Vehicle",53 "license_plate": cstr(license_plate),54 "make": "Maruti",55 "model": "PCM",56 "employee": employee_id,57 "last_odometer": 5000,58 "acquisition_date": nowdate(),59 "location": "Mumbai",60 "chassis_no": "1234ABCD",61 "uom": "Litre",62 "vehicle_value": flt(500000)63 })64 try:65 vehicle.insert()66 except frappe.DuplicateEntryError:67 pass68 return license_plate69def make_vehicle_log(license_plate, employee_id, with_services=False):70 vehicle_log = frappe.get_doc({71 "doctype": "Vehicle Log",72 "license_plate": cstr(license_plate),73 "employee": employee_id,74 "date": nowdate(),75 "odometer": 5010,76 "fuel_qty": flt(50),77 "price": flt(500)78 })79 if with_services:80 vehicle_log.append("service_detail", {81 "service_item": "Oil Change",82 "type": "Inspection",83 "frequency": "Mileage",84 "expense_amount": flt(500)85 })86 vehicle_log.append("service_detail", {87 "service_item": "Wheels",88 "type": "Change",89 "frequency": "Half Yearly",90 "expense_amount": flt(1500)91 })92 vehicle_log.save()93 vehicle_log.submit()...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Create Custom Menus with CSS Select

When it comes to UI components, there are two versatile methods that we can use to build it for your website: either we can use prebuilt components from a well-known library or framework, or we can develop our UI components from scratch.

How Testers Can Remain Valuable in Agile Teams

Traditional software testers must step up if they want to remain relevant in the Agile environment. Agile will most probably continue to be the leading form of the software development process in the coming years.

[LambdaTest Spartans Panel Discussion]: What Changed For Testing & QA Community And What Lies Ahead

The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.

Why does DevOps recommend shift-left testing principles?

Companies are using DevOps to quickly respond to changing market dynamics and customer requirements.

The Art of Testing the Untestable

It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?

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 testcontainers-python 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