Exemple #1
0
    def test_populate_execute_all(self):
        data = [False, False]

        def step1(registry):
            data[0] = True

        def step2(registry):  # pragma: no cover
            data[0] = True

        self.config.ptah_populate_step('custom-step1',
                                       title='Custom step 1',
                                       active=True,
                                       factory=step1)

        self.config.ptah_populate_step('custom-step2',
                                       title='Custom step 2',
                                       active=False,
                                       factory=step2)

        sys.argv[:] = ['ptah-populate', 'ptah.ini', '-a']

        populate.main()

        self.assertTrue(data[0])
        self.assertFalse(data[1])
Exemple #2
0
    def test_populate_execute_step(self):
        data = [False]
        def step(registry):
            data[0] = True

        self.config.ptah_populate_step(
            'custom-step', title='Custom step',
            active=False, factory=step)

        sys.argv[:] = ['ptah-populate', 'ptah.ini', 'custom-step']

        populate.main()

        self.assertTrue(data[0])
Exemple #3
0
    def test_populate_no_params(self):
        sys.argv[:] = ['ptah-populate', 'ptah.ini']

        stdout = sys.stdout
        out = NativeIO()
        sys.stdout = out

        populate.main()
        sys.stdout = stdout

        val = out.getvalue()

        self.assertIn(
            'usage: ptah-populate [-h] [-l] [-a] config [step [step ...]]', val)
Exemple #4
0
    def test_populate_no_params(self):
        sys.argv[:] = ['ptah-populate', 'ptah.ini']

        stdout = sys.stdout
        out = NativeIO()
        sys.stdout = out

        populate.main()
        sys.stdout = stdout

        val = out.getvalue()

        self.assertIn(
            'usage: ptah-populate [-h] [-l] [-a] config [step [step ...]]',
            val)
Exemple #5
0
    def test_populate_execute_step(self):
        data = [False]

        def step(registry):
            data[0] = True

        self.config.ptah_populate_step('custom-step',
                                       title='Custom step',
                                       active=False,
                                       factory=step)

        sys.argv[:] = ['ptah-populate', 'ptah.ini', 'custom-step']

        populate.main()

        self.assertTrue(data[0])
Exemple #6
0
    def test_populate_list(self):
        def step(registry):
            """ """

        self.config.ptah_populate_step('custom-step',
                                       title='Custom step',
                                       active=False,
                                       factory=step)

        sys.argv[:] = ['ptah-populate', 'ptah.ini', '-l']

        stdout = sys.stdout
        out = NativeIO()
        sys.stdout = out

        populate.main()
        sys.stdout = stdout

        val = out.getvalue()

        self.assertIn('* custom-step: Custom step (inactive)', val)
Exemple #7
0
    def test_populate_list(self):

        def step(registry):
            """ """

        self.config.ptah_populate_step(
            'custom-step', title='Custom step',
            active=False, factory=step)

        sys.argv[:] = ['ptah-populate', 'ptah.ini', '-l']

        stdout = sys.stdout
        out = NativeIO()
        sys.stdout = out

        populate.main()
        sys.stdout = stdout

        val = out.getvalue()

        self.assertIn('* custom-step: Custom step (inactive)', val)
Exemple #8
0
    def test_populate_execute_all(self):
        data = [False, False]
        def step1(registry):
            data[0] = True

        def step2(registry): # pragma: no cover
            data[0] = True

        self.config.ptah_populate_step(
            'custom-step1', title='Custom step 1',
            active=True, factory=step1)

        self.config.ptah_populate_step(
            'custom-step2', title='Custom step 2',
            active=False, factory=step2)

        sys.argv[:] = ['ptah-populate', 'ptah.ini', '-a']

        populate.main()

        self.assertTrue(data[0])
        self.assertFalse(data[1])