diff --git a/rules/0.17-allow-new-players.py b/rules/0.17-allow-new-players.py index f27ec29..db87807 100644 --- a/rules/0.17-allow-new-players.py +++ b/rules/0.17-allow-new-players.py @@ -1,3 +1,4 @@ +import os import util # This value set to 0 until we figure out a good way to prevent dummy account abuse @@ -14,11 +15,12 @@ def should_allow(pr): (points_user, points_name, points_change) = bonuses[0] - if points_user in util.users(): - raise Exception('Cannot create an existing user') + if pr.author() != points_user: + raise Exception('New players should submit their own PRs, but %s submitted the PR to add %s' % + (pr.author(), points_user)) if points_name != 'initial': - raise Exception('New player bonus value must be called "initial"') + raise Exception('New player bonus value is called "%s" instead of "initial"' % points_name) if points_change < 0: raise Exception('Points cannot be negative') @@ -27,4 +29,10 @@ def should_allow(pr): raise Exception('%s initial points exceeds maximum starting value of %s points' % (points_change, max_start_bonus)) + bonus_directory = os.path.join('players', points_user, 'bonuses') + if os.path.isdir(bonus_directory): + for bonus in os.listdir(bonus_directory): + if bonus != 'initial': + raise Exception('%s already has bonuses' % points_user) + return True diff --git a/rules/0.25-block-test-failures.py b/rules/0.25-block-test-failures.py index 500f98f..b41bdfe 100644 --- a/rules/0.25-block-test-failures.py +++ b/rules/0.25-block-test-failures.py @@ -2,6 +2,19 @@ import runpy SIMPLE_TESTS = { + '0.17-allow-new-players.py': [ + ('247', 'All file changes must be additions'), + ('250', 'not enough values to unpack (expected 4, got 2)'), + ('260', 'Added file rules/tnelling/bonuses/initial is not a bonus file'), + ('261', 'Added file players/tnelling/foo/initial is not a bonus file'), + ('253', 'File should contain a single integer.'), + ('254', 'Only one new player can be added in a PR'), + ('236', 'New players should submit their own PRs, but jeffkaufman submitted the PR to add sockpupper1'), + ('220', 'New player bonus value is called "lose-point" instead of "initial"'), + ('255', 'Points cannot be negative'), + ('225', '10 initial points exceeds maximum starting value of 0 points'), + ('258', None), + ], '0.3-allow-points-transfer.py': [ ('33', 'All file changes must be additions'), ('82', 'Points transfer PRs should not add users: got dchudz'),