Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Fix unitests for trade logging #192

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

cmdclass = {}

install_requires = ['flexx >= 0.4.1',
install_requires = ['flexx == 0.4.1',
'future',
'normality == 0.6.1',
'dataset == 0.8']
Expand All @@ -26,7 +26,7 @@
'tornado == 4.3']


version = '0.9.7b0'
version = '0.9.7b1'


setup(name='abcEconomics',
Expand Down
4 changes: 2 additions & 2 deletions unittest/buy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def two(self):
oo = self.get_offers('cookies')
assert oo
for offer in oo:
if random.randint(0, 10) == 0:
if self.time % 3 == 0:
self.tests['not_answered'] = True
continue
elif random.randint(0, 10) == 0:
elif self.time % 3 == 1:
self.reject(offer)
assert self['money'] == 0
assert self['cookies'] == cookies
Expand Down
5 changes: 2 additions & 3 deletions unittest/give.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ def one(self):

def two(self):
if self.id == 1:
rnd = random.randint(0, 1)
if rnd == 0:
if self.time % 2 == 0:
msg = self.get_messages_all()
msg = msg['tpc']
self.tests['all'] = True
assert len(msg) == 1, len(msg)
elif rnd == 1:
elif self.time % 2 == 1:
msg = self.get_messages('tpc')
self.tests['topic'] = True
assert len(msg) == 1, len(msg)
Expand Down
7 changes: 4 additions & 3 deletions unittest/sell.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import random
import abcEconomics
from tools import is_zero
import random
Expand Down Expand Up @@ -29,17 +30,17 @@ def two(self):
oo = self.get_offers('cookies')
assert oo, oo
for offer in oo:
if random.randrange(0, 10) == 0:
if self.time % 4 == 0:
self.tests['not_answered'] = True
continue
elif random.randrange(0, 10) == 0:
elif self.time % 4 == 1:
self.reject(offer)
assert self['money'] == money
assert self['cookies'] == 0
self.tests['rejected'] = True
break # tests the automatic clean-up of polled offers
try:
if random.randrange(2) == 0:
if self.time % 4 == 2:
self.accept(offer)
assert self['cookies'] == offer.quantity
assert self['money'] == money - offer.quantity * offer.price
Expand Down
6 changes: 3 additions & 3 deletions unittest/start_core_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def main(processes, rounds):
s = Simulation(processes=processes, name='unittest')
s = Simulation(processes=processes, name='unittest', trade_logging='group')

print('build Buy')
buy = s.build_agents(Buy, 'buy', 1000, rounds=rounds)
Expand Down Expand Up @@ -49,7 +49,7 @@ def main(processes, rounds):


if __name__ == '__main__':
main(processes=1, rounds=3)
main(processes=1, rounds=20)
print('Iteration with 1 core finished')
main(processes=2, rounds=3)
main(processes=2, rounds=20)
print('Iteration with multiple processes finished')