Пример #1
0
 def test_update(self):
     # Test
     list_ = error.ErrorList()
     error.NodeError(1, repo_id=None)
     error.NodeError(2, repo_id='repo_1')
     list_.update(repo_id='repo_2')
     # Verify
     for ne in list_:
         self.assertEqual(ne.details['repo_id'], 'repo_2')
Пример #2
0
 def test_extend_unique(self):
     # Test
     list_ = error.ErrorList()
     ne_1 = error.NodeError(1)
     ne_2 = error.NodeError(2)
     list_.extend([ne_1, ne_2, ne_1])
     # Verify
     self.assertEqual(len(list_), 2)
     self.assertTrue(ne_1 in list_)
     self.assertTrue(ne_2 in list_)
Пример #3
0
 def test_equals(self):
     # Test
     ne_1 = error.NodeError(1, a=1, b=2)
     ne_2 = error.NodeError(1, a=1, b=2)
     ne_3 = error.NodeError(1, a=1, b=20)
     ne_4 = error.NodeError(2, a=1, b=2)
     # Verify
     self.assertEqual(ne_1, ne_2)
     self.assertNotEqual(ne_1, ne_3)
     self.assertNotEqual(ne_2, ne_4)
Пример #4
0
 def test_append(self):
     # Test
     list_ = error.ErrorList()
     ne_1 = error.NodeError(1)
     ne_2 = error.NodeError(2)
     list_.append(ne_1)
     list_.append(ne_2)
     # Verify
     self.assertEqual(len(list_), 2)
     self.assertTrue(ne_1 in list_)
     self.assertTrue(ne_2 in list_)
Пример #5
0
 def test_constructor(self):
     # Test
     ne = error.NodeError(1, a=1, b=2)
     # Verify
     self.assertEqual(ne.error_id, 1)
     self.assertEqual(ne.details['a'], 1)
     self.assertEqual(ne.details['b'], 2)
Пример #6
0
 def test_to_dict(self):
     # Test
     ne = error.NodeError(1, a=1, b=2)
     d = ne.dict()
     # Verify
     self.assertEqual(ne.error_id, d['error_id'])
     self.assertEqual(ne.details, d['details'])
Пример #7
0
 def test_load(self):
     # Test
     d = dict(error_id=1, details=dict(a=1, b=2))
     ne = error.NodeError(None)
     ne.load(d)
     # Verify
     self.assertEqual(ne.error_id, 1)
     self.assertEqual(ne.details, dict(a=1, b=2))
Пример #8
0
 def test_extend(self):
     # Test
     list_ = error.ErrorList()
     ne = error.NodeError(1)
     list_.extend([ne])
     # Verify
     self.assertEqual(len(list_), 1)
     self.assertTrue(ne in list_)
Пример #9
0
    def test_load_failed(self):
        ne = error.NodeError(None)

        self.assertRaises(ValueError, ne.load, [])