@@ -0,0 +1,1638 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0Aimport random%0Aimport re%0Aimport StringIO%0A%0Aimport d1_common.xml%0A%0Aimport d1_test.d1_test_case%0Aimport d1_test.instance_generator.identifier%0Aimport d1_test.instance_generator.system_metadata%0A%0A%0Adef generate_reproducible(client, pid=None, option_dict=None):%0A  %22%22%22Generate science object bytes and a random, fully populated System Metadata%0A  object that are always the same for a given PID.%0A%0A  The PID can be seen as a handle through which the same science object bytes%0A  and sysmeta can always be retrieved.%0A  %22%22%22%0A  option_dict = option_dict or %7B%7D%0A  pid = pid or d1_test.instance_generator.identifier.generate_pid()%0A  option_dict%5B'identifier'%5D = pid%0A  with d1_test.d1_test_case.reproducible_random_context(pid):%0A    sciobj_str = generate_reproducible_sciobj_str(pid)%0A    sysmeta_pyxb = (%0A      d1_test.instance_generator.system_metadata.generate_from_file(%0A        client, StringIO.StringIO(sciobj_str), option_dict%0A      )%0A    )%0A    return (%0A      pid, d1_common.xml.get_value(sysmeta_pyxb, 'seriesId'), sciobj_str,%0A      sysmeta_pyxb%0A    )%0A%0A%0Adef generate_reproducible_sciobj_str(pid):%0A  %22%22%22Return a science object byte string that is always the same for a given PID%0A  %22%22%22%0A  undecorated_pid = re.sub(r'%5E%3C.*?%3E', '', pid)%0A  with d1_test.d1_test_case.reproducible_random_context(undecorated_pid):%0A    return (%0A      'These are the reproducible Science Object bytes for pid=%22%7B%7D%22. '%0A      'What follows is 100 to 200 random bytes: '.%0A      format(undecorated_pid.encode('utf-8')) + str(%0A        bytearray(%0A          random.getrandbits(8) for _ in range(random.randint(100, 200))%0A        )%0A      )%0A    )%0A

Add instance generator for complete reproducible objects