| 81 | |
| 82 | |
| 83 | class Update(threading.Thread): |
| 84 | def __init__(self, collection, n, expect_exception): |
| 85 | threading.Thread.__init__(self) |
| 86 | self.collection = collection |
| 87 | self.n = n |
| 88 | self.expect_exception = expect_exception |
| 89 | self.daemon = True |
| 90 | |
| 91 | def run(self): |
| 92 | for _ in range(self.n): |
| 93 | error = True |
| 94 | |
| 95 | try: |
| 96 | self.collection.update_one({"test": "unique"}, {"$set": {"test": "update"}}) |
| 97 | error = False |
| 98 | except: |
| 99 | if not self.expect_exception: |
| 100 | raise |
| 101 | |
| 102 | if self.expect_exception: |
| 103 | assert error |
| 104 | |
| 105 | |
| 106 | class TestThreads(IntegrationTest): |
no outgoing calls