~jelmer/loggerhead/fix-tests

« back to all changes in this revision

Viewing changes to loggerhead/tests/test_load_test.py

  • Committer: Ubuntu One Auto Copilot
  • Author(s): Jelmer Vernooij
  • Date: 2023-02-03 20:03:20 UTC
  • mfrom: (547.1.1 lp:loggerhead)
  • Revision ID: otto-copilot@canonical.com-20230203200320-czhzowsk0q4v4g94
Upgrade Python code to a modern version

Merged from https://code.launchpad.net/~jelmer/loggerhead/pyupgrade/+merge/436797

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
class TestRequestWorker(tests.TestCaseWithTransport):
123
123
 
124
124
    def setUp(self):
125
 
        super(TestRequestWorker, self).setUp()
 
125
        super().setUp()
126
126
        self.transport_readonly_server = http_server.HttpServer
127
127
 
128
128
    def test_request_items(self):
278
278
class TestActionScriptIntegration(tests.TestCaseWithTransport):
279
279
 
280
280
    def setUp(self):
281
 
        super(TestActionScriptIntegration, self).setUp()
 
281
        super().setUp()
282
282
        self.transport_readonly_server = http_server.HttpServer
283
283
 
284
284
    def test_full_integration(self):
285
285
        self.build_tree(['first', 'second', 'third', 'fourth'])
286
286
        url = self.get_readonly_url()
287
 
        script = load_test.ActionScript.parse("""{
288
 
            "parameters": {"base_url": "%s", "blocking_timeout": 2.0},
 
287
        script = load_test.ActionScript.parse("""{{
 
288
            "parameters": {{"base_url": "{}", "blocking_timeout": 2.0}},
289
289
            "requests": [
290
 
                {"thread": "1", "relpath": "first"},
291
 
                {"thread": "2", "relpath": "second"},
292
 
                {"thread": "1", "relpath": "no-this"},
293
 
                {"thread": "2", "relpath": "or-this"},
294
 
                {"thread": "1", "relpath": "third"},
295
 
                {"thread": "2", "relpath": "fourth"}
296
 
            ]}""" % (url,))
 
290
                {{"thread": "1", "relpath": "first"}},
 
291
                {{"thread": "2", "relpath": "second"}},
 
292
                {{"thread": "1", "relpath": "no-this"}},
 
293
                {{"thread": "2", "relpath": "or-this"}},
 
294
                {{"thread": "1", "relpath": "third"}},
 
295
                {{"thread": "2", "relpath": "fourth"}}
 
296
            ]}}""".format(url))
297
297
        script.run()
298
298
        worker = script._get_worker("1")
299
299
        self.assertEqual([("first", True), ('no-this', False),
310
310
class TestRunScript(tests.TestCaseWithTransport):
311
311
 
312
312
    def setUp(self):
313
 
        super(TestRunScript, self).setUp()
 
313
        super().setUp()
314
314
        self.transport_readonly_server = http_server.HttpServer
315
315
 
316
316
    def test_run_script(self):
317
317
        self.build_tree(['file1', 'file2', 'file3', 'file4'])
318
318
        url = self.get_readonly_url()
319
 
        self.build_tree_contents([('localhost.script', """{
320
 
    "parameters": {"base_url": "%s", "blocking_timeout": 0.1},
 
319
        self.build_tree_contents([('localhost.script', """{{
 
320
    "parameters": {{"base_url": "{}", "blocking_timeout": 0.1}},
321
321
    "requests": [
322
 
        {"thread": "1", "relpath": "file1"},
323
 
        {"thread": "2", "relpath": "file2"},
324
 
        {"thread": "1", "relpath": "file3"},
325
 
        {"thread": "2", "relpath": "file4"}
 
322
        {{"thread": "1", "relpath": "file1"}},
 
323
        {{"thread": "2", "relpath": "file2"}},
 
324
        {{"thread": "1", "relpath": "file3"}},
 
325
        {{"thread": "2", "relpath": "file4"}}
326
326
    ]
327
 
}""" % (url,))])
 
327
}}""".format(url))])
328
328
        script = load_test.run_script('localhost.script')
329
329
        worker = script._threads["1"][0]
330
330
        self.assertEqual([("file1", True), ('file3', True)],