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')
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_)
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)
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_)
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)
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'])
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))
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_)
def test_load_failed(self): ne = error.NodeError(None) self.assertRaises(ValueError, ne.load, [])