~ionutbalutoiu/charms/trusty/neutron-api/next

« back to all changes in this revision

Viewing changes to unit_tests/test_neutron_api_context.py

  • Committer: James Page
  • Date: 2015-09-04 11:03:14 UTC
  • mfrom: (39.7.35 trunk)
  • Revision ID: james.page@ubuntu.com-20150904110314-1iym0vseisumy5d0
[project-calico,r=james-page] Add support for Calico plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
438
438
            self.assertEquals(napi_ctxt[key], expect[key])
439
439
 
440
440
 
 
441
class EtcdContextTest(CharmTestCase):
 
442
 
 
443
    def setUp(self):
 
444
        super(EtcdContextTest, self).setUp(context, TO_PATCH)
 
445
        self.relation_get.side_effect = self.test_relation.get
 
446
        self.config.side_effect = self.test_config.get
 
447
        self.test_config.set('neutron-plugin', 'Calico')
 
448
 
 
449
    def tearDown(self):
 
450
        super(EtcdContextTest, self).tearDown()
 
451
 
 
452
    def test_etcd_no_related_units(self):
 
453
        self.related_units.return_value = []
 
454
        ctxt = context.EtcdContext()()
 
455
        expect = {'cluster': ''}
 
456
 
 
457
        self.assertEquals(expect, ctxt)
 
458
 
 
459
    def test_some_related_units(self):
 
460
        self.related_units.return_value = ['unit1']
 
461
        self.relation_ids.return_value = ['rid2', 'rid3']
 
462
        result = (
 
463
            'testname=http://172.18.18.18:8888,'
 
464
            'testname=http://172.18.18.18:8888'
 
465
        )
 
466
        self.test_relation.set({'cluster': result})
 
467
 
 
468
        ctxt = context.EtcdContext()()
 
469
        expect = {'cluster': result}
 
470
 
 
471
        self.assertEquals(expect, ctxt)
 
472
 
 
473
    def test_early_exit(self):
 
474
        self.test_config.set('neutron-plugin', 'notCalico')
 
475
 
 
476
        self.related_units.return_value = ['unit1']
 
477
        self.relation_ids.return_value = ['rid2', 'rid3']
 
478
        self.test_relation.set({'ip': '172.18.18.18',
 
479
                                'port': 8888,
 
480
                                'name': 'testname'})
 
481
 
 
482
        ctxt = context.EtcdContext()()
 
483
        expect = {'cluster': ''}
 
484
 
 
485
        self.assertEquals(expect, ctxt)
 
486
 
 
487
 
441
488
class NeutronApiSDNContextTest(CharmTestCase):
442
489
 
443
490
    def setUp(self):