(self)
| 670 | self.client.admin.command("configureFailPoint", "maxTimeAlwaysTimeOut", mode="off") |
| 671 | |
| 672 | def test_with_options(self): |
| 673 | codec_options = DECIMAL_CODECOPTS |
| 674 | read_preference = ReadPreference.SECONDARY_PREFERRED |
| 675 | write_concern = WriteConcern(j=True) |
| 676 | read_concern = ReadConcern(level="majority") |
| 677 | |
| 678 | # List of all options to compare. |
| 679 | allopts = [ |
| 680 | "name", |
| 681 | "client", |
| 682 | "codec_options", |
| 683 | "read_preference", |
| 684 | "write_concern", |
| 685 | "read_concern", |
| 686 | ] |
| 687 | |
| 688 | db1 = self.client.get_database( |
| 689 | "with_options_test", |
| 690 | codec_options=codec_options, |
| 691 | read_preference=read_preference, |
| 692 | write_concern=write_concern, |
| 693 | read_concern=read_concern, |
| 694 | ) |
| 695 | |
| 696 | # Case 1: swap no options |
| 697 | db2 = db1.with_options() |
| 698 | for opt in allopts: |
| 699 | self.assertEqual(getattr(db1, opt), getattr(db2, opt)) |
| 700 | |
| 701 | # Case 2: swap all options |
| 702 | newopts = { |
| 703 | "codec_options": CodecOptions(), |
| 704 | "read_preference": ReadPreference.PRIMARY, |
| 705 | "write_concern": WriteConcern(w=1), |
| 706 | "read_concern": ReadConcern(level="local"), |
| 707 | } |
| 708 | db2 = db1.with_options(**newopts) # type: ignore[arg-type, call-overload] |
| 709 | for opt in newopts: |
| 710 | self.assertEqual(getattr(db2, opt), newopts.get(opt, getattr(db1, opt))) |
| 711 | |
| 712 | |
| 713 | class TestDatabaseAggregation(IntegrationTest): |
nothing calls this directly
no test coverage detected