~ubuntu-branches/ubuntu/vivid/neutron/vivid-updates

« back to all changes in this revision

Viewing changes to neutron/tests/unit/services/test_advanced_service.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-03-30 11:17:19 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20150330111719-h0gx7233p4jkkgfh
Tags: 1:2015.1~b3-0ubuntu1
* New upstream milestone release:
  - d/control: Align version requirements with upstream.
  - d/control: Add new dependency on oslo-log.
  - d/p/*: Rebase.
  - d/control,d/neutron-plugin-hyperv*: Dropped, decomposed into
    separate project upstream.
  - d/control,d/neutron-plugin-openflow*: Dropped, decomposed into
    separate project upstream.
  - d/neutron-common.install: Add neutron-rootwrap-daemon and 
    neutron-keepalived-state-change binaries.
  - d/rules: Ignore neutron-hyperv-agent when installing; only for Windows.
  - d/neutron-plugin-cisco.install: Drop neutron-cisco-cfg-agent as
    decomposed into separate project upstream.
  - d/neutron-plugin-vmware.install: Drop neutron-check-nsx-config and
    neutron-nsx-manage as decomposed into separate project upstream.
  - d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent.
* d/pydist-overrides: Add overrides for oslo packages.
* d/control: Fixup type in package description (LP: #1263539).
* d/p/fixup-driver-test-execution.patch: Cherry pick fix from upstream VCS
  to support unit test exection in out-of-tree vendor drivers.
* d/neutron-common.postinst: Allow general access to /etc/neutron but limit
  access to root/neutron to /etc/neutron/neutron.conf to support execution
  of unit tests in decomposed vendor drivers.
* d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent
  package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        super(TestAdvancedService, self).setUp()
35
35
        self.agent = mock.Mock()
36
36
        self.test_observers = event_observers.L3EventObservers()
37
 
        # Ensure no instances for each test
38
 
        FakeServiceA._instance = None
39
 
        FakeServiceB._instance = None
40
37
 
41
38
    def test_create_service(self):
42
39
        """Test agent saved and service added to observer list."""
43
 
        my_service = FakeServiceA.instance(self.agent)
 
40
        my_service = FakeServiceA(self.agent)
44
41
        self.test_observers.add(my_service)
45
42
        self.assertIn(my_service, self.test_observers.observers)
46
43
        self.assertEqual(self.agent, my_service.l3_agent)
47
44
 
48
 
    def test_service_is_singleton(self):
49
 
        """Test that two services of same time use same instance."""
50
 
        a1 = FakeServiceA.instance(self.agent)
51
 
        a2 = FakeServiceA.instance(self.agent)
52
 
        self.assertIs(a1, a2)
53
 
 
54
45
    def test_shared_observers_for_different_services(self):
55
46
        """Test different service type instances created.
56
47
 
57
48
        The services are unique instances, with different agents, but
58
49
        sharing the same observer list.
59
50
        """
60
 
        a = FakeServiceA.instance(self.agent)
 
51
        a = FakeServiceA(self.agent)
61
52
        self.test_observers.add(a)
62
53
        self.assertEqual(self.agent, a.l3_agent)
63
54
        self.assertIn(a, self.test_observers.observers)
64
55
 
65
56
        another_agent = mock.Mock()
66
 
        b = FakeServiceB.instance(another_agent)
 
57
        b = FakeServiceB(another_agent)
67
58
        self.test_observers.add(b)
68
59
        self.assertNotEqual(a, b)
69
60
        self.assertEqual(another_agent, b.l3_agent)
76
67
        The services are unique instances, shared the same agent, but
77
68
        are using different observer lists.
78
69
        """
79
 
        a = FakeServiceA.instance(self.agent)
 
70
        a = FakeServiceA(self.agent)
80
71
        self.test_observers.add(a)
81
72
        other_observers = event_observers.L3EventObservers()
82
 
        b = FakeServiceB.instance(self.agent)
 
73
        b = FakeServiceB(self.agent)
83
74
        other_observers.add(b)
84
75
 
85
76
        self.assertNotEqual(a, b)