You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/06/02 12:23:15 UTC

[incubator-ponymail-unit-tests] 01/05: allow setting a mock archived-at for getting around medium archiver discrepancies

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-unit-tests.git

commit 66ad0d8d0ad271593b911c6a3ae40ad0cd15d444
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Jun 2 14:00:08 2021 +0200

    allow setting a mock archived-at for getting around medium archiver discrepancies
---
 tests/test-generators.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tests/test-generators.py b/tests/test-generators.py
index 1dbd36f..aaa3daa 100755
--- a/tests/test-generators.py
+++ b/tests/test-generators.py
@@ -10,6 +10,7 @@ import yaml
 import argparse
 import collections
 import interfacer
+import email.utils
 
 parse_html = False
 nonce = None
@@ -92,6 +93,9 @@ def run_tests(args):
     errors = 0
     tests_run = 0
     yml = yaml.safe_load(open(args.load, 'r'))
+    _env = {}
+    if 'args' in yml and 'env' in yml['args']:
+        _env = yml['args']['env']
     generator_names = generators.generator_names() if hasattr(generators, 'generator_names') else ['full', 'medium', 'cluster', 'legacy']
     if args.generators:
         generator_names = args.generators
@@ -119,6 +123,13 @@ def run_tests(args):
                     key = test['index']
                     message_raw = _raw(args, mbox, key)
                     message = mbox.get(key)
+                    # Mock archived-at
+                    if 'MOCK_AAT' in _env:
+                        mock_aat = email.utils.formatdate(int(_env['MOCK_AAT']), False)
+                        try:
+                            message.replace_header('archived-at', mock_aat)
+                        except:
+                            message['archived-at'] = mock_aat
                     msgid =(message.get('message-id') or '').strip()
                     dateheader = message.get('date')
                     if args.skipnodate and not dateheader: