def test_subtract(self):
        s1 = models.NamedSet()
        s2 = models.NamedSet()
        item1 = NamedItem('thename1')
        item2 = NamedItem('thename2')
        item3 = NamedItem('thename3')

        s1.add(item1)
        s2.add(item1)

        s1.add(item2)

        s2.add(item3)

        s_diff = s1 - s2

        self.assertIn(item1, s1, 's1 was modified')
        self.assertIn(item2, s1, 's1 was modified')
        self.assertNotIn(item3, s1, 's1 was modified')

        self.assertIn(item1, s2, 's2 was modified')
        self.assertNotIn(item2, s2, 's2 was modified')
        self.assertIn(item3, s2, 's2 was modified')

        self.assertNotIn(item1, s_diff, 'item1 was not removed')
        self.assertIn(item2, s_diff, 'item2 was wrongfully removed')
        self.assertNotIn(item3, s_diff, 'item3 appeared out of nowhere')
    def test_not_eq(self):
        s1 = models.NamedSet()
        s2 = models.NamedSet()
        item1 = NamedItem('thename1')
        item2 = NamedItem('thename2')

        s1.add(item1)
        s2.add(item2)

        self.assertNotEqual(s1, s2)
    def test_iter(self):
        s = models.NamedSet()
        item1 = NamedItem('thename1')
        item2 = NamedItem('thename2')
        s.add(item1)
        s.add(item2)

        s_ = set([item1, item2])

        for x in s:
            s_.remove(x)

        self.assertEqual(s_, set())
 def test_remove_no_args(self):
     s = models.NamedSet()
     self.assertRaises(TypeError, s.remove)
 def test_remove_by_item(self):
     s = models.NamedSet()
     item = NamedItem('thename')
     s.add(item)
     s.remove(item)
     self.assertNotIn(item, s)
 def test_add(self):
     s = models.NamedSet()
     item = NamedItem('thename')
     s.add(item)
     self.assertIn(item, s)
 def test_new_is_empty(self):
     s = models.NamedSet()
     self.assertEqual(list(s), [])
 def test_init(self):
     c = models.Collection()
     self.assertEqual(models.NamedSet(), c.nodes)
     self.assertEqual(models.NamedSet(), c.security_groups)
     self.assertEqual(models.NamedSet(), c.security_group_rules)