コード例 #1
0
    def test_RelationshipCreate_Overrides(self):
        '''test the defaults when creating a relationship.'''
        r = Relationship(self.zp, 'CiscoDevice', 'VRF', contained=False)
        self.assertIsInstance(r, Relationship)

        r = Relationship(self.zp, 'CiscoDevice', 'VRF', type_='1-1')
        self.assertIsInstance(r, Relationship)
コード例 #2
0
 def test_ReturnsCorrectRelationships(self):
     c = self.zp.addComponentType('SampleComponent')
     r = Relationship(self.zp, 'SampleDevice', 'SampleComponent')
     self.assertEqual([r], Relationship.find(c))
     self.assertEqual([], Relationship.find(c, types='1-M'))
     self.assertEqual([r], Relationship.find(c, types=['1-M', 'M-M']))
     self.assertEqual([], Relationship.find(c, types=['1-1']))
コード例 #3
0
 def test_ReturnsCorrectRelationships(self):
     c = self.zp.addComponentType('SampleComponent')
     r = Relationship(self.zp, 'SampleDevice', 'SampleComponent')
     self.assertEqual([r], Relationship.find(c))
     self.assertEqual([], Relationship.find(c, types='1-M'))
     self.assertEqual([r], Relationship.find(c, types=['1-M', 'M-M']))
     self.assertEqual([], Relationship.find(c, types=['1-1']))
コード例 #4
0
 def test_returnsManyToManyCont(self):
     d4 = Component(self.zp, 'Device4')
     c4 = Component(self.zp, 'Component4')
     r4 = Relationship(self.zp, 'Device4', 'Component4', type_='M-M')
     self.assertEqual(
         "('component4s', ToMany(ToManyCont, 'a.b.c.Component4', 'device4s',)),", r4.toString(d4))
     self.assertEqual(
         "('device4s', ToManyCont(ToMany, 'a.b.c.Device4', 'component4s',)),", r4.toString(c4))
コード例 #5
0
 def test_returnsOneToManyCont(self):
     d = Component(self.zp, 'Device')
     c = Component(self.zp, 'Component')
     r = Relationship(self.zp, 'Device', 'Component')
     self.assertEqual(
         "('components', ToManyCont(ToOne, 'a.b.c.Component', 'device',)),", r.toString(d))
     self.assertEqual(
         "('device', ToOne(ToManyCont, 'a.b.c.Device', 'components',)),", r.toString(c))
コード例 #6
0
 def test_returnsOneToMany(self):
     d2 = Component(self.zp, 'Device2')
     c2 = Component(self.zp, 'Component2')
     r2 = Relationship(self.zp, 'Device2', 'Component2', contained=False)
     self.assertEqual(
         "('component2s', ToMany(ToOne, 'a.b.c.Component2', 'device2',)),", r2.toString(d2))
     self.assertEqual(
         "('device2', ToOne(ToMany, 'a.b.c.Device2', 'component2s',)),", r2.toString(c2))
コード例 #7
0
 def test_returnsOneToOne(self):
     d3 = Component(self.zp, 'Device3')
     c3 = Component(self.zp, 'Component3')
     r3 = Relationship(
         self.zp, 'Device3', 'Component3', contained=False, type_='1-1')
     self.assertEqual(
         "('component3', ToOne(ToOne, 'a.b.c.Component3', 'device3',)),", r3.toString(d3))
     self.assertEqual(
         "('device3', ToOne(ToOne, 'a.b.c.Device3', 'component3',)),", r3.toString(c3))
コード例 #8
0
 def test_returnsManyToMany(self):
     d5 = Component(self.zp, 'Device5')
     c5 = Component(self.zp, 'Component5')
     r5 = Relationship(
         self.zp, 'Device5', 'Component5', contained=False, type_='M-M')
     self.assertEqual(
         "('component5s', ToMany(ToMany, 'a.b.c.Component5', 'device5s',)),", r5.toString(d5))
     self.assertEqual(
         "('device5s', ToMany(ToMany, 'a.b.c.Device5', 'component5s',)),", r5.toString(c5))
コード例 #9
0
 def test_returnsOneToManyCont(self):
     d = Component(self.zp, 'Device')
     c = Component(self.zp, 'Component')
     r = Relationship(self.zp, 'Device', 'Component')
     self.assertEqual(
         "('components', ToManyCont(ToOne, 'a.b.c.Component', 'device',)),",
         r.toString(d))
     self.assertEqual(
         "('device', ToOne(ToManyCont, 'a.b.c.Device', 'components',)),",
         r.toString(c))
コード例 #10
0
 def test_returnsManyToManyCont(self):
     d4 = Component(self.zp, 'Device4')
     c4 = Component(self.zp, 'Component4')
     r4 = Relationship(self.zp, 'Device4', 'Component4', type_='M-M')
     self.assertEqual(
         "('component4s', ToMany(ToManyCont, 'a.b.c.Component4', 'device4s',)),",
         r4.toString(d4))
     self.assertEqual(
         "('device4s', ToManyCont(ToMany, 'a.b.c.Device4', 'component4s',)),",
         r4.toString(c4))
コード例 #11
0
 def test_returnsOneToMany(self):
     d2 = Component(self.zp, 'Device2')
     c2 = Component(self.zp, 'Component2')
     r2 = Relationship(self.zp, 'Device2', 'Component2', contained=False)
     self.assertEqual(
         "('component2s', ToMany(ToOne, 'a.b.c.Component2', 'device2',)),",
         r2.toString(d2))
     self.assertEqual(
         "('device2', ToOne(ToMany, 'a.b.c.Device2', 'component2s',)),",
         r2.toString(c2))
コード例 #12
0
 def test_ReturnsContainedRelationships(self):
     c = Component(self.zp, 'SampleComponent')
     c3 = Component(self.zp, 'SampleComponent3')
     r = Relationship(self.zp, 'SampleDevice', 'SampleComponent')
     r3 = Relationship(
         self.zp, 'SampleComponent3', 'SampleComponent4', contained=False)
     Relationship(self.zp, 'SampleComponent4', 'SampleComponent5')
     self.maxDiff = None
     self.assertEqual([r], Relationship.find(c, contained=True))
     self.assertEqual([r3], Relationship.find(c3, contained=False))
コード例 #13
0
 def test_ReturnsContainedRelationships(self):
     c = Component(self.zp, 'SampleComponent')
     c3 = Component(self.zp, 'SampleComponent3')
     r = Relationship(self.zp, 'SampleDevice', 'SampleComponent')
     r3 = Relationship(self.zp,
                       'SampleComponent3',
                       'SampleComponent4',
                       contained=False)
     Relationship(self.zp, 'SampleComponent4', 'SampleComponent5')
     self.maxDiff = None
     self.assertEqual([r], Relationship.find(c, contained=True))
     self.assertEqual([r3], Relationship.find(c3, contained=False))
コード例 #14
0
 def test_returnsOneToOne(self):
     d3 = Component(self.zp, 'Device3')
     c3 = Component(self.zp, 'Component3')
     r3 = Relationship(self.zp,
                       'Device3',
                       'Component3',
                       contained=False,
                       type_='1-1')
     self.assertEqual(
         "('component3', ToOne(ToOne, 'a.b.c.Component3', 'device3',)),",
         r3.toString(d3))
     self.assertEqual(
         "('device3', ToOne(ToOne, 'a.b.c.Device3', 'component3',)),",
         r3.toString(c3))
コード例 #15
0
 def test_returnsManyToMany(self):
     d5 = Component(self.zp, 'Device5')
     c5 = Component(self.zp, 'Component5')
     r5 = Relationship(self.zp,
                       'Device5',
                       'Component5',
                       contained=False,
                       type_='M-M')
     self.assertEqual(
         "('component5s', ToMany(ToMany, 'a.b.c.Component5', 'device5s',)),",
         r5.toString(d5))
     self.assertEqual(
         "('device5s', ToMany(ToMany, 'a.b.c.Device5', 'component5s',)),",
         r5.toString(c5))
コード例 #16
0
 def test_ReturnsNoRelationships(self):
     c2 = self.zp.addComponentType('SampleComponent2')
     Relationship(self.zp, 'SampleDevice', 'SampleComponent')
     self.maxDiff = None
     self.assertEqual([], Relationship.find(c2))
コード例 #17
0
 def test_RelationshipCreate_Defaults(self):
     '''test the defaults when creating a relationship.'''
     r = Relationship(self.zp, 'CiscoDevice', 'VRF')
     self.assertIsInstance(r, Relationship)
コード例 #18
0
 def test_HasComponent_False(self):
     c = self.zp.addComponentType('SampleComponent')
     r = Relationship(self.zp, 'SampleDevice', 'SampleComponent2')
     self.assertEqual(False, r.hasComponent(c))
コード例 #19
0
 def test_HasComponent_False(self):
     c = self.zp.addComponentType('SampleComponent')
     r = Relationship(self.zp, 'SampleDevice', 'SampleComponent2')
     self.assertEqual(False, r.hasComponent(c))
コード例 #20
0
 def test_ReturnsNoRelationships(self):
     c2 = self.zp.addComponentType('SampleComponent2')
     Relationship(self.zp, 'SampleDevice', 'SampleComponent')
     self.maxDiff = None
     self.assertEqual([], Relationship.find(c2))