def test_update_from_api_with_deletions(self, mock_update, mock_mark_as_deleted): mock_update.return_value = [{'a':1, 'b':2, 'deleted':True}] update_from_api(settings) mock_call = call({'a':1, 'b':2, 'deleted':True}, settings['db_conn']) self.assertEquals(mock_mark_as_deleted.call_args_list, [mock_call])
def test_update_from_api_with_updates(self, mock_update, mock_api_data, mock_persists, mock_datetime): test_datetime = datetime(2014, 01, 31, 0, 0) mock_datetime.now.return_value = test_datetime mock_update.return_value = [{'seq':1 ,'id':1, 'changes':[{'rev': '2'}]}] mock_api_data.return_value = {'_id':10, 'publisher': 'teste'} update_from_api(settings) uri = '%s/book/%s/' % (settings['scielo_uri'], 1) api_data_call = call(uri, {'rev':'2'}) persists_call = call({'datestamp': test_datetime, 'identifier':10, 'publisher': 'teste'}, settings['db_conn']) self.assertEquals(mock_api_data.call_args_list, [api_data_call]) self.assertEquals(mock_persists.call_args_list, [persists_call])
def test_update_from_api_return_none_if_no_updates(self, mock_update, mock_data): mock_update.return_value = [] resp = update_from_api(settings) self.assertEquals(resp, None) self.assertEquals(mock_data.call_count, 0)