Exemple #1
0
    def test_sanity_check_args(self):
        a = Main().constructor([
            'compare',
        ])
        with pytest.raises(Exception) as e:
            a.pre_sanity_check_args()
        assert 'missing --origin' in str(e.value)

        a = Main().constructor([
            'compare',
            '--origin', 'ORIGIN',
        ])
        with pytest.raises(Exception) as e:
            a.pre_sanity_check_args()
        assert 'missing --destination' in str(e.value)

        a = Main().constructor([
            'compare',
            '--origin', 'ORIGIN',
            '--destination', 'DESTINATION',
        ])
        a.pre_sanity_check_args()
        with pytest.raises(Exception) as e:
            a.post_sanity_check_args()
        assert 'missing --rule' in str(e.value)

        a = Main().constructor([
            'compare',
            '--origin', 'ORIGIN',
            '--destination', 'DESTINATION',
            '--rule', 'RULE',
            '--choose-args', 'CHOOSE ARGS',
        ])
        a.pre_sanity_check_args()
        a.post_sanity_check_args()
Exemple #2
0
    def test_sanity_check_args(self):
        a = Main().constructor([
            'optimize',
        ])
        with pytest.raises(Exception) as e:
            a.pre_sanity_check_args()
        assert 'missing --crushmap' in str(e.value)

        a = Main().constructor([
            'optimize',
            '--crushmap',
            'CRUSHMAP',
        ])
        with pytest.raises(Exception) as e:
            a.pre_sanity_check_args()
        assert 'missing --out-path' in str(e.value)

        a = Main().constructor([
            'optimize',
            '--crushmap',
            'CRUSHMAP',
            '--out-path',
            'OUT PATH',
            '--no-forecast',
        ])
        with pytest.raises(Exception) as e:
            a.pre_sanity_check_args()
        assert 'only valid with --step' in str(e.value)

        a = Main().constructor([
            'optimize',
            '--crushmap',
            'CRUSHMAP',
            '--out-path',
            'OUT PATH',
        ])
        a.pre_sanity_check_args()
        with pytest.raises(Exception) as e:
            a.post_sanity_check_args()
        assert 'missing --rule' in str(e.value)

        a = Main().constructor([
            'optimize',
            '--crushmap',
            'CRUSHMAP',
            '--out-path',
            'OUT PATH',
            '--rule',
            'RULE',
        ])
        a.pre_sanity_check_args()
        with pytest.raises(Exception) as e:
            a.post_sanity_check_args()
        assert 'missing --choose-args' in str(e.value)

        a = Main().constructor([
            'optimize',
            '--crushmap',
            'CRUSHMAP',
            '--out-path',
            'OUT PATH',
            '--rule',
            'RULE',
            '--choose-args',
            'CHOOSE ARGS',
        ])
        a.pre_sanity_check_args()
        a.post_sanity_check_args()