Skip to content

Instantly share code, notes, and snippets.

@mstriemer
Created July 28, 2015 23:51
Show Gist options
  • Save mstriemer/7ff3617b95866fb0ba84 to your computer and use it in GitHub Desktop.
Save mstriemer/7ff3617b95866fb0ba84 to your computer and use it in GitHub Desktop.
From d853add1fb526d9dd35a94c0e79fd1c5b80700e8 Mon Sep 17 00:00:00 2001
From: Mark Striemer <mstriemer@mozilla.com>
Date: Tue, 28 Jul 2015 18:50:01 -0500
Subject: [PATCH] Test the unlisted addon detection
---
scripts/validations.py | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/scripts/validations.py b/scripts/validations.py
index e4eb210..c6c12a0 100644
--- a/scripts/validations.py
+++ b/scripts/validations.py
@@ -106,6 +106,10 @@ def main(action):
parse_unlisted_addons()
+ process_pipeline(pipeline)
+
+
+def process_pipeline(pipeline):
# Read from STDIN.
val = sys.stdin
@@ -117,8 +121,35 @@ def main(action):
for line in val:
print line
+
+def testing():
+ def get_values(results):
+ return ((result['metadata'].get('listed'),
+ result['metadata'].get('id') is None,
+ result['metadata'].get('id') in UNLISTED_ADDONS)
+ for result in results)
+
+ def iter_len(iterable):
+ return reduce(lambda s, i: s + 1, iterable, 0)
+
+ def get_counts(results):
+ return ((r[0], iter_len(r[1])) for r in results)
+
+ parse_unlisted_addons()
+ process_pipeline([
+ parse_validations,
+ unlisted_validations,
+ get_values,
+ sorted,
+ itertools.groupby,
+ get_counts,
+ ])
+
+
if __name__ == '__main__':
- if len(sys.argv) != 2 or sys.argv[1] not in ACTIONS:
+ if True:
+ testing()
+ elif len(sys.argv) != 2 or sys.argv[1] not in ACTIONS:
print '''Usage: python {name} <action>
action: {actions}
values are read from STDIN'''.format(
--
2.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment