~divmod-dev/divmod.org/trunk

« back to all changes in this revision

Viewing changes to Epsilon/epsilon/test/test_process.py

  • Committer: Jean-Paul Calderone
  • Date: 2014-06-29 20:33:04 UTC
  • mfrom: (2749.1.1 remove-epsilon-1325289)
  • Revision ID: exarkun@twistedmatrix.com-20140629203304-gdkmbwl1suei4m97
mergeĀ lp:~exarkun/divmod.org/remove-epsilon-1325289

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2008 Divmod.  See LICENSE for details.
2
 
 
3
 
"""
4
 
Tests for L{epsilon.process}.
5
 
"""
6
 
 
7
 
from zope.interface.verify import verifyObject
8
 
 
9
 
from twisted.trial.unittest import TestCase
10
 
from twisted.application.service import IService, MultiService
11
 
from twisted.internet.protocol import Protocol
12
 
 
13
 
from epsilon import process
14
 
 
15
 
 
16
 
class StandardIOServiceTests(TestCase):
17
 
    """
18
 
    Tests for L{StandardIOService}, an L{IService} implementation which
19
 
    associates a L{IProtocol} provider with stdin and stdout when it is
20
 
    started.
21
 
    """
22
 
    def test_interface(self):
23
 
        """
24
 
        L{StandardIOService} instances provide L{IService}.
25
 
        """
26
 
        verifyObject(IService, process.StandardIOService(None))
27
 
 
28
 
 
29
 
    def test_startService(self):
30
 
        """
31
 
        L{StandardIOService.startService} connects a protocol to a standard io
32
 
        transport.
33
 
        """
34
 
        # This sucks.  StandardIO sucks.  APIs should be testable.
35
 
        L = []
36
 
        self.patch(process, 'StandardIO', L.append)
37
 
        proto = Protocol()
38
 
        service = process.StandardIOService(proto)
39
 
        service.startService()
40
 
        self.assertEqual(L, [proto])
41
 
 
42
 
 
43
 
    def test_setName(self):
44
 
        """
45
 
        L{StandardIOService.setName} sets the C{name} attribute.
46
 
        """
47
 
        service = process.StandardIOService(None)
48
 
        service.setName("foo")
49
 
        self.assertEqual(service.name, "foo")
50
 
 
51
 
 
52
 
    def test_setServiceParent(self):
53
 
        """
54
 
        L{StandardIOService.setServiceParent} sets the C{parent} attribute and
55
 
        adds the service as a child of the given parent.
56
 
        """
57
 
        parent = MultiService()
58
 
        service = process.StandardIOService(None)
59
 
        service.setServiceParent(parent)
60
 
        self.assertEqual(list(parent), [service])
61
 
        self.assertIdentical(service.parent, parent)
62
 
 
63
 
 
64
 
    def test_disownServiceParent(self):
65
 
        """
66
 
        L{StandardIOService.disownServiceParent} sets the C{parent} attribute
67
 
        to C{None} and removes the service from the parent's child list.
68
 
        """
69
 
        parent = MultiService()
70
 
        service = process.StandardIOService(None)
71
 
        service.setServiceParent(parent)
72
 
        service.disownServiceParent()
73
 
        self.assertEqual(list(parent), [])
74
 
        self.assertIdentical(service.parent, None)