Example #1
0
 def test_blockchain_create_invalid_schema(self, mock_is_valid_schema):
     err_message = '[Blockchain] Validation error.'
     mock_is_valid_schema.side_effect = Mock(
         side_effect=BlockchainError(err_message))
     with self.assertRaises(BlockchainError) as err:
         Blockchain.create(self.invalid_chain)
         self.assertTrue(mock_is_valid_schema.called)
         self.assertIsInstance(err, BlockchainError)
         self.assertIn(err_message, err.message)
Example #2
0
 def test_blockchain_create_valid_schema(self, mock_is_valid_schema):
     mock_is_valid_schema.return_value = True
     blockchain = Blockchain.create(self.valid_chain)
     self.assertTrue(mock_is_valid_schema.called)
     self.assertIsInstance(blockchain, Blockchain)
     self.assertEqual(blockchain.chain, self.valid_chain)