def test_syncronize_success(self): """ Contract syncronization success """ my_contract = Contract("0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae") self.assertEqual(my_contract.last_syncronization, None) my_contract.syncronize() self.assertNotEqual(my_contract.last_syncronization, None) self.assertTrue(my_contract.last_syncronization < datetime.now())
def __init__(self, contract_address=None, contract_owner=None): # Initialize properties Contract.__init__(self, contract_address, contract_owner) self.name = None self.description = None self.timezone = None self.address = None self.location = None self.unittypes = [] self.units = []
def test_deploy_success(self, mock_api, mock_payload, mock_ressource): """ Deploy a contract with success """ # Run contract deployment my_contract = Contract() my_contract.deploy() self.assertEqual(my_contract.contract_address, "0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae") # Check calling parameters self.assertEqual(mock_api.call_args_list[0][0], ('POST', '/ressource', {'value', 'key'})) self.assertEqual(mock_payload.call_count, 1) self.assertEqual(mock_ressource.call_count, 1)
def test_syncronize_when_contract_not_deployed(self): """ Attempting to sync a contract not deployed should raise an exception """ my_contract = Contract() self.assertEqual(my_contract.last_syncronization, None) with self.assertRaises(ContractNotDeployedException): my_contract.syncronize()
def test_deploy_already_deployed(self): """ Attempting to deploy a contract already deployed should raise an exception """ my_contract = Contract("0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae") with self.assertRaises(ContractAlreadyDeployedException): my_contract.deploy()
def test_get_contract_payload_abstract_call(self): """ Getting a payload on the abstract class should raise an exception """ my_contract = Contract() with self.assertRaises(NotImplementedError): my_contract.get_contract_rest_payload()
def test_init_with_address(self): """ Test a basic initialization with address""" my_contract = Contract("0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae") self.assertEqual(my_contract.contract_address, "0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae")
def test_init_without_address(self): """ Test a basic initialization without address""" my_contract = Contract() self.assertEqual(my_contract.contract_address, None)