예제 #1
0
    def test_removes_nothing_if_service_doesnt_exist(self, os_):
        service_path = '/var/run/haproxy/some-service.service'
        os_.path.exists.return_value = False

        self.assertTrue(hooks.remove_services('some-service'))

        os_.path.exists.assert_called_with(service_path)
예제 #2
0
    def test_removes_nothing_if_service_doesnt_exist(self, os_):
        service_path = '/var/run/haproxy/some-service.service'
        os_.path.exists.return_value = False

        self.assertTrue(hooks.remove_services('some-service'))

        os_.path.exists.assert_called_with(service_path)
예제 #3
0
    def test_logs_error_when_failing_to_remove_service_by_name(self, log, os_):
        error = Exception('some error')
        os_.path.exists.return_value = True
        os_.remove.side_effect = error

        self.assertFalse(hooks.remove_services('some-service'))

        log.assert_called_with(str(error))
예제 #4
0
    def test_removes_services_by_name(self, os_):
        service_path = '/var/run/haproxy/some-service.service'
        os_.path.exists.return_value = True

        self.assertTrue(hooks.remove_services('some-service'))

        os_.path.exists.assert_called_with(service_path)
        os_.remove.assert_called_with(service_path)
예제 #5
0
    def test_logs_error_when_failing_to_remove_service_by_name(self, log, os_):
        error = Exception('some error')
        os_.path.exists.return_value = True
        os_.remove.side_effect = error

        self.assertFalse(hooks.remove_services('some-service'))

        log.assert_called_with(str(error))
예제 #6
0
    def test_removes_services_by_name(self, os_):
        service_path = '/var/run/haproxy/some-service.service'
        os_.path.exists.return_value = True

        self.assertTrue(hooks.remove_services('some-service'))

        os_.path.exists.assert_called_with(service_path)
        os_.remove.assert_called_with(service_path)
예제 #7
0
    def test_logs_error_when_failing_to_remove_services(self, glob, log, os_):
        errors = [Exception('some error 1'), Exception('some error 2')]
        os_.remove.side_effect = errors
        glob.return_value = ['foo', 'bar']

        self.assertTrue(hooks.remove_services())

        log.assert_has_calls([
            call(str(errors[0])),
            call(str(errors[1])),
        ])
예제 #8
0
    def test_logs_error_when_failing_to_remove_services(self, glob, log, os_):
        errors = [Exception('some error 1'), Exception('some error 2')]
        os_.remove.side_effect = errors
        glob.return_value = ['foo', 'bar']

        self.assertTrue(hooks.remove_services())

        log.assert_has_calls([
            call(str(errors[0])),
            call(str(errors[1])),
        ])
예제 #9
0
    def test_removes_all_services_in_dir_if_name_not_provided(self, glob, os_):
        glob.return_value = ['foo', 'bar']

        self.assertTrue(hooks.remove_services())

        os_.remove.assert_has_calls([call('foo'), call('bar')])
예제 #10
0
    def test_removes_all_services_in_dir_if_name_not_provided(self, glob, os_):
        glob.return_value = ['foo', 'bar']

        self.assertTrue(hooks.remove_services())

        os_.remove.assert_has_calls([call('foo'), call('bar')])