From d15aaa8df3b2384d497aaca53c6f52940b0b8ce0 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Mon, 8 May 2017 21:09:09 +0200
Subject: [PATCH] Add helper functions to randomly fill factories

---
 common/helpers/__init__.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/common/helpers/__init__.py b/common/helpers/__init__.py
index 5bab1621f..abe97df91 100644
--- a/common/helpers/__init__.py
+++ b/common/helpers/__init__.py
@@ -1,6 +1,8 @@
 import random
 import string
 
+from journals.constants import SCIPOST_JOURNALS_SUBMIT
+
 
 def model_form_data(model, form_class, form_kwargs={}):
     '''
@@ -38,6 +40,34 @@ def random_arxiv_identifier_without_version_number():
     return random_digits(4) + "." + random_digits(5)
 
 
+def random_scipost_journal():
+    return random.choice(SCIPOST_JOURNALS_SUBMIT)[0]
+
+
+def random_external_journal():
+    return random.choice((
+        'PhysRevA.',
+        'PhysRevB.',
+        'PhysRevC.',
+        'nature.'
+        'S0550-3213(01)',
+        '1742-5468/',
+        '0550-3213(96)'
+    ))
+
+
+def random_pub_number():
+    return '%i.%i.%s' % (random.randint(1, 9), random.randint(1, 9), random_digits(3))
+
+
+def random_scipost_doi():
+    return '10.21468/%s.%s' % (random_scipost_journal(), random_pub_number())
+
+
+def random_external_doi():
+    return '10.%s/%s%s' % (random_digits(5), random_external_journal(), random_pub_number())
+
+
 def random_digits(n):
     return "".join(random.choice(string.digits) for _ in range(n))
 
-- 
GitLab