示例#1
0
    def test_it_should_complain_when_removing_a_skill_that_is_not_installed(
            self):
        s = SkillsManager('skills')

        with patch('os.path.isdir', return_value=False):
            succeeded, failed = s.uninstall('a/skill', 'another__one',
                                            'https://github.com/a/third')

            expect(failed).to.equal(['a/skill', 'another/one', 'a/third'])
            expect(succeeded).to.be.empty
示例#2
0
    def test_it_should_uninstall_skills_correctly(self):
        s = SkillsManager('skills')
        p = os.path.abspath('skills')

        with patch('os.path.isdir', return_value=True):
            with patch('pytlas.supporting.manager.rmtree') as rmtree_mock:
                succeeded, failed = s.uninstall('a/skill', 'another__one',
                                                'https://github.com/a/third')

                expect(succeeded).to.equal(
                    ['a/skill', 'another/one', 'a/third'])
                expect(failed).to.be.empty

                expect(rmtree_mock.call_count).to.equal(3)
                rmtree_mock.assert_has_calls([
                    call(os.path.join(p, 'a__skill')),
                    call(os.path.join(p, 'another__one')),
                    call(os.path.join(p, 'a__third')),
                ])
示例#3
0
    def test_it_should_complain_when_an_error_occured_when_removing_a_skill(
            self):
        s = SkillsManager('skills')
        p = os.path.abspath('skills')

        with patch('os.path.isdir', return_value=True):
            with patch('pytlas.supporting.manager.rmtree') as rmtree_mock:
                rmtree_mock.side_effect = Exception('An error!')

                succeeded, failed = s.uninstall('a/skill', 'another__one',
                                                'https://github.com/a/third')

                expect(failed).to.equal(['a/skill', 'another/one', 'a/third'])
                expect(succeeded).to.be.empty

                expect(rmtree_mock.call_count).to.equal(3)
                rmtree_mock.assert_has_calls([
                    call(os.path.join(p, 'a__skill')),
                    call(os.path.join(p, 'another__one')),
                    call(os.path.join(p, 'a__third')),
                ])