Upload logs to the S3 bucket after tests complete.
(self, test)
| 23 | page_utils._save_data_as(data, destination_folder, file_name) |
| 24 | |
| 25 | def afterTest(self, test): |
| 26 | """Upload logs to the S3 bucket after tests complete.""" |
| 27 | from seleniumbase.core.s3_manager import S3LoggingBucket |
| 28 | |
| 29 | self.test_id = test.test.id() |
| 30 | s3_bucket = S3LoggingBucket() |
| 31 | guid = str(uuid.uuid4().hex) |
| 32 | path = os.path.join(self.options.log_path, self.test_id) |
| 33 | uploaded_files = [] |
| 34 | for logfile in os.listdir(path): |
| 35 | logfile_name = "%s/%s/%s" % ( |
| 36 | guid, |
| 37 | self.test_id, |
| 38 | logfile.split(path)[-1], |
| 39 | ) |
| 40 | s3_bucket.upload_file(logfile_name, os.path.join(path, logfile)) |
| 41 | uploaded_files.append(logfile_name) |
| 42 | s3_bucket.save_uploaded_file_names(uploaded_files) |
| 43 | index_file = s3_bucket.upload_index_file( |
| 44 | test.id(), guid, path, self.save_data_to_logs |
| 45 | ) |
| 46 | print("\n*** Log files uploaded: ***\n%s\n" % index_file) |
| 47 | |
| 48 | # If the SB database plugin is also being used, |
| 49 | # attach a link to the logs index database row. |
| 50 | if hasattr(test.test, "testcase_guid"): |
| 51 | from seleniumbase.core.testcase_manager import ( |
| 52 | TestcaseDataPayload, |
| 53 | TestcaseManager, |
| 54 | ) |
| 55 | |
| 56 | self.testcase_manager = TestcaseManager(self.options.database_env) |
| 57 | data_payload = TestcaseDataPayload() |
| 58 | data_payload.guid = test.test.testcase_guid |
| 59 | data_payload.log_url = index_file |
| 60 | self.testcase_manager.update_testcase_log_url(data_payload) |
nothing calls this directly
no test coverage detected