def test__construct_chain_string(self):
        p1 = ParameterFactory.create(task=self.t,
                                     flag="-t",
                                     bool_valued=True,
                                     rest_alias="this")
        p1 = ParameterFactory.create(task=self.t,
                                     flag="-th",
                                     bool_valued=False,
                                     rest_alias="that",
                                     default=123,
                                     spacing=True)
        p1 = ParameterFactory.create(task=self.t,
                                     flag="VALUE",
                                     bool_valued=False,
                                     rest_alias="other",
                                     default="huh")

        request_contents = {
            'task1_this': 'True',
            'task1_that': 123,
            'task1_other': 'things'
        }
        steps = self.j1.steps.all().select_related('task') \
                       .extra(order_by=['ordering'])
        sd = SubmissionDetails()
        local_id = str(uuid.uuid1())
        chain_str = sd._SubmissionDetails__construct_chain_string(
            steps, request_contents, local_id, 1)
        self.assertEqual(
            chain_str, "chain(task_runner.subtask(('" + local_id +
            "', 0, 1, 1, 1, 'task1', ['-t', '-th'], "
            "{'-th': {'spacing': True, "
            "'switchless': False, 'value': 123}}, "
            "'things', 1, {}), immutable=True, "
            "queue='localhost'),).apply_async()")
    def test__construct_chain_string_with_ending_group(self):
        self.t2 = TaskFactory.create(backend=self.b,
                                     name="task2",
                                     executable="rm")
        s = StepFactory(job=self.j1, task=self.t2, ordering=1)
        self.t3 = TaskFactory.create(backend=self.b,
                                     name="task3",
                                     executable="diff")
        s = StepFactory(job=self.j1, task=self.t3, ordering=1)

        steps = self.j1.steps.all().select_related('task') \
                       .extra(order_by=['ordering'])
        sd = SubmissionDetails()
        local_id = str(uuid.uuid1())
        request_contents = {}
        chain_str = sd._SubmissionDetails__construct_chain_string(
            steps, request_contents, local_id, 1)
        # print(chain_str)
        self.assertEqual(
            chain_str, "chain(task_runner.subtask(('" + local_id +
            "', 0, 1, 1, 4, 'task1', [], {}, '', 1, {}), "
            "immutable=True, queue='localhost'), "
            "group(task_runner.subtask(('" + local_id +
            "', 1, 2, 2, 4, 'task2', [], {}, '', 1, {}), "
            "immutable=True, queue='localhost'), "
            "task_runner.subtask(('" + local_id +
            "', 1, 2, 3, 4, 'task3', [], {}, '', 1, {}), "
            "immutable=True, queue='localhost')), "
            "chord_end.subtask(('" + local_id + "', 2, 4), immutable=True, "
            "queue='localhost'),).apply_async()")
    def test__option_uses_default_if_not_passed(self):
        p1 = ParameterFactory.create(task=self.t,
                                     flag="-th",
                                     bool_valued=False,
                                     rest_alias="that",
                                     default=123,
                                     spacing=True)

        request_contents = {
            'task1_chain': 'AS',
        }
        steps = self.j1.steps.all().select_related('task') \
                       .extra(order_by=['ordering'])
        sd = SubmissionDetails()
        local_id = str(uuid.uuid1())
        chain_str = sd._SubmissionDetails__construct_chain_string(
            steps, request_contents, local_id, 1)
        # print(chain_str)
        self.assertEqual(
            chain_str, "chain(task_runner.subtask(('" + local_id +
            "', 0, 1, 1, 1, 'task1', ['-th'], "
            "{'-th': {'spacing': True, "
            "'switchless': False, 'value': '123'}}, "
            "'', 1, {}), immutable=True, "
            "queue='localhost'),).apply_async()")
    def test__construct_chain_string_high_priority(self):
        p1 = ParameterFactory.create(task=self.t, flag="-t", bool_valued=True,
                                     rest_alias="this")
        p1 = ParameterFactory.create(task=self.t, flag="-th",
                                     bool_valued=False,
                                     rest_alias="that",
                                     default=123,
                                     spacing=True)
        p1 = ParameterFactory.create(task=self.t, flag="VALUE",
                                     bool_valued=False,
                                     rest_alias="other",
                                     default="huh")

        request_contents = {'task1_this': 'True', 'task1_that': 123,
                            'task1_other': 'things'}
        steps = self.j1.steps.all().select_related('task') \
                       .extra(order_by=['ordering'])
        sd = SubmissionDetails()
        local_id = str(uuid.uuid1())
        chain_str = sd._SubmissionDetails__construct_chain_string(
                    steps, request_contents, local_id, 2)
        self.assertEqual(chain_str, "chain(task_runner.subtask(('" + local_id +
                                    "', 0, 1, 1, 1, 'task1', ['-t', '-th'], "
                                    "{'-th': {'spacing': True, "
                                    "'switchless': False, 'value': 123}}, "
                                    "'things', 1, {}), immutable=True, "
                                    "queue='high_localhost'),).apply_async()")
    def test__construct_chain_string_with_ending_group(self):
        self.t2 = TaskFactory.create(backend=self.b, name="task2",
                                     executable="rm")
        s = StepFactory(job=self.j1, task=self.t2, ordering=1)
        self.t3 = TaskFactory.create(backend=self.b, name="task3",
                                     executable="diff")
        s = StepFactory(job=self.j1, task=self.t3, ordering=1)

        steps = self.j1.steps.all().select_related('task') \
                       .extra(order_by=['ordering'])
        sd = SubmissionDetails()
        local_id = str(uuid.uuid1())
        request_contents = {}
        chain_str = sd._SubmissionDetails__construct_chain_string(
                    steps, request_contents, local_id, 1)
        # print(chain_str)
        self.assertEqual(chain_str, "chain(task_runner.subtask(('" + local_id +
                                    "', 0, 1, 1, 4, 'task1', [], {}, '', 1, {}), "
                                    "immutable=True, queue='localhost'), "
                                    "group(task_runner.subtask(('" + local_id +
                                    "', 1, 2, 2, 4, 'task2', [], {}, '', 1, {}), "
                                    "immutable=True, queue='localhost'), "
                                    "task_runner.subtask(('" + local_id +
                                    "', 1, 2, 3, 4, 'task3', [], {}, '', 1, {}), "
                                    "immutable=True, queue='localhost')), "
                                    "chord_end.subtask(('" + local_id +
                                    "', 2, 4), immutable=True, "
                                    "queue='localhost'),).apply_async()")
    def test__ensure_we_pass_more_than_one_option(self):
        p1 = ParameterFactory.create(task=self.t, flag="-th",
                                     bool_valued=False,
                                     rest_alias="that",
                                     default=123,
                                     spacing=True)
        p1 = ParameterFactory.create(task=self.t, flag="-ch",
                                     bool_valued=False,
                                     rest_alias="chain",
                                     default="CU",
                                     spacing=True)

        request_contents = {'task1_chain': 'AS', 'task1_that': 123, }
        steps = self.j1.steps.all().select_related('task') \
                       .extra(order_by=['ordering'])
        sd = SubmissionDetails()
        local_id = str(uuid.uuid1())
        chain_str = sd._SubmissionDetails__construct_chain_string(
                    steps, request_contents, local_id, 1)
        # print(chain_str)
        self.assertEqual(chain_str, "chain(task_runner.subtask(('" + local_id +
                                    "', 0, 1, 1, 1, 'task1', ['-th', '-ch'], "
                                    "{'-ch': {'spacing': True, "
                                    "'switchless': False, 'value': 'AS'}, "
                                    "'-th': {'spacing': True, "
                                    "'switchless': False, 'value': 123}}, "
                                    "'', 1, {}), immutable=True, "
                                    "queue='localhost'),).apply_async()")