def init_raises_exception_with_bad_params_test(self): with self.assertRaises(ValueError): Account(None, None) with self.assertRaises(ValueError): Account(self.connection, None) with self.assertRaises(ValueError): Account(None, 1)
def valid_result_raises_no_exceptions_test(self): def callback(resource, api_version, query_params): return json.loads(self.__VALID_RESULT) connection = MockConnection(callback) a = Account(connection, 1) a.pending_transfers()
def json_with_error_block_raises_exception_test(self): def callback(resource, api_version, query_params): return json.loads("""{"errors": "foo"}""") connection = MockConnection(callback) a = Account(connection, 1) with self.assertRaises(ExecutionFailureException): a.account_summary()
def detailed_info_requests_data_from_detailednotes_test(self): def callback(resource, api_version, query_params): self.assertEquals('accounts/1/detailednotes', resource) return json.loads(self.__VALID_RESULT) connection = MockConnection(callback) a = Account(connection, 1) a.owned_notes(detailed_info=True)
def null_enddate_is_not_converted_test(self): def callback(resource, api_version, query_params): return json.loads(self.__VALID_RESULT) connection = MockConnection(callback) a = Account(connection, 1) result = a.pending_transfers() self.assertIsNone(result[0]['endDate'])
def dates_are_converted_test(self): def callback(resource, api_version, query_params): return json.loads(self.__VALID_RESULT) connection = MockConnection(callback) a = Account(connection, 1) result = a.owned_notes() self.assertEquals(arrow.get("2009-11-12T06:34:02.000-08:00"), result[0]['issueDate'])
def no_portfolios_returns_empty_list_test(self): def callback(resource, api_version, query_params): return json.loads('{}') connection = MockConnection(callback) a = Account(connection, 1) result = a.portfolios() self.assertEquals(list, type(result)) self.assertEquals(0, len(result))
def frequencies_are_converted_test(self): def callback(resource, api_version, query_params): return json.loads(self.__VALID_RESULT) connection = MockConnection(callback) a = Account(connection, 1) result = a.pending_transfers() self.assertEquals("LOAD_ONCE", result[0]['frequency']) self.assertEquals("LOAD_ON_DAY_1_AND_16", result[3]['frequency'])
def init_succeeds_with_good_params_test(self): Account(self.connection, 1)