Skip to content

Commit

Permalink
Merge pull request #27 from ActiDoo/develop
Browse files Browse the repository at this point in the history
Fix for several test cases
  • Loading branch information
Matthias Feldotto authored Apr 23, 2017
2 parents 91062e0 + 72b8d46 commit 522e193
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.2.2
* Fix several test cases

0.2.1
* Fix of PyPI packaging

Expand Down
2 changes: 1 addition & 1 deletion gengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from gengine.base.errors import APIError
from gengine.base.settings import set_settings

__version__ = '0.2.1'
__version__ = '0.2.2'

import datetime

Expand Down
22 changes: 11 additions & 11 deletions gengine/app/tests/test_achievement1.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ def test_evaluate_achievement_for_participate(self):

level = Achievement.evaluate(user, achievement.id, achievement_date).get("level")

Value.increase_value(variable_name="participate", user=user, value=1, key="7")
Value.increase_value(variable_name="participate", user=user, value=1, key="7", at_datetime=achievement_date)
level2 = Achievement.evaluate(user, achievement.id, achievement_date).get("level")

Value.increase_value(variable_name="participate", user=user, value=5, key="5")
Value.increase_value(variable_name="participate", user=user, value=5, key="5", at_datetime=achievement_date)
level1 = Achievement.evaluate(user, achievement.id, achievement_date).get("level")

self.assertEqual(level, 1)
Expand All @@ -284,7 +284,7 @@ def test_evaluate_achievement_for_invite_users(self):

update_connection().execute(t_values.delete())
create_variable("invite_users", variable_group="day")
Value.increase_value(variable_name="invite_users", user=user, value=1, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=1, key=None, at_datetime=achievement_date)

create_goals(achievement,
goal_goal="1*level",
Expand All @@ -296,11 +296,11 @@ def test_evaluate_achievement_for_invite_users(self):
level = Achievement.evaluate(user, achievement.id, achievement_date).get("level")
print("level: ", level)

Value.increase_value(variable_name="invite_users", user=user, value=8, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=8, key=None, at_datetime=achievement_date)
level1 = Achievement.evaluate(user, achievement.id, achievement_date).get("level")
print("level1 ", level1)

Value.increase_value(variable_name="invite_users", user=user, value=5, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=5, key=None, at_datetime=achievement_date)
level2 = Achievement.evaluate(user, achievement.id, achievement_date).get("level")
print("level2: ", level2)

Expand Down Expand Up @@ -334,7 +334,7 @@ def test_get_reward_and_properties_for_achievement(self):
create_achievement_user(user=user, achievement=achievement, achievement_date=achievement_date, level=1)

create_variable("invite_users", "none")
Value.increase_value(variable_name="invite_users", user=user, value=4, key="5")
Value.increase_value(variable_name="invite_users", user=user, value=4, key="5", at_datetime=achievement_date)

create_goals(achievement = achievement,
goal_condition="""{"term": {"type": "literal", "variable": "invite_users"}}""",
Expand Down Expand Up @@ -380,16 +380,16 @@ def test_multiple_goals_of_same_achievement(self):

variable1 = create_variable("participate_seminar", variable_group=None)
variable2 = create_variable("participate_talk", variable_group=None)
Value.increase_value(variable1.name, user, "2", "5")
Value.increase_value(variable1.name, user, "3", "7")
Value.increase_value(variable2.name, user, "3", key=None)
Value.increase_value(variable1.name, user, "2", "5", at_datetime=achievement_date)
Value.increase_value(variable1.name, user, "3", "7", at_datetime=achievement_date)
Value.increase_value(variable2.name, user, "3", key=None, at_datetime=achievement_date)

result = Achievement.evaluate(user, achievement.id, achievement_date)
print("multiple_goals_of_same_achievement:",result)
Value.increase_value(variable1.name, user, "2", "7")
Value.increase_value(variable1.name, user, "2", "7", at_datetime=achievement_date)
result1 = Achievement.evaluate(user, achievement.id, achievement_date)
print(result1)
Value.increase_value(variable2.name, user, "2", key=None)
Value.increase_value(variable2.name, user, "2", key=None, at_datetime=achievement_date)
result2 = Achievement.evaluate(user, achievement.id, achievement_date)
print(result2)

Expand Down
18 changes: 9 additions & 9 deletions gengine/app/tests/test_achievement_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_evaluate_achievement_for_weekly_evaluation_case1(self):

# User has achieved in first week and 2nd week
print("Weekly evaluation Case 1")
Value.increase_value(variable_name="invite_users", user=user, value=10, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=10, key=None, at_datetime=achievement_date)
achievement_result = Achievement.evaluate(user, achievement.id, achievement_date)
print(achievement_result)

Expand Down Expand Up @@ -81,7 +81,7 @@ def test_evaluate_achievement_for_weekly_evaluation_case2(self):

# User has not achieved in first week but in 2nd week
print("Weekly evaluation Case 2")
Value.increase_value(variable_name="invite_users", user=user, value=5, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=5, key=None, at_datetime=achievement_date)
achievement_result = Achievement.evaluate(user, achievement.id, achievement_date)
print(achievement_result)

Expand Down Expand Up @@ -123,7 +123,7 @@ def test_evaluate_achievement_for_weekly_evaluation_case3(self):

# User has not achieved in first week and achieved after few days in a same week
print("Weekly evaluation Case 3")
Value.increase_value(variable_name="invite_users", user=user, value=5, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=5, key=None, at_datetime=achievement_date)
achievement_result = Achievement.evaluate(user, achievement.id, achievement_date)
print(achievement_result)

Expand Down Expand Up @@ -168,7 +168,7 @@ def test_evaluate_achievement_for_monthly_evaluation_case1(self):
# User has achieved in this month and next month
print("Monthly evaluation Case 1")

Value.increase_value(variable_name="invite_users", user=user, value=10, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=10, key=None, at_datetime=achievement_date)
achievement_result = Achievement.evaluate(user, achievement.id, achievement_date)
print("achievement result: ", achievement_result)

Expand Down Expand Up @@ -217,7 +217,7 @@ def test_evaluate_achievement_for_monthly_evaluation_case2(self):
# User has NOT achieved in this month but in the next month
print("Monthly evaluation Case 2")

Value.increase_value(variable_name="invite_users", user=user, value=5, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=5, key=None, at_datetime=achievement_date)
achievement_result = Achievement.evaluate(user, achievement.id, achievement_date)
print("achievement result: ", achievement_result)

Expand Down Expand Up @@ -262,7 +262,7 @@ def test_evaluate_achievement_for_monthly_evaluation_case3(self):
# Not achieved in first month after some days in the same month
print("Monthly evaluation Case 3")

Value.increase_value(variable_name="invite_users", user=user, value=5, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=5, key=None, at_datetime=achievement_date)
achievement_result = Achievement.evaluate(user, achievement.id, achievement_date)
print("achievement result: ", achievement_result)

Expand Down Expand Up @@ -307,7 +307,7 @@ def test_evaluate_achievement_for_yearly_evaluation_case1(self):
# Goal achieved in both this month and next year
print("Yearly evaluation Case 1")

Value.increase_value(variable_name="invite_users", user=user, value=10, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=10, key=None, at_datetime=achievement_date)
achievement_result = Achievement.evaluate(user, achievement.id, achievement_date)
print("achievement result: ", achievement_result)

Expand Down Expand Up @@ -356,7 +356,7 @@ def test_evaluate_achievement_for_yearly_evaluation_case2(self):
# Not achieved in first year but in the second year
print("Yearly evaluation Case 2")

Value.increase_value(variable_name="invite_users", user=user, value=5, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=5, key=None, at_datetime=achievement_date)
achievement_result = Achievement.evaluate(user, achievement.id, achievement_date)
print("achievement result: ", achievement_result)

Expand Down Expand Up @@ -403,7 +403,7 @@ def test_evaluate_achievement_for_yearly_evaluation_case3(self):
# Not achieved in first month after some days in the same year
print("Yearly evaluation Case 3")

Value.increase_value(variable_name="invite_users", user=user, value=5, key=None)
Value.increase_value(variable_name="invite_users", user=user, value=5, key=None, at_datetime=achievement_date)
achievement_result = Achievement.evaluate(user, achievement.id, achievement_date)
print("achievement result: ", achievement_result)

Expand Down
8 changes: 4 additions & 4 deletions gengine/app/tests/test_eval_types_and_rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def test_friends_leaderboard(self):
goal_group_by_key=False
)

Value.increase_value(variable_name="invite_users", user=user1, value=12, key=None)
Value.increase_value(variable_name="invite_users", user=user2, value=2, key=None)
Value.increase_value(variable_name="invite_users", user=user3, value=11, key=None)
Value.increase_value(variable_name="invite_users", user=user4, value=6, key=None)
Value.increase_value(variable_name="invite_users", user=user1, value=12, key=None, at_datetime=achievement_date1)
Value.increase_value(variable_name="invite_users", user=user2, value=2, key=None, at_datetime=achievement_date1)
Value.increase_value(variable_name="invite_users", user=user3, value=11, key=None, at_datetime=achievement_date1)
Value.increase_value(variable_name="invite_users", user=user4, value=6, key=None, at_datetime=achievement_date1)

clear_all_caches()

Expand Down

0 comments on commit 522e193

Please sign in to comment.