Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Executing section Default...
- Executing section py-analysis...
- liberapay/security/authentication.py
- | 36| def•sign_in_with_form_data(body,•state):
- | 37| ••••p•=•None
- | 38| ••••_,•website•=•state['_'],•state['website']
- | 39|
- | 40| ••••if•body.get('log-in.id'):
- | 41| ••••••••id•=•body.pop('log-in.id')
- | 42| ••••••••k•=•'email'•if•'@'•in•id•else•'username'
- | 43| ••••••••p•=•Participant.authenticate(
- | 44| ••••••••••••k,•'password',
- | 45| ••••••••••••id,•body.pop('log-in.password')
- | 46| ••••••••)
- | 47| ••••••••if•not•p:
- | 48| ••••••••••••state['sign-in.error']•=•_("Bad•username•or•password.")
- | 49| ••••••••if•p•and•p.status•==•'closed':
- | 50| ••••••••••••p.update_status('active')
- | 51|
- | 52| ••••elif•body.get('sign-in.username'):
- | 53| ••••••••if•body.pop('sign-in.terms')•!=•'agree':
- | 54| ••••••••••••raise•Response(400,•'you•have•to•agree•to•the•terms')
- | 55| ••••••••kind•=•body.pop('sign-in.kind')
- | 56| ••••••••if•kind•not•i[WARNING][15:05:49] Bear RadonBear failed to run. Take a look at debug messages for further information.
- n•('individual',•'organization'):
- | 57| ••••••••••••raise•Response(400,•'bad•kind')
- | 58| ••••••••with•website.db.get_cursor()•as•c:
- | 59| ••••••••••••p•=•Participant.make_active(
- | 60| ••••••••••••••••body.pop('sign-in.username'),•kind,•body.pop('sign-in.password'),
- | 61| ••••••••••••••••cursor=c
- | 62| ••••••••••••)
- | 63| ••••••••••••p.add_email(body.pop('sign-in.email'),•cursor=c)
- | 64| ••••••••p.authenticated•=•True
- | 65|
- | 66| ••••elif•body.get('email-login.email'):
- | 67| ••••••••email•=•body.pop('email-login.email')
- | 68| ••••••••p•=•Participant._from_thing('email',•email)
- | 69| ••••••••if•p:
- | 70| ••••••••••••p.start_session()
- | 71| ••••••••••••qs•=•{'log-in.id':•p.id,•'log-in.token':•p.session_token}
- | 72| ••••••••••••p.send_email(
- | 73| ••••••••••••••••'password_reset',
- | 74| ••••••••••••••••email=email,
- | 75| ••••••••••••••••link=p.url('settings/',•qs),
- | 76| ••••••••••••••••link_validity=SESSION_TIMEOUT,
- | 77| ••••••••••••)
- | 78| ••••••••••••state['email-login.sent-to']•=•email
- | 79| ••••••••else:
- | 80| ••••••••••••state['sign-in.error']•=•_(
- | 81| ••••••••••••••••"We•didn't•find•any•account•whose•primary•email•address•is•{0}.",
- | 82| ••••••••••••••••email
- | 83| ••••••••••••)
- | 84| ••••••••p•=•None
- | 85|
- | 86| ••••return•p
- | | [NORMAL] RadonBear:
- | | sign_in_with_form_data has a cyclomatic complexity of C
- liberapay/security/authentication.py
- | 95| def•authenticate_user_if_possible(request,•state,•user,•_):
- | 96| ••••"""This•signs•the•user•in.
- | 97| ••••"""
- | 98| ••••if•reque[WARNING][15:05:49] Bear RadonBear failed to run. Take a look at debug messages for further information.
- st.line.uri.startswith('/assets/'[WARNING][15:05:49] Bear RadonBear failed to run. Take a look at debug messages for further information.
- ):
- | 99| ••••••••return
- | 100|
- | 101| ••••#•HTTP•auth
- | 102| ••••if•'Authorization'•in•request.headers:
- | 103| ••••••••header•=•request.headers['authorization']
- | 104| ••••••••if•not•header.startswith('Basic•'):
- | 105| ••••••••••••ra[WARNING][15:05:49] Bear RadonBear failed to run. Take a look at debug messages for further information.
- ise•Response(401,•'Unsupported•authentication•method')
- | 106| •[WARNING][15:05:49] Bear RadonBear failed to run. Take a look at debug messages for further information.
- •••••••try:
- | 107| ••••••••••••creds•=•binascii.a2b_base64(header[len('Basic•'):]).split(':',•1)
- | 108| ••••••••except•binascii.Error:
- | 109| ••••••••••••raise•Response(400,•'Malformed•"Authorization"•header')
- | 110| ••••••••participant•=•Participant.authenticate('id',•'password',•*creds)
- | 111| ••••••••if•not•participant:
- | 112| ••••••••••••raise•Response(401)
- | 113| ••••••••return•{'user':•participant}
- | 114|
- | 115| ••••#•Cookie•and•form•auth
- | 116| ••••#•We•want•to•try•cookie•auth•first,•but•we•want•form•auth•to•supersede•it
- | 117| ••••p•=•None
- | 118| ••••response•=•state.setdefault('response',•Response())
- | 119| ••••if•SESSION•in•request.headers.cookie:
- | 120| ••••••••creds•=•request.headers.cookie[SESSION].value.split(':',•1)
- | 121| ••••••••p•=•Participant.authenticate('id',•'session',•*creds)
- | 122| ••••••••if•p:
- | 123| ••••••••••••state['user']•=•p
- | 124| ••••session_p,•p•=•p,•None
- | 125| ••••session_suffix•=•''
- | 126| ••••redirect_url•=•request.line.uri
- | 127| ••••if•request.method•==•'POST':
- | 128| ••••••••body•=•_get_body(request)
- | 129| ••••••••if•body:
- | 130| ••••••••••••p•=•sign_in_with_form_data(body,•state)
- | 131| ••••••••••••carry_on•=•body.pop('email-login.carry-on',•None)
- | 132| ••••••••••••if•not•p•and•carry_on:
- | 133| ••••••••••••••••p_email•=•session_p•and•(
- | 134| ••••••••••••••••••••session_p.email•or•session_p.get_emails()[0].address
- | 135| ••••••••••••••••)
- | 136| ••••••••••••••••if•p_email•!=•carry_on:
- | 137| ••••••••••••••••••••state['email-login.carry-on']•=•carry_on
- | 138| ••••••••••••••••••••raise•AuthRequired
- | 139| ••••••••••••redirect_url•=•body.get('sign-in.back-to')•or•redirect_url
- | 140| ••••elif•request.method•==•'GET'•and•request.qs.get('log-in.id'):
- | 141| ••••••••id,•token•=•request.qs.pop('log-in.id'),•request.qs.pop('log-in.token')
- | 142| ••••••••p•=•Participant.authenticate('id',•'session',•id,•token)
- | 143| ••••••••if•not•p•and•(not•session_p•or•session_p.id•!=•id):
- | 144| ••••••••••••raise•Response(400,•_("This•login•link•is•expired•or•invalid."))
- | 145| ••••••••else:
- | 146| ••••••••••••qs•=•'?'•+•urlencode(request.qs,•doseq=True)•if•request.qs•else•''
- | 147| ••••••••••••redirect_url•=•request.path.raw•+•qs
- | 148| ••••••••••••session_p•=•p
- | 149| ••••••••••••session_suffix•=•'.em'
- | 150| ••••if•p:
- | 151| ••••••••if•session_p:
- | 152| ••••••••••••session_p.sign_out(response.headers.cookie)
- | 153| ••••••••p.sign_in(response.headers.cookie,•session_suffix)
- | 154| ••••••••state['user']•=•p
- | 155| ••••••••if•request.body.pop('form.repost',•None)•!=•'true':
- | 156| ••••••••••••response.redirect(redirect_url)
- | | [NORMAL] RadonBear:
- | | authenticate_user_if_possible has a cyclomatic complexity of D
- liberapay/models/participant.py
- | 168| ••••@classmethod
- | 169| ••••def•authenticate(cls,•k1,•k2,•v1=None,•v2=None):
- | 170| ••••••••assert•k1•in•('id',•'username',•'email')
- | 171| ••••••••if•not•(v1•and•v2):
- | 172| ••••••••••••return
- | 173| ••••••••if•k1•==•'username':
- | 174| ••••••••••••k1•=•'lower(username)'
- | 175| ••••••••••••v1•=•v1.lower()
- | 176| ••••••••p•=•cls._from_thing(k1,•v1)
- | 177| ••••••••if•not•p:
- | 178| ••••••••••••return
- | 179| ••••••••if•k2•==•'session':
- | 180| ••••••••••••if•not•p.session_token:
- | 181| ••••••••••••••••return
- | 182| ••••••••••••if•p.session_expires•<•utcnow():
- | 183| ••••••••••••••••return
- | 184| ••••••••••••if•constant_time_compare(p.session_token,•v2):
- | 185| ••••••••••••••••p.authenticated•=•True
- | 186| ••••••••••••••••return•p
- | 187| ••••••••elif•k2•==•'password':
- | 188| ••••••••••••if•not•p.password:
- | 189| ••••••••••••••••return
- | 190| ••••••••••••algo,•rounds,•salt,•hashed•=•p.password.split('$',•3)
- | 191| ••••••••••••rounds•=•int(rounds)
- | 192| ••••••••••••salt,•hashed•=•b64decode(salt),•b64decode(hashed)
- | 193| ••••••••••••if•cls._hash_password(v2,•algo,•salt,•rounds)•==•hashed:
- | 194| ••••••••••••••••p.authenticated•=•True
- | 195| ••••••••••••••••return•p
- | | [NORMAL] RadonBear:
- | | authenticate has a cyclomatic complexity of C
- liberapay/models/participant.py
- | 524| ••••def•add_email(self,•email,•cursor=None):
- | 525| ••••••••"""
- | 526| ••••••••••••This•is•called•when
- | 527| ••••••••••••1)•Adding•a•new•email•address
- | 528| ••••••••••••2)•Resending•the•verification•email•for•an•unverified•email•address
- | 529|
- | 530| ••••••••••••Returns•the•number•of•emails•sent.
- | 531| ••••••••"""
- | 532|
- | 533| ••••••••if•not•EMAIL_RE.match(email):
- | 534| ••••••••••••raise•BadEmailAddress(email)
- | 535|
- | 536| ••••••••#•Check•that•this•address•isn't•already•verified
- | 537| ••••••••owner•=•(cursor•or•self.db).one("""
- | 538| ••••••••••••SELECT•participant
- | 539| ••••••••••••••FROM•emails
- | 540| •••••••••••••WHERE•address•=•%(email)s
- | 541| •••••••••••••••AND•verified•IS•true
- | 542| ••••••••""",•locals())
- | 543| ••••••••if•owner:
- | 544| ••••••••••••if•owner•==•self.id:
- | 545| ••••••••••••••••return•0
- | 546| ••••••••••••else:
- | 547| ••••••••••••••••raise•EmailAlreadyTaken(email)
- | 548|
- | 549| ••••••••if•len(self.get_emails())•>•9:
- | 550| ••••••••••••raise•TooManyEmailAddresses(email)
- | 551|
- | 552| ••••••••nonce•=•str(uuid.uuid4())
- | 553| ••••••••added_time•=•utcnow()
- | 554| ••••••••try:
- | 555| ••••••••••••with•self.db.get_cursor(cursor)•as•c:
- | 556| ••••••••••••••••self.add_event(c,•'add_email',•email)
- | 557| ••••••••••••••••c.run("""
- | 558| ••••••••••••••••••••INSERT•INTO•emails
- | 559| ••••••••••••••••••••••••••••••••(address,•nonce,•added_time,•participant)
- | 560| •••••••••••••••••••••••••VALUES•(%s,•%s,•%s,•%s)
- | 561| ••••••••••••••••""",•(email,•nonce,•added_time,•self.id))
- | 562| ••••••••except•IntegrityError:
- | 563| ••••••••••••nonce•=•(cursor•or•self.db).one("""
- | 564| ••••••••••••••••UPDATE•emails
- | 565| •••••••••••••••••••SET•added_time=%s
- | 566| •••••••••••••••••WHERE•participant=%s
- | 567| •••••••••••••••••••AND•address=%s
- | 568| •••••••••••••••••••AND•verified•IS•NULL
- | 569| •••••••••••••RETURNING•nonce
- | 570| ••••••••••••""",•(added_time,•self.id,•email))
- | 571| ••••••••••••if•not•nonce:
- | 572| ••••••••••••••••return•self.add_email(email)
- | 573|
- | 574| ••••••••scheme•=•website.canonical_scheme
- | 575| ••••••••host•=•website.canonical_host
- | 576| ••••••••username•=•self.username
- | 577| ••••••••base64_email•=•b64encode_s(email)
- | 578| ••••••••link•=•"{scheme}://{host}/{username}/emails/verify.html?email64={base64_email}&nonce={nonce}"
- | 579| ••••••••r•=•self.send_email('verification',•email=email,•link=link.format(**locals()))
- | 580| ••••••••assert•r•==•1•#•Make•sure•the•verification•email•was•sent
- | 581|
- | 582| ••••••••if•self.email:
- | 583| ••••••••••••self.send_email('verification_notice',•new_email=email)
- | 584| ••••••••••••return•2
- | 585| ••••••••else:
- | 586| ••••••••••••self.update_avatar(cursor=cursor)
- | 587|
- | 588| ••••••••return•1
- | | [NORMAL] RadonBear:
- | | add_email has a cyclomatic complexity of C
- liberapay/models/participant.py
- |1017| ••••def•update_avatar(self,•src=None,•cursor=None):
- |1018| ••••••••if•self.status•==•'stub':
- |1019| ••••••••••••assert•src•is•None
- |1020|
- |1021| ••••••••src•=•self.avatar_src•if•src•is•None•else•src
- |1022| ••••••••platform,•key•=•src.split(':',•1)•if•src•else•(None,•None)
- |1023| ••••••••email•=•self.avatar_email•or•self.email•or•self.get_any_email(cursor)
- |1024|
- |1025| ••••••••if•platform•==•'libravatar'•or•platform•is•None•and•email:
- |1026| ••••••••••••if•not•email:
- |1027| ••••••••••••••••return
- |1028| ••••••••••••avatar_id•=•md5(email.strip().lower()).hexdigest()
- |1029| ••••••••••••avatar_url•=•'https://seccdn.libravatar.org/avatar/'+avatar_id
- |1030| ••••••••••••avatar_url•+=•AVATAR_QUERY
- |1031|
- |1032| ••••••••elif•platform•is•None:
- |1033| ••••••••••••avatar_url•=•(cursor•or•self.db).one("""
- |1034| ••••••••••••••••SELECT•avatar_url
- |1035| ••••••••••••••••••FROM•elsewhere
- |1036| •••••••••••••••••WHERE•participant•=•%s
- |1037| ••••••••••••••ORDER•BY•platform•=•'github'•DESC,
- |1038| •••••••••••••••••••••••avatar_url•LIKE•'%%libravatar.org%%'•DESC,
- |1039| •••••••••••••••••••••••avatar_url•LIKE•'%%gravatar.com%%'•DESC
- |1040| •••••••••••••••••LIMIT•1
- |1041| ••••••••••••""",•(self.id,))
- |1042|
- |1043| ••••••••else:
- |1044| ••••••••••••avatar_url•=•(cursor•or•self.db).one("""
- |1045| ••••••••••••••••SELECT•avatar_url
- |1046| ••••••••••••••••••FROM•elsewhere
- |1047| •••••••••••••••••WHERE•participant•=•%s
- |1048| •••••••••••••••••••AND•platform•=•%s
- |1049| ••••••••••••••••--•AND•user_id•=•%%s••--•not•implemented•yet
- |1050| ••••••••••••""",•(self.id,•platform))
- |1051|
- |1052| ••••••••if•not•avatar_url:
- |1053| ••••••••••••return
- |1054|
- |1055| ••••••••(cursor•or•self.db).run("""
- |1056| ••••••••••••UPDATE•participants
- |1057| •••••••••••••••SET•avatar_url•=•%s
- |1058| •••••••••••••••••,•avatar_src•=•%s
- |1059| •••••••••••••WHERE•id•=•%s
- |1060| ••••••••""",•(avatar_url,•src,•self.id))
- |1061| ••••••••self.set_attributes(avatar_src=src,•avatar_url=avatar_url)
- |1062|
- |1063| ••••••••return•avatar_url
- | | [NORMAL] RadonBear:
- | | update_avatar has a cyclomatic complexity of C
- liberapay/models/participant.py
- |1174| ••••def•set_tip_to(self,•tippee,•amount,•update_self=True,•update_tippee=True,•cursor=None):
- |1175| ••••••••"""Given•a•Participant•or•username,•and•amount•as•str,•returns•a•dict.
- |1176|
- |1177| ••••••••We•INSERT•instead•of•UPDATE,•so•that•we•have•history•to•explore.•The
- |1178| ••••••••COALESCE•function•returns•the•first•of•its•arguments•that•is•not•NULL.
- |1179| ••••••••The•effect•here•is•to•stamp•all•tips•with•the•timestamp•of•the•first
- |1180| ••••••••tip•from•this•user•to•that.•I•believe•this•is•used•to•determine•the
- |1181| ••••••••order•of•transfers•during•payday.
- |1182|
- |1183| ••••••••The•dict•returned•represents•the•row•inserted•in•the•tips•table,•with
- |1184| ••••••••an•additional•boolean•indicating•whether•this•is•the•first•time•this
- |1185| ••••••••tipper•has•tipped•(we•want•to•track•that•as•part•of•our•conversion
- |1186| ••••••••funnel).
- |1187|
- |1188| ••••••••"""
- |1189| ••••••••assert•self.status•==•'active'••#•sanity•check
- |1190|
- |1191| ••••••••if•isinstance(tippee,•AccountElsewhere):
- |1192| ••••••••••••tippee•=•tippee.participant
- |1193| ••••••••elif•not•isinstance(tippee,•Participant):
- |1194| ••••••••••••tippee,•u•=•Participant.from_username(tippee),•tippee
- |1195| ••••••••••••if•not•tippee:
- |1196| ••••••••••••••••raise•NoTippee(u)
- |1197|
- |1198| ••••••••if•self.id•==•tippee.id:
- |1199| ••••••••••••raise•NoSelfTipping
- |1200|
- |1201| ••••••••amount•=•Decimal(amount)••#•May•raise•InvalidOperation
- |1202| ••••••••if•amount•!=•0•and•amount•<•MIN_TIP•or•amount•>•MAX_TIP:
- |1203| ••••••••••••raise•BadAmount(amount)
- |1204|
- |1205| ••••••••if•not•tippee.accepts_tips•and•amount•!=•0:
- |1206| ••••••••••••raise•UserDoesntAcceptTips(tippee.username)
- |1207|
- |1208| ••••••••#•Insert•tip
- |1209| ••••••••NEW_TIP•=•"""\
- |1210|
- |1211| ••••••••••••INSERT•INTO•tips
- |1212| ••••••••••••••••••••••••(ctime,•tipper,•tippee,•amount)
- |1213| •••••••••••••••••VALUES•(•COALESCE•((•SELECT•ctime
- |1214| ••••••••••••••••••••••••••••••••••••••••FROM•tips
- |1215| •••••••••••••••••••••••••••••••••••••••WHERE•(tipper=%(tipper)s•AND•tippee=%(tippee)s)
- |1216| •••••••••••••••••••••••••••••••••••••••LIMIT•1
- |1217| ••••••••••••••••••••••••••••••••••••••),•CURRENT_TIMESTAMP)
- |1218| ••••••••••••••••••••••••,•%(tipper)s,•%(tippee)s,•%(amount)s
- |1219| •••••••••••••••••••••••••)
- |1220| ••••••••••••••RETURNING•*
- |1221| ••••••••••••••••••••••,•(•SELECT•count(*)•=•0•FROM•tips•WHERE•tipper=%(tipper)s•)•AS•first_time_tipper
- |1222| ••••••••••••••••••••••,•(•SELECT•join_time•IS•NULL•FROM•participants•WHERE•id•=•%(tippee)s•)•AS•is_pledge
- |1223|
- |1224| ••••••••"""
- |1225| ••••••••args•=•dict(tipper=self.id,•tippee=tippee.id,•amount=amount)
- |1226| ••••••••t•=•(cursor•or•self.db).one(NEW_TIP,•args)._asdict()
- |1227|
- |1228| ••••••••if•update_self:
- |1229| ••••••••••••#•Update•giving•amount•of•tipper
- |1230| ••••••••••••updated•=•self.update_giving(cursor)
- |1231| ••••••••••••for•u•in•updated:
- |1232| ••••••••••••••••if•u.id•==•t['id']:
- |1233| ••••••••••••••••••••t['is_funded']•=•u.is_funded
- |1234| ••••••••if•update_tippee:
- |1235| ••••••••••••#•Update•receiving•amount•of•tippee
- |1236| ••••••••••••tippee.update_receiving(cursor)
- |1237|
- |1238| ••••••••return•t
- | | [NORMAL] RadonBear:
- | | set_tip_to has a cyclomatic complexity of C
- liberapay/models/participant.py
- |1463| ••••def•take_over(self,•account,•have_confirmation=False):
- |1464| ••••••••"""Given•an•AccountElsewhere•or•a•tuple•(platform_name,•user_id),
- |1465| ••••••••associate•an•elsewhere•account.
- |1466|
- |1467| ••••••••Returns•None•or•raises•NeedConfirmation.
- |1468|
- |1469| ••••••••This•method•associates•an•account•on•another•platform•(GitHub,•Twitter,
- |1470| ••••••••etc.)•with•the•given•Liberapay•participant.•Every•account•elsewhere•has•an
- |1471| ••••••••associated•Liberapay•participant•account,•even•if•its•only•a•stub
- |1472| ••••••••participant•(it•allows•us•to•track•pledges•to•that•account•should•they
- |1473| ••••••••ever•decide•to•join•Liberapay).
- |1474|
- |1475| ••••••••In•certain•circumstances,•we•want•to•present•the•user•with•a
- |1476| ••••••••confirmation•before•proceeding•to•transfer•the•account•elsewhere•to
- |1477| ••••••••the•new•Liberapay•account;•NeedConfirmation•is•the•signal•to•request
- |1478| ••••••••confirmation.
- |1479| ••••••••"""
- |1480|
- |1481| ••••••••if•isinstance(account,•AccountElsewhere):
- |1482| ••••••••••••platform,•user_id•=•account.platform,•account.user_id
- |1483| ••••••••else:
- |1484| ••••••••••••platform,•user_id•=•map(str,•account)
- |1485|
- |1486| ••••••••CREATE_TEMP_TABLE_FOR_TIPS•=•"""
- |1487| ••••••••••••CREATE•TEMP•TABLE•temp_tips•ON•COMMIT•drop•AS
- |1488| ••••••••••••••••SELECT•ctime,•tipper,•tippee,•amount,•is_funded
- |1489| ••••••••••••••••••FROM•current_tips
- |1490| •••••••••••••••••WHERE•(tippee•=•%(dead)s•OR•tippee•=•%(live)s)
- |1491| •••••••••••••••••••AND•amount•>•0;
- |1492| ••••••••"""
- |1493|
- |1494| ••••••••CONSOLIDATE_TIPS_RECEIVING•=•"""
- |1495| ••••••••••••--•Create•a•new•set•of•tips,•one•for•each•current•tip•*to*•either
- |1496| ••••••••••••--•the•dead•or•the•live•account.•If•a•user•was•tipping•both•the
- |1497| ••••••••••••--•dead•and•the•live•account,•then•we•create•one•new•combined•tip
- |1498| ••••••••••••--•to•the•live•account•(via•the•GROUP•BY•and•sum()).
- |1499| ••••••••••••INSERT•INTO•tips•(ctime,•tipper,•tippee,•amount,•is_funded)
- |1500| •••••••••••••••••SELECT•min(ctime),•tipper,•%(live)s•AS•tippee,•sum(amount),•bool_and(is_funded)
- |1501| •••••••••••••••••••FROM•temp_tips
- |1502| ••••••••••••••••••WHERE•(tippee•=•%(dead)s•OR•tippee•=•%(live)s)
- |1503| ••••••••••••••••••••••••--•Include•tips•*to*•either•the•dead•or•live•account.
- |1504| ••••••••••••••••AND•NOT•(tipper•=•%(dead)s•OR•tipper•=•%(live)s)
- |1505| ••••••••••••••••••••••••--•Don't•include•tips•*from*•the•dead•or•live•account,
- |1506| ••••••••••••••••••••••••--•lest•we•convert•cross-tipping•to•self-tipping.
- |1507| •••••••••••••••GROUP•BY•tipper
- |1508| ••••••••"""
- |1509|
- |1510| ••••••••ZERO_OUT_OLD_TIPS_RECEIVING•=•"""
- |1511| ••••••••••••INSERT•INTO•tips•(ctime,•tipper,•tippee,•amount)
- |1512| ••••••••••••••••SELECT•ctime,•tipper,•tippee,•0•AS•amount
- |1513| ••••••••••••••••••FROM•temp_tips
- |1514| •••••••••••••••••WHERE•tippee=%s
- |1515| ••••••••"""
- |1516|
- |1517| ••••••••with•self.db.get_cursor()•as•cursor:
- |1518|
- |1519| ••••••••••••#•Load•the•existing•connection
- |1520| ••••••••••••#•Every•account•elsewhere•has•at•least•a•stub•participant•account
- |1521| ••••••••••••#•on•Liberapay.
- |1522| ••••••••••••elsewhere•=•cursor.one("""
- |1523| ••••••••••••••••SELECT•e.*::elsewhere_with_participant
- |1524| ••••••••••••••••••FROM•elsewhere•e
- |1525| ••••••••••••••••••JOIN•participants•p•ON•p.id•=•e.participant
- |1526| •••••••••••••••••WHERE•e.platform=%s•AND•e.user_id=%s
- |1527| ••••••••••••""",•(platform,•user_id),•default=Exception)
- |1528| ••••••••••••other•=•elsewhere.participant
- |1529|
- |1530| ••••••••••••if•self.id•==•other.id:
- |1531| ••••••••••••••••#•this•is•a•no•op•-•trying•to•take•over•itself
- |1532| ••••••••••••••••return
- |1533|
- |1534| ••••••••••••#•Save•old•tips•so•we•can•notify•patrons•that•they've•been•claimed
- |1535| ••••••••••••old_tips•=•other.get_tips_receiving()•if•other.status•==•'stub'•else•None
- |1536|
- |1537| ••••••••••••#•Make•sure•we•have•user•confirmation•if•needed.
- |1538| ••••••••••••#•==============================================
- |1539| ••••••••••••#•We•need•confirmation•if•any•of•these•are•true:
- |1540| ••••••••••••#
- |1541| ••••••••••••#•••-•the•other•participant•is•not•a•stub;•we•are•taking•the
- |1542| ••••••••••••#•••••••account•elsewhere•away•from•another•viable•participant
- |1543| ••••••••••••#
- |1544| ••••••••••••#•••-•we•already•have•an•account•elsewhere•connected•from•the•given
- |1545| ••••••••••••#•••••••platform,•and•it•will•be•handed•off•to•a•new•stub
- |1546| ••••••••••••#•••••••participant
- |1547|
- |1548| ••••••••••••other_is_a_real_participant•=•other.status•!=•'stub'
- |1549|
- |1550| ••••••••••••we_already_have_that_kind_of_account•=•cursor.one("""
- |1551| ••••••••••••••••SELECT•true
- |1552| ••••••••••••••••••FROM•elsewhere
- |1553| •••••••••••••••••WHERE•participant=%s•AND•platform=%s
- |1554| ••••••••••••""",•(self.id,•platform),•default=False)
- |1555|
- |1556| ••••••••••••need_confirmation•=•NeedConfirmation(
- |1557| ••••••••••••••••other_is_a_real_participant,
- |1558| ••••••••••••••••we_already_have_that_kind_of_account,
- |1559| ••••••••••••)
- |1560| ••••••••••••if•need_confirmation•and•not•have_confirmation:
- |1561| ••••••••••••••••raise•need_confirmation
- |1562|
- |1563| ••••••••••••#•Move•any•old•account•out•of•the•way
- |1564| ••••••••••••if•we_already_have_that_kind_of_account:
- |1565| ••••••••••••••••new_stub•=•Participant.make_stub(cursor)
- |1566| ••••••••••••••••cursor.run(•"UPDATE•elsewhere•SET•participant=%s•"
- |1567| ••••••••••••••••••••••••••••"WHERE•platform=%s•AND•participant=%s"
- |1568| ••••••••••••••••••••••••••,•(new_stub.id,•platform,•self.id)
- |1569| •••••••••••••••••••••••••••)
- |1570|
- |1571| ••••••••••••#•Do•the•deal
- |1572| ••••••••••••cursor.run(•"UPDATE•elsewhere•SET•participant=%s•"
- |1573| ••••••••••••••••••••••••"WHERE•platform=%s•AND•user_id=%s"
- |1574| ••••••••••••••••••••••,•(self.id,•platform,•user_id)
- |1575| •••••••••••••••••••••••)
- |1576|
- |1577| ••••••••••••#•Turn•pledges•into•actual•tips
- |1578| ••••••••••••if•old_tips:
- |1579| ••••••••••••••••x,•y•=•self.id,•other.id
- |1580| ••••••••••••••••cursor.run(CREATE_TEMP_TABLE_FOR_TIPS,•dict(live=x,•dead=y))
- |1581| ••••••••••••••••cursor.run(CONSOLIDATE_TIPS_RECEIVING,•dict(live=x,•dead=y))
- |1582| ••••••••••••••••cursor.run(ZERO_OUT_OLD_TIPS_RECEIVING,•(other.id,))
- |1583|
- |1584| ••••••••••••#•Try•to•delete•the•stub•account,•or•prevent•new•pledges•to•it
- |1585| ••••••••••••if•not•other_is_a_real_participant:
- |1586| ••••••••••••••••cursor.run("""
- |1587| ••••••••••••••••••••DO•$$
- |1588| ••••••••••••••••••••BEGIN
- |1589| ••••••••••••••••••••••••DELETE•FROM•participants•WHERE•id•=•%(dead)s;
- |1590| ••••••••••••••••••••EXCEPTION•WHEN•OTHERS•THEN
- |1591| ••••••••••••••••••••••••UPDATE•participants
- |1592| •••••••••••••••••••••••••••SET•goal•=•-1
- |1593| •••••••••••••••••••••••••WHERE•id•=•%(dead)s;
- |1594| ••••••••••••••••••••END;
- |1595| ••••••••••••••••••••$$•LANGUAGE•plpgsql;
- |1596| ••••••••••••••••""",•dict(dead=other.id))
- |1597|
- |1598| ••••••••••••#•Log•the•event
- |1599| ••••••••••••payload•=•dict(platform=platform,•user_id=user_id,•owner=other.id)
- |1600| ••••••••••••self.add_event(cursor,•'take-over',•payload)
- |1601|
- |1602| ••••••••if•old_tips:
- |1603| ••••••••••••self.notify_patrons(elsewhere,•tips=old_tips)
- |1604|
- |1605| ••••••••self.update_avatar()
- |1606|
- |1607| ••••••••#•Note:•the•order•matters•here,•receiving•needs•to•be•updated•before•giving
- |1608| ••••••••self.update_receiving()
- |1609| ••••••••self.update_giving()
- | | [NORMAL] RadonBear:
- | | take_over has a cyclomatic complexity of C
- liberapay/billing/payday.py
- | 94| ••••def•shuffle(self,•log_dir=''):
- | 95| ••••••••self.transfers_filename•=•log_dir+'payday-%s_transfers.pickle'•%•self.id
- | 96| ••••••••if•os.path.exists(self.transfers_filename):
- | 97| ••••••••••••with•open(self.transfers_filename,•'rb')•as•f:
- | 98| ••••••••••••••••transfers•=•pickle.load(f)
- | 99| ••••••••••••done•=•self.db.all("""
- | 100| ••••••••••••••••SELECT•*
- | 101| ••••••••••••••••••FROM•transfers•t
- | 102| •••••••••••••••••WHERE•t.timestamp•>=•%(ts_start)s;
- | 103| ••••••••••••""",•dict(ts_start=self.ts_start))
- | 104| ••••••••••••done•=•set((t.tipper,•t.tippee,•t.context,•t.team)•for•t•in•done)
- | 105| ••••••••••••transfers•=•[t•for•t•in•transfers•if•(t.tipper,•t.tippee,•t.context,•t.team)•not•in•done]
- | 106| ••••••••else:
- | 107| ••••••••••••with•self.db.get_cursor()•as•cursor:
- | 108| ••••••••••••••••self.prepare(cursor,•self.ts_start)
- | 109| ••••••••••••••••self.transfer_virtually(cursor)
- | 110| ••••••••••••••••transfers•=•[NS(t._asdict())•for•t•in•cursor.all("""
- | 111| ••••••••••••••••••••SELECT•t.*
- | 112| •••••••••••••••••••••••••,•p.mangopay_user_id•AS•tipper_mango_id
- | 113| •••••••••••••••••••••••••,•p2.mangopay_user_id•AS•tippee_mango_id
- | 114| •••••••••••••••••••••••••,•p.mangopay_wallet_id•AS•tipper_wallet_id
- | 115| •••••••••••••••••••••••••,•p2.mangopay_wallet_id•AS•tippee_wallet_id
- | 116| ••••••••••••••••••••••FROM•payday_transfers•t
- | 117| ••••••••••••••••••••••JOIN•participants•p•ON•p.id•=•t.tipper
- | 118| ••••••••••••••••••••••JOIN•participants•p2•ON•p2.id•=•t.tippee
- | 119| ••••••••••••••••""")]
- | 120| ••••••••••••••••self.check_balances(cursor)
- | 121| ••••••••••••••••with•open(self.transfers_filename,•'wb')•as•f:
- | 122| ••••••••••••••••••••pickle.dump(transfers,•f)
- | 123| ••••••••••••••••if•self.id•>•1:
- | 124| ••••••••••••••••••••previous_ts_start•=•self.db.one("""
- | 125| ••••••••••••••••••••••••SELECT•ts_start
- | 126| ••••••••••••••••••••••••••FROM•paydays
- | 127| •••••••••••••••••••••••••WHERE•id•=•%s
- | 128| ••••••••••••••••••••""",•(self.id•-•1,))
- | 129| ••••••••••••••••else:
- | 130| ••••••••••••••••••••previous_ts_start•=•constants.EPOCH
- | 131| ••••••••••••••••assert•previous_ts_start
- | 132| ••••••••••••••••ts_start•=•self.ts_start
- | 133| ••••••••••••••••cursor.run("""
- | 134| ••••••••••••••••••••WITH•week_exchanges•AS•(
- | 135| •••••••••••••••••••••••••••••SELECT•e.*
- | 136| •••••••••••••••••••••••••••••••FROM•exchanges•e
- | 137| ••••••••••••••••••••••••••••••WHERE•e.timestamp•<•%(ts_start)s
- | 138| ••••••••••••••••••••••••••••••••AND•e.timestamp•>=•%(previous_ts_start)s
- | 139| ••••••••••••••••••••••••••••••••AND•status•<>•'failed'
- | 140| •••••••••••••••••••••••••)
- | 141| ••••••••••••••••••••UPDATE•paydays
- | 142| •••••••••••••••••••••••SET•nparticipants•=•(SELECT•count(*)•FROM•payday_participants)
- | 143| •••••••••••••••••••••••••,•nusers•=•(
- | 144| •••••••••••••••••••••••••••••••SELECT•count(*)
- | 145| •••••••••••••••••••••••••••••••••FROM•participants
- | 146| ••••••••••••••••••••••••••••••••WHERE•kind•IN•('individual',•'organization')
- | 147| ••••••••••••••••••••••••••••••••••AND•join_time•<•%(ts_start)s
- | 148| ••••••••••••••••••••••••••••••••••AND•status•=•'active'
- | 149| •••••••••••••••••••••••••••)
- | 150| •••••••••••••••••••••••••,•week_deposits•=•(
- | 151| •••••••••••••••••••••••••••••••SELECT•COALESCE(sum(amount),•0)
- | 152| •••••••••••••••••••••••••••••••••FROM•week_exchanges
- | 153| ••••••••••••••••••••••••••••••••WHERE•amount•>•0
- | 154| •••••••••••••••••••••••••••)
- | 155| •••••••••••••••••••••••••,•week_withdrawals•=•(
- | 156| •••••••••••••••••••••••••••••••SELECT•COALESCE(-sum(amount),•0)
- | 157| •••••••••••••••••••••••••••••••••FROM•week_exchanges
- | 158| ••••••••••••••••••••••••••••••••WHERE•amount•<•0
- | 159| •••••••••••••••••••••••••••)
- | 160| •••••••••••••••••••••WHERE•ts_end='1970-01-01T00:00:00+00'::timestamptz;
- | 161| ••••••••••••••••""",•locals())
- | 162| ••••••••••••self.clean_up()
- | 163|
- | 164| ••••••••self.transfer_for_real(transfers)
- | 165|
- | 166| ••••••••self.db.self_check()
- | | [NORMAL] RadonBear:
- | | shuffle has a cyclomatic complexity of C
- liberapay/billing/payday.py
- | 552| ••••def•notify_participants(self):
- | 553| ••••••••previous_ts_end•=•self.db.one("""
- | 554| ••••••••••••SELECT•ts_end
- | 555| ••••••••••••••FROM•paydays
- | 556| •••••••••••••WHERE•ts_start•<•%s
- | 557| ••••••••••ORDER•BY•ts_end•DESC
- | 558| •••••••••••••LIMIT•1
- | 559| ••••••••""",•(self.ts_start,),•default=constants.BIRTHDAY)
- | 560|
- | 561| ••••••••#•Income•notifications
- | 562| ••••••••r•=•self.db.all("""
- | 563| ••••••••••••SELECT•tippee,•json_agg(t)•AS•transfers
- | 564| ••••••••••••••FROM•transfers•t
- | 565| •••••••••••••WHERE•"timestamp"•>•%s
- | 566| •••••••••••••••AND•"timestamp"•<=•%s
- | 567| ••••••••••GROUP•BY•tippee
- | 568| ••••••••""",•(previous_ts_end,•self.ts_end))
- | 569| ••••••••for•tippee_id,•transfers•in•r:
- | 570| ••••••••••••successes•=•[t•for•t•in•transfers•if•t['status']•==•'succeeded']
- | 571| ••••••••••••if•not•successes:
- | 572| ••••••••••••••••continue
- | 573| ••••••••••••by_team•=•{k:•sum(t['amount']•for•t•in•v)
- | 574| •••••••••••••••••••••••for•k,•v•in•group_by(successes,•'team').items()}
- | 575| ••••••••••••personal•=•by_team.pop(None,•0)
- | 576| ••••••••••••by_team•=•{Participant.from_id(k).username:•v•for•k,•v•in•by_team.items()}
- | 577| ••••••••••••Participant.from_id(tippee_id).notify(
- | 578| ••••••••••••••••'income',
- | 579| ••••••••••••••••total=sum(t['amount']•for•t•in•successes),
- | 580| ••••••••••••••••personal=personal,
- | 581| ••••••••••••••••by_team=by_team,
- | 582| ••••••••••••)
- | 583|
- | 584| ••••••••#•Identity-required•notifications
- | 585| ••••••••participants•=•self.db.all("""
- | 586| ••••••••••••SELECT•p.*::participants
- | 587| ••••••••••••••FROM•participants•p
- | 588| •••••••••••••WHERE•mangopay_user_id•IS•NULL
- | 589| •••••••••••••••AND•kind•IN•('individual',•'organization')
- | 590| •••••••••••••••AND•(p.goal•IS•NULL•OR•p.goal•>=•0)
- | 591| •••••••••••••••AND•EXISTS•(
- | 592| •••••••••••••••••••••SELECT•1
- | 593| •••••••••••••••••••••••FROM•current_tips•t
- | 594| •••••••••••••••••••••••JOIN•participants•p2•ON•p2.id•=•t.tipper
- | 595| ••••••••••••••••••••••WHERE•t.tippee•=•p.id
- | 596| ••••••••••••••••••••••••AND•t.amount•>•0
- | 597| ••••••••••••••••••••••••AND•p2.balance•>•t.amount
- | 598| •••••••••••••••••••)
- | 599| ••••••••""")
- | 600| ••••••••for•p•in•participants:
- | 601| ••••••••••••p.notify('identity_required',•force_email=True)
- | 602|
- | 603| ••••••••#•Low-balance•notifications
- | 604| ••••••••participants•=•self.db.all("""
- | 605| ••••••••••••SELECT•p.*::participants
- | 606| ••••••••••••••FROM•participants•p
- | 607| •••••••••••••WHERE•balance•<•(
- | 608| •••••••••••••••••••••SELECT•sum(amount)
- | 609| •••••••••••••••••••••••FROM•current_tips•t
- | 610| •••••••••••••••••••••••JOIN•participants•p2•ON•p2.id•=•t.tippee
- | 611| ••••••••••••••••••••••WHERE•t.tipper•=•p.id
- | 612| ••••••••••••••••••••••••AND•p2.mangopay_user_id•IS•NOT•NULL
- | 613| ••••••••••••••••••••••••AND•p2.status•=•'active'
- | 614| •••••••••••••••••••)
- | 615| •••••••••••••••AND•EXISTS•(
- | 616| •••••••••••••••••••••SELECT•1
- | 617| •••••••••••••••••••••••FROM•transfers•t
- | 618| ••••••••••••••••••••••WHERE•t.tipper•=•p.id
- | 619| ••••••••••••••••••••••••AND•t.timestamp•>•%s
- | 620| ••••••••••••••••••••••••AND•t.timestamp•<=•%s
- | 621| ••••••••••••••••••••••••AND•t.status•=•'succeeded'
- | 622| •••••••••••••••••••)
- | 623| ••••••••""",•(previous_ts_end,•self.ts_end))
- | 624| ••••••••for•p•in•participants:
- | 625| ••••••••••••p.notify('low_balance')
- | | [NORMAL] RadonBear:
- | | notify_participants has a cyclomatic complexity of C
- liberapay/wireup.py
- | 279| def•load_i18n(canonical_host,•canonical_scheme,•project_root,•tell_sentry):
- | 280| ••••#•Load•the•locales
- | 281| ••••localeDir•=•os.path.join(project_root,•'i18n',•'core')
- | 282| ••••locales•=•LOCALES
- | 283| ••••for•file•in•os.listdir(localeDir):
- | 284| ••••••••try:
- | 285| ••••••••••••parts•=•file.split(".")
- | 286| ••••••••••••if•not•(len(parts)•==•2•and•parts[1]•==•"po"):
- | 287| ••••••••••••••••continue
- | 288| ••••••••••••lang•=•parts[0]
- | 289| ••••••••••••with•open(os.path.join(localeDir,•file))•as•f:
- | 290| ••••••••••••••••l•=•locales[lang.lower()]•=•Locale(lang)
- | 291| ••••••••••••••••c•=•l.catalog•=•read_po(f)
- | 292| ••••••••••••••••c.plural_func•=•get_function_from_rule(c.plural_expr)
- | 293| ••••••••••••••••try:
- | 294| ••••••••••••••••••••l.countries•=•make_sorted_dict(COUNTRIES,•l.territories)
- | 295| ••••••••••••••••except•KeyError:
- | 296| ••••••••••••••••••••l.countries•=•COUNTRIES
- | 297| ••••••••••••••••try:
- | 298| ••••••••••••••••••••l.languages_2•=•make_sorted_dict(LANGUAGES_2,•l.languages)
- | 299| ••••••••••••••••except•KeyError:
- | 300| ••••••••••••••••••••l.languages_2•=•LANGUAGES_2
- | 301| ••••••••except•Exception•as•e:
- | 302| ••••••••••••tell_sentry(e,•{},•allow_reraise=True)
- | 303|
- | 304| ••••#•Prepare•a•unique•and•sorted•list•for•use•in•the•language•switcher
- | 305| ••••for•l•in•locales.values():
- | 306| ••••••••strings•=•[m.string•for•m•in•l.catalog]
- | 307| ••••••••l.completion•=•sum(1•for•s•in•strings•if•s)•/•len(strings)
- | 308| ••••loc_url•=•canonical_scheme+'://%s.'+canonical_host
- | 309| ••••lang_list•=•sorted(
- | 310| ••••••••(
- | 311| ••••••••••••(l.completion,•l.language,•l.language_name.title(),•loc_url•%•l.language)
- | 312| ••••••••••••for•l•in•set(locales.values())
- | 313| ••••••••),
- | 314| ••••••••key=lambda•t:•(-t[0],•t[1]),
- | 315| ••••)
- | 316|
- | 317| ••••#•Add•aliases
- | 318| ••••for•k,•v•in•list(locales.items()):
- | 319| ••••••••locales.setdefault(ALIASES.get(k,•k),•v)
- | 320| ••••••••locales.setdefault(ALIASES_R.get(k,•k),•v)
- | 321| ••••for•k,•v•in•list(locales.items()):
- | 322| ••••••••locales.setdefault(k.split('_',•1)[0],•v)
- | 323|
- | 324| ••••#•Patch•the•locales•to•look•less•formal
- | 325| ••••locales['fr'].currency_formats[None]•=•parse_pattern('#,##0.00\u202f\xa4')
- | 326| ••••locales['fr'].currency_symbols['USD']•=•'$'
- | 327|
- | 328| ••••#•Load•the•markdown•files
- | 329| ••••docs•=•{}
- | 330| ••••heading_re•=•re.compile(r'^(#+•)',•re.M)
- | 331| ••••for•path•in•find_files(os.path.join(project_root,•'i18n'),•'*.md'):
- | 332| ••••••••d,•b•=•os.path.split(path)
- | 333| ••••••••doc•=•os.path.basename(d)
- | 334| ••••••••lang•=•b[:-3]
- | 335| ••••••••with•open(path,•'rb')•as•f:
- | 336| ••••••••••••md•=•f.read().decode('utf8')
- | 337| ••••••••••••if•md.startswith('#•'):
- | 338| ••••••••••••••••md•=•'\n'.join(md.split('\n')[1:]).strip()
- | 339| ••••••••••••••••md•=•heading_re.sub(r'##\1',•md)
- | 340| ••••••••••••docs.setdefault(doc,•{}).__setitem__(lang,•markdown.render(md))
- | 341|
- | 342| ••••return•{'docs':•docs,•'lang_list':•lang_list,•'locales':•locales}
- | | [NORMAL] RadonBear:
- | | load_i18n has a cyclomatic complexity of C
- liberapay/utils/history.py
- | 66| def•iter_payday_events(db,•participant,•year=None):
- | 67| ••••"""Yields•payday•events•for•the•given•participant.
- | 68| ••••"""
- | 69| ••••current_year•=•datetime.utcnow().year
- | 70| ••••year•=•year•or•current_year
- | 71|
- | 72| ••••id•=•participant.id
- | 73| ••••exchanges•=•db.all("""
- | 74| ••••••••SELECT•*
- | 75| ••••••••••FROM•exchanges
- | 76| •••••••••WHERE•participant=%(id)s
- | 77| •••••••••••AND•extract(year•from•timestamp)•=•%(year)s
- | 78| ••••""",•locals(),•back_as=dict)
- | 79| ••••transfers•=•db.all("""
- | 80| ••••••••SELECT•t.*,•p.username,•(SELECT•username•FROM•participants•WHERE•id•=•team)•AS•team_name
- | 81| ••••••••••FROM•transfers•t
- | 82| ••••••••••JOIN•participants•p•ON•p.id•=•tipper
- | 83| •••••••••WHERE•t.tippee=%(id)s
- | 84| •••••••••••AND•extract(year•from•t.timestamp)•=•%(year)s
- | 85| ••••••••UNION•ALL
- | 86| ••••••••SELECT•t.*,•p.username,•(SELECT•username•FROM•participants•WHERE•id•=•team)•AS•team_name
- | 87| ••••••••••FROM•transfers•t
- | 88| ••••••••••JOIN•participants•p•ON•p.id•=•tippee
- | 89| •••••••••WHERE•t.tipper=%(id)s
- | 90| •••••••••••AND•extract(year•from•t.timestamp)•=•%(year)s
- | 91| ••••""",•locals(),•back_as=dict)
- | 92|
- | 93| ••••if•not•(exchanges•or•transfers):
- | 94| ••••••••return
- | 95|
- | 96| ••••if•transfers:
- | 97| ••••••••yield•dict(
- | 98| ••••••••••••kind='totals',
- | 99| ••••••••••••given=sum(t['amount']•for•t•in•transfers•if•t['tipper']•==•id•and•t['status']•==•'succeeded'),
- | 100| ••••••••••••received=sum(t['amount']•for•t•in•transfers•if•t['tippee']•==•id•and•t['status']•==•'succeeded'),
- | 101| ••••••••)
- | 102|
- | 103| ••••payday_dates•=•db.all("""
- | 104| ••••••••SELECT•ts_start::date
- | 105| ••••••••••FROM•paydays
- | 106| ••••••ORDER•BY•ts_start•ASC
- | 107| ••••""")
- | 108|
- | 109| ••••balance•=•get_end_of_year_balance(db,•participant,•year,•current_year)
- | 110| ••••prev_date•=•None
- | 111| ••••get_timestamp•=•lambda•e:•e['timestamp']
- | 112| ••••events•=•sorted(exchanges+transfers,•key=get_timestamp,•reverse=True)
- | 113| ••••for•event•in•events:
- | 114|
- | 115| ••••••••event['balance']•=•balance
- | 116|
- | 117| ••••••••event_date•=•event['timestamp'].date()
- | 118| ••••••••if•event_date•!=•prev_date:
- | 119| ••••••••••••if•prev_date:
- | 120| ••••••••••••••••yield•dict(kind='day-close',•balance=balance)
- | 121| ••••••••••••day_open•=•dict(kind='day-open',•date=event_date,•balance=balance)
- | 122| ••••••••••••if•payday_dates:
- | 123| ••••••••••••••••while•payday_dates•and•payday_dates[-1]•>•event_date:
- | 124| ••••••••••••••••••••payday_dates.pop()
- | 125| ••••••••••••••••payday_date•=•payday_dates[-1]•if•payday_dates•else•None
- | 126| ••••••••••••••••if•event_date•==•payday_date:
- | 127| ••••••••••••••••••••day_open['payday_number']•=•len(payday_dates)•-•1
- | 128| ••••••••••••yield•day_open
- | 129| ••••••••••••prev_date•=•event_date
- | 130|
- | 131| ••••••••if•'fee'•in•event:
- | 132| ••••••••••••if•event['amount']•>•0:
- | 133| ••••••••••••••••kind•=•'charge'
- | 134| ••••••••••••••••if•event['status']•in•(None,•'succeeded'):
- | 135| ••••••••••••••••••••balance•-=•event['amount']
- | 136| ••••••••••••else:
- | 137| ••••••••••••••••kind•=•'credit'
- | 138| ••••••••••••••••if•event['status']•!=•'failed':
- | 139| ••••••••••••••••••••balance•-=•event['amount']•-•event['fee']
- | 140| ••••••••else:
- | 141| ••••••••••••kind•=•'transfer'
- | 142| ••••••••••••if•event['status']•!=•'succeeded':
- | 143| ••••••••••••••••pass
- | 144| ••••••••••••elif•event['tippee']•==•id:
- | 145| ••••••••••••••••balance•-=•event['amount']
- | 146| ••••••••••••else:
- | 147| ••••••••••••••••balance•+=•event['amount']
- | 148| ••••••••event['kind']•=•kind
- | 149|
- | 150| ••••••••yield•event
- | 151|
- | 152| ••••yield•dict(kind='day-close',•balance=balance)
- | | [NORMAL] RadonBear:
- | | iter_payday_events has a cyclomatic complexity of D
- liberapay/utils/__init__.py
- | 29| def•get_participant(state,•restrict=True,•redirect_stub=True,•allow_member=False):
- | 30| ••••"""Given•a•Request,•raise•Response•or•return•Participant.
- | 31|
- | 32| ••••If•restrict•is•True•then•we'll•restrict•access•to•owners•and•admins.
- | 33|
- | 34| ••••"""
- | 35| ••••request•=•state['request']
- | 36| ••••user•=•state['user']
- | 37| ••••slug•=•request.line.uri.path['username']
- | 38| ••••_•=•state['_']
- | 39|
- | 40| ••••if•restrict•and•user.ANON:
- | 41| ••••••••raise•AuthRequired
- | 42|
- | 43| ••••if•slug.startswith('~'):
- | 44| ••••••••thing•=•'id'
- | 45| ••••••••value•=•slug[1:]
- | 46| ••••••••participant•=•user•if•user•and•str(user.id)•==•value•else•None
- | 47| ••••else:
- | 48| ••••••••thing•=•'lower(username)'
- | 49| ••••••••value•=•slug.lower()
- | 50| ••••••••participant•=•user•if•user•and•user.username.lower()•==•value•else•None
- | 51|
- | 52| ••••if•participant•is•None:
- | 53| ••••••••from•liberapay.models.participant•import•Participant••#•avoid•circular•import
- | 54| ••••••••participant•=•Participant._from_thing(thing,•value)•if•value•else•None
- | 55| ••••••••if•participant•is•None•or•participant.kind•==•'community':
- | 56| ••••••••••••raise•Response(404)
- | 57|
- | 58| ••••if•request.method•in•('GET',•'HEAD'):
- | 59| ••••••••if•slug•!=•participant.username:
- | 60| ••••••••••••canon•=•'/'•+•participant.username•+•request.line.uri[len(slug)+1:]
- | 61| ••••••••••••raise•Response(302,•headers={'Location':•canon})
- | 62|
- | 63| ••••status•=•participant.status
- | 64| ••••if•status•==•'closed':
- | 65| ••••••••if•user.is_admin:
- | 66| ••••••••••••return•participant
- | 67| ••••••••raise•Response(410)
- | 68| ••••elif•status•==•'stub':
- | 69| ••••••••if•redirect_stub:
- | 70| ••••••••••••to•=•participant.resolve_stub()
- | 71| ••••••••••••assert•to
- | 72| ••••••••••••raise•Response(302,•headers={'Location':•to})
- | 73|
- | 74| ••••if•restrict:
- | 75| ••••••••if•participant•!=•user:
- | 76| ••••••••••••if•allow_member•and•participant.kind•==•'group'•and•user.member_of(participant):
- | 77| ••••••••••••••••pass
- | 78| ••••••••••••elif•not•user.is_admin:
- | 79| ••••••••••••••••raise•Response(403,•_("You•are•not•authorized•to•access•this•page."))
- | 80|
- | 81| ••••return•participant
- | | [NORMAL] RadonBear:
- | | get_participant has a cyclomatic complexity of D
- liberapay/billing/exchanges.py
- | 261| def•propagate_exchange(cursor,•participant,•exchange,•route,•error,•amount):
- | 262| ••••"""Propagates•an•exchange's•result•to•the•participant's•balance•and•the
- | 263| ••••route's•status.
- | 264| ••••"""
- | 265| ••••route.update_error(error•or•'')
- | 266|
- | 267| ••••new_balance•=•cursor.one("""
- | 268| ••••••••UPDATE•participants
- | 269| •••••••••••SET•balance=(balance•+•%s)
- | 270| •••••••••WHERE•id=%s
- | 271| •••••RETURNING•balance
- | 272| ••••""",•(amount,•participant.id))
- | 273|
- | 274| ••••if•amount•<•0•and•new_balance•<•0:
- | 275| ••••••••raise•NegativeBalance
- | 276|
- | 277| ••••if•amount•<•0:
- | 278| ••••••••bundles•=•cursor.all("""
- | 279| ••••••••••••LOCK•TABLE•cash_bundles•IN•EXCLUSIVE•MODE;
- | 280| ••••••••••••SELECT•*
- | 281| ••••••••••••••FROM•cash_bundles
- | 282| •••••••••••••WHERE•owner•=•%s
- | 283| •••••••••••••••AND•ts•<•now()•-•INTERVAL•%s
- | 284| ••••••••••ORDER•BY•ts
- | 285| ••••••••""",•(participant.id,•QUARANTINE))
- | 286| ••••••••withdrawable•=•sum(b.amount•for•b•in•bundles)
- | 287| ••••••••x•=•-amount
- | 288| ••••••••if•x•>•withdrawable:
- | 289| ••••••••••••raise•NotEnoughWithdrawableMoney(Money(withdrawable,•'EUR'))
- | 290| ••••••••for•b•in•bundles:
- | 291| ••••••••••••if•x•>=•b.amount:
- | 292| ••••••••••••••••cursor.run("""
- | 293| ••••••••••••••••••••INSERT•INTO•e2e_transfers
- | 294| ••••••••••••••••••••••••••••••••(origin,•withdrawal,•amount)
- | 295| •••••••••••••••••••••••••VALUES•(%s,•%s,•%s)
- | 296| ••••••••••••••••""",•(b.origin,•exchange.id,•b.amount))
- | 297| ••••••••••••••••cursor.run("DELETE•FROM•cash_bundles•WHERE•id•=•%s",•(b.id,))
- | 298| ••••••••••••••••x•-=•b.amount
- | 299| ••••••••••••••••if•x•==•0:
- | 300| ••••••••••••••••••••break
- | 301| ••••••••••••else:
- | 302| ••••••••••••••••assert•x•>•0
- | 303| ••••••••••••••••cursor.run("""
- | 304| ••••••••••••••••••••INSERT•INTO•e2e_transfers
- | 305| ••••••••••••••••••••••••••••••••(origin,•withdrawal,•amount)
- | 306| •••••••••••••••••••••••••VALUES•(%s,•%s,•%s)
- | 307| ••••••••••••••••""",•(b.origin,•exchange.id,•x))
- | 308| ••••••••••••••••cursor.run("""
- | 309| ••••••••••••••••••••UPDATE•cash_bundles
- | 310| •••••••••••••••••••••••SET•amount•=•(amount•-•%s)
- | 311| •••••••••••••••••••••WHERE•id•=•%s
- | 312| ••••••••••••••••""",•(x,•b.id))
- | 313| ••••••••••••••••break
- | 314| ••••elif•amount•>•0:
- | 315| ••••••••cursor.run("""
- | 316| ••••••••••••INSERT•INTO•cash_bundles
- | 317| ••••••••••••••••••••••••(owner,•origin,•amount,•ts)
- | 318| •••••••••••••••••VALUES•(%s,•%s,•%s,•%s)
- | 319| ••••••••""",•(participant.id,•exchange.id,•amount,•exchange.timestamp))
- | 320|
- | 321| ••••participant.set_attributes(balance=new_balance)
- | 322|
- | 323| ••••if•amount•!=•0:
- | 324| ••••••••participant.update_giving_and_tippees(cursor)
- | | [NORMAL] RadonBear:
- | | propagate_exchange has a cyclomatic complexity of C
- liberapay/billing/exchanges.py
- | 413| def•sync_with_mangopay(db):
- | 414| ••••"""We•can•get•out•of•sync•with•MangoPay•if•record_exchange_result•wasn't
- | 415| ••••completed.•This•is•where•we•fix•that.
- | 416| ••••"""
- | 417| ••••check_db(db)
- | 418|
- | 419| ••••exchanges•=•db.all("SELECT•*•FROM•exchanges•WHERE•status•=•'pre'")
- | 420| ••••for•e•in•exchanges:
- | 421| ••••••••p•=•Participant.from_id(e.participant)
- | 422| ••••••••transactions•=•mangoapi.users.GetTransactions(p.mangopay_user_id)
- | 423| ••••••••transactions•=•[x•for•x•in•transactions•if•x.Tag•==•str(e.id)]
- | 424| ••••••••assert•len(transactions)•<•2
- | 425| ••••••••if•transactions:
- | 426| ••••••••••••t•=•transactions[0]
- | 427| ••••••••••••error•=•repr_error(t)
- | 428| ••••••••••••status•=•t.Status.lower()
- | 429| ••••••••••••assert•(not•error)•^•(status•==•'failed')
- | 430| ••••••••••••record_exchange_result(db,•e.id,•status,•error,•p)
- | 431| ••••••••else:
- | 432| ••••••••••••#•The•exchange•didn't•happen
- | 433| ••••••••••••if•e.amount•<•0:
- | 434| ••••••••••••••••#•Mark•it•as•failed•if•it•was•a•credit
- | 435| ••••••••••••••••record_exchange_result(db,•e.id,•'failed',•'interrupted',•p)
- | 436| ••••••••••••else:
- | 437| ••••••••••••••••#•Otherwise•forget•about•it
- | 438| ••••••••••••••••db.run("DELETE•FROM•exchanges•WHERE•id=%s",•(e.id,))
- | 439|
- | 440| ••••transfers•=•db.all("SELECT•*•FROM•transfers•WHERE•status•=•'pre'")
- | 441| ••••for•t•in•transfers:
- | 442| ••••••••tipper•=•Participant.from_id(t.tipper)
- | 443| ••••••••transactions•=•mangoapi.wallets.GetTransactions(tipper.mangopay_wallet_id)
- | 444| ••••••••transactions•=•[x•for•x•in•transactions•if•x.Type•==•'TRANSFER'•and•x.Tag•==•str(t.id)]
- | 445| ••••••••assert•len(transactions)•<•2
- | 446| ••••••••if•transactions:
- | 447| ••••••••••••record_transfer_result(db,•t.id,•transactions[0])
- | 448| ••••••••else:
- | 449| ••••••••••••#•The•transfer•didn't•happen,•remove•it
- | 450| ••••••••••••db.run("DELETE•FROM•transfers•WHERE•id•=•%s",•(t.id,))
- | 451|
- | 452| ••••check_db(db)
- | | [NORMAL] RadonBear:
- | | sync_with_mangopay has a cyclomatic complexity of C
- tests/py/test_callbacks.py
- | 18| ••••@patch('mangopaysdk.tools.apipayouts.ApiPayOuts.Get')
- | 19| ••••def•test_payout_callback(self,•Get):
- | 20| ••••••••homer,•ba•=•self.homer,•self.homer_route
- | 21| ••••••••for•status•in•('succeeded',•'failed'):
- | 22| ••••••••••••status_up•=•status.upper()
- | 23| ••••••••••••error•=•'FOO'•if•status•==•'failed'•else•None
- | 24| ••••••••••••self.make_exchange('mango-cc',•10,•0,•homer)
- | 25| ••••••••••••e_id•=•record_exchange(self.db,•ba,•-10,•0,•0,•homer,•'pre')
- | 26| ••••••••••••assert•homer.balance•==•0
- | 27| ••••••••••••homer.close(None)
- | 28| ••••••••••••assert•homer.status•==•'closed'
- | 29| ••••••••••••qs•=•"EventType=PAYOUT_NORMAL_"+status_up+"&RessourceId=123456790"
- | 30| ••••••••••••payout•=•PayOut()
- | 31| ••••••••••••payout.Status•=•status_up
- | 32| ••••••••••••payout.ResultCode•=•'000001'•if•error•else•'000000'
- | 33| ••••••••••••payout.ResultMessage•=•error
- | 34| ••••••••••••payout.AuthorId•=•homer.mangopay_user_id
- | 35| ••••••••••••payout.Tag•=•str(e_id)
- | 36| ••••••••••••Get.return_value•=•payout
- | 37| ••••••••••••r•=•self.callback(qs,•csrf_token=False)
- | 38| ••••••••••••assert•b'csrf_token'•not•in•r.headers.cookie
- | 39| ••••••••••••assert•r.code•==•200,•r.text
- | 40| ••••••••••••homer•=•homer.refetch()
- | 41| ••••••••••••if•status•==•'succeeded':
- | 42| ••••••••••••••••assert•homer.balance•==•0
- | 43| ••••••••••••••••assert•homer.status•==•'closed'
- | 44| ••••••••••••else:
- | 45| ••••••••••••••••assert•homer.balance•==•10
- | 46| ••••••••••••••••assert•homer.status•==•'active'
- | 47| ••••••••••••••••emails•=•self.get_emails()
- | 48| ••••••••••••••••assert•len(emails)•==•1
- | 49| ••••••••••••••••assert•emails[0]['to'][0]•==•'homer•<%s>'•%•homer.email
- | 50| ••••••••••••••••assert•'fail'•in•emails[0]['subject']
- | 51| ••••••••••••homer.update_status('active')••#•reset•for•next•loop•run
- | | [NORMAL] RadonBear:
- | | test_payout_callback has a cyclomatic complexity of C
- liberapay/utils/fake_data.py
- | 160| def•populate_db(website,•num_participants=100,•num_tips=200,•num_teams=5,•num_transfers=5000,•num_communities=20):
- | 161| ••••"""Populate•DB•with•fake•data.
- | 162| ••••"""
- | 163| ••••db•=•website.db
- | 164|
- | 165| ••••print("Making•Participants")
- | 166| ••••participants•=•[]
- | 167| ••••for•i•in•range(num_participants):
- | 168| ••••••••participants.append(fake_participant(db))
- | 169|
- | 170| ••••print("Making•Teams")
- | 171| ••••teams•=•[]
- | 172| ••••for•i•in•range(num_teams):
- | 173| ••••••••team•=•fake_participant(db,•kind="group")
- | 174| ••••••••#Add•1•to•3•members•to•the•team
- | 175| ••••••••members•=•random.sample(participants,•random.randint(1,•3))
- | 176| ••••••••for•p•in•members:
- | 177| ••••••••••••team.add_member(p)
- | 178| ••••••••teams.append(team)
- | 179| ••••participants.extend(teams)
- | 180|
- | 181| ••••print("Making•Elsewheres")
- | 182| ••••platforms•=•[p.name•for•p•in•website.platforms]
- | 183| ••••for•p•in•participants:
- | 184| ••••••••#All•participants•get•between•0•and•3•elsewheres
- | 185| ••••••••num_elsewheres•=•random.randint(0,•3)
- | 186| ••••••••for•platform_name•in•random.sample(platforms,•num_elsewheres):
- | 187| ••••••••••••fake_elsewhere(db,•p,•platform_name)
- | 188|
- | 189| ••••print("Making•Communities")
- | 190| ••••for•i•in•range(num_communities):
- | 191| ••••••••creator•=•random.sample(participants,•1)
- | 192| ••••••••community•=•fake_community(db,•creator[0])
- | 193|
- | 194| ••••••••members•=•random.sample(participants,•random.randint(1,•3))
- | 195| ••••••••for•p•in•members:
- | 196| ••••••••••••p.update_community_status('memberships',•True,•community.id)
- | 197|
- | 198| ••••print("Making•Tips")
- | 199| ••••tips•=•[]
- | 200| ••••for•i•in•range(num_tips):
- | 201| ••••••••tipper,•tippee•=•random.sample(participants,•2)
- | 202| ••••••••tips.append(fake_tip(db,•tipper,•tippee))
- | 203|
- | 204| ••••#•Transfers
- | 205| ••••transfers•=•[]
- | 206| ••••for•i•in•range(num_transfers):
- | 207| ••••••••tipper,•tippee•=•random.sample(participants,•2)
- | 208| ••••••••while•tipper.kind•in•('group',•'community')•or•\
- | 209| ••••••••••••••tippee.kind•in•('group',•'community'):
- | 210| ••••••••••••tipper,•tippee•=•random.sample(participants,•2)
- | 211| ••••••••sys.stdout.write("\rMaking•Transfers•(%i/%i)"•%•(i+1,•num_transfers))
- | 212| ••••••••sys.stdout.flush()
- | 213| ••••••••amount•=•fake_tip_amount()
- | 214| ••••••••ts•=•faker.date_time_this_year()
- | 215| ••••••••fake_exchange(db,•tipper,•amount,•0,•0,•(ts•-•datetime.timedelta(days=1)))
- | 216| ••••••••transfers.append(fake_transfer(db,•tipper,•tippee,•amount,•ts))
- | 217| ••••print("")
- | 218|
- | 219| ••••#•Paydays
- | 220| ••••#•First•determine•the•boundaries•-•min•and•max•date
- | 221| ••••min_date•=•min(min(x.ctime•for•x•in•tips),•\
- | 222| •••••••••••••••••••min(x.timestamp•for•x•in•transfers))
- | 223| ••••max_date•=•max(max(x.ctime•for•x•in•tips),•\
- | 224| •••••••••••••••••••max(x.timestamp•for•x•in•transfers))
- | 225| ••••#•iterate•through•min_date,•max_date•one•week•at•a•time
- | 226| ••••payday_counter•=•1
- | 227| ••••date•=•min_date
- | 228| ••••paydays_total•=•(max_date•-•min_date).days/7•+•1
- | 229| ••••while•date•<•max_date:
- | 230| ••••••••sys.stdout.write("\rMaking•Paydays•(%i/%i)"•%•(payday_counter,•paydays_total))
- | 231| ••••••••sys.stdout.flush()
- | 232| ••••••••payday_counter•+=•1
- | 233| ••••••••end_date•=•date•+•datetime.timedelta(days=7)
- | 234| ••••••••week_tips•=•[x•for•x•in•tips•if•date•<•x.ctime•<•end_date]
- | 235| ••••••••week_transfers•=•[x•for•x•in•transfers•if•date•<•x.timestamp•<•end_date]
- | 236| ••••••••week_participants•=•[x•for•x•in•participants•if•x.join_time•<•end_date]
- | 237| ••••••••actives=set()
- | 238| ••••••••tippers=set()
- | 239| ••••••••for•xfers•in•week_tips,•week_transfers:
- | 240| ••••••••••••actives.update(x.tipper•for•x•in•xfers)
- | 241| ••••••••••••actives.update(x.tippee•for•x•in•xfers)
- | 242| ••••••••••••tippers.update(x.tipper•for•x•in•xfers)
- | 243| ••••••••payday•=•{
- | 244| ••••••••••••'ts_start':•date,
- | 245| ••••••••••••'ts_end':•end_date,
- | 246| ••••••••••••'ntips':•len(week_tips),
- | 247| ••••••••••••'ntransfers':•len(week_transfers),
- | 248| ••••••••••••'nparticipants':•len(week_participants),
- | 249| ••••••••••••'ntippers':•len(tippers),
- | 250| ••••••••••••'nactive':•len(actives),
- | 251| ••••••••••••'transfer_volume':•sum(x.amount•for•x•in•week_transfers)
- | 252| ••••••••}
- | 253| ••••••••_fake_thing(db,•"paydays",•**payday)
- | 254| ••••••••date•=•end_date
- | 255| ••••print("")
- | | [NORMAL] RadonBear:
- | | populate_db has a cyclomatic complexity of D
- liberapay/elsewhere/_base.py
- | 87| ••••def•api_get(self,•path,•sess=None,•error_handler=True,•**kw):
- | 88| ••••••••"""
- | 89| ••••••••Given•a•`path`•(e.g.•/users/foo),•this•function•sends•a•GET•request•to
- | 90| ••••••••the•platform's•API•(e.g.•https://api.github.com/users/foo).
- | 91|
- | 92| ••••••••The•response•is•returned,•after•checking•its•status•code•and•ratelimit
- | 93| ••••••••headers.
- | 94| ••••••••"""
- | 95| ••••••••url•=•self.api_url+path
- | 96| ••••••••is_user_session•=•bool(sess)
- | 97| ••••••••if•not•sess:
- | 98| ••••••••••••sess•=•self.get_auth_session()
- | 99| ••••••••••••api_app_auth_params•=•getattr(self,•'api_app_auth_params',•None)
- | 100| ••••••••••••if•api_app_auth_params:
- | 101| ••••••••••••••••url•+=•'?'•if•'?'•not•in•url•else•'&'
- | 102| ••••••••••••••••url•+=•api_app_auth_params.format(**self.__dict__)
- | 103| ••••••••response•=•sess.get(url,•**kw)
- | 104|
- | 105| ••••••••if•not•is_user_session:
- | 106| ••••••••••••limit,•remaining,•reset•=•self.get_ratelimit_headers(response)
- | 107| ••••••••••••self.log_ratelimit_headers(limit,•remaining,•reset)
- | 108|
- | 109| ••••••••#•Check•response•status
- | 110| ••••••••if•error_handler•is•True:
- | 111| ••••••••••••error_handler•=•self.api_error_handler
- | 112| ••••••••status•=•response.status_code
- | 113| ••••••••if•status•==•401•and•isinstance(self,•PlatformOAuth1)•and•is_user_session:
- | 114| ••••••••••••#•https://tools.ietf.org/html/rfc5849#section-3.2
- | 115| ••••••••••••raise•TokenExpiredError
- | 116| ••••••••if•status•!=•200•and•error_handler:
- | 117| ••••••••••••error_handler(response,•is_user_session)
- | 118|
- | 119| ••••••••return•response
- | | [NORMAL] RadonBear:
- | | api_get has a cyclomatic complexity of C
- tests/py/test_close.py
- | 126| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 127| ••••••••bob•=•self.make_participant('bob')
- | 128| ••••••••carl•=•self.make_participant('carl')
- | 129| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 130| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | 131| ••••••••with•self.db.get_cursor()•as•cursor:
- | 132| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 133| ••••••••assert•Participant.from_username('bob').balance•==•D('3.33')
- tests/py/test_close.py
- | 138| ••••••••alice•=•self.make_participant('alice',•balance=D('0.00'))
- | 139| ••••••••bob•=•self.make_participant('bob')
- | 140| ••••••••carl•=•self.make_participant('carl')
- | 141| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 142| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | 143| ••••••••with•self.db.get_cursor()•as•cursor:
- | 144| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 145| ••••••••assert•self.db.one("SELECT•count(*)•FROM•tips")•==•2
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_stats.py
- | 43| ••••••••bad_cc.set_tip_to(self.bob,•'3.00')
- | 44| ••••••••expected•=•([[Decimal('1.00'),•1,•Decimal('1.00'),•1,•Decimal('1')]],
- | 45| ••••••••••••••••••••1.0,•Decimal('1.00'))
- | 46| ••••••••actual•=•self.bob.get_tip_distribution()
- | 47| ••••••••assert•actual•==•expected
- tests/py/test_stats.py
- | 52| ••••••••missing_cc.set_tip_to(self.bob,•'3.00')
- | 53| ••••••••expected•=•([[Decimal('1.00'),•1,•Decimal('1.00'),•1,•Decimal('1')]],
- | 54| ••••••••••••••••••••1.0,•Decimal('1.00'))
- | 55| ••••••••actual•=•self.bob.get_tip_distribution()
- | 56| ••••••••assert•actual•==•expected
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_exchanges.py
- | 330| ••••••••••••with•self.assertRaises(Foobar):
- | 331| ••••••••••••••••transfer(self.db,•self.janet.id,•self.david.id,•D('10.00'),•'tip')
- | 332| ••••••••t•=•self.db.one("SELECT•*•FROM•transfers")
- | 333| ••••••••assert•t.status•==•'pre'
- | 334| ••••••••sync_with_mangopay(self.db)
- tests/py/test_billing_exchanges.py
- | 345| ••••••••••••with•self.assertRaises(Foobar):
- | 346| ••••••••••••••••transfer(self.db,•self.janet.id,•self.david.id,•D('10.00'),•'tip')
- | 347| ••••••••t•=•self.db.one("SELECT•*•FROM•transfers")
- | 348| ••••••••assert•t.status•==•'pre'
- | 349| ••••••••sync_with_mangopay(self.db)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 75| ••••def•test_dbafg_distributes_balance_as_final_gift(self):
- | 76| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 77| ••••••••bob•=•self.make_participant('bob')
- | 78| ••••••••carl•=•self.make_participant('carl')
- | 79| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 80| ••••••••alice.set_tip_to(carl,•D('2.00'))
- tests/py/test_close.py
- | 125| ••••def•test_dbafg_favors_highest_tippee_in_rounding_errors(self):
- | 126| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 127| ••••••••bob•=•self.make_participant('bob')
- | 128| ••••••••carl•=•self.make_participant('carl')
- | 129| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 130| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_elsewhere.py
- | 38| ••••••••alice•=•self.make_participant('alice',•elsewhere='twitter')
- | 39|
- | 40| ••••••••gusi.return_value•=•self.client.website.platforms.github.extract_user_info({'id':•2})
- | 41| ••••••••gui.return_value•=•self.client.website.platforms.github.extract_user_info({'id':•1})
- | 42| ••••••••ft.return_value•=•None
- tests/py/test_elsewhere.py
- | 57| ••••••••self.make_participant('bob')
- | 58|
- | 59| ••••••••gusi.return_value•=•self.client.website.platforms.github.extract_user_info({'id':•2})
- | 60| ••••••••gui.return_value•=•self.client.website.platforms.github.extract_user_info({'id':•1})
- | 61| ••••••••ft.return_value•=•None
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_utils.py
- | 38| ••••••••state•=•self.client.GET('/Alice/?foo=bar',•return_after='dispatch_request_to_filesystem',
- | 39| ••••••••••••••••••••••••••••••••want='state')
- | 40| ••••••••with•self.assertRaises(Response)•as•cm:
- | 41| ••••••••••••utils.get_participant(state,•restrict=False)
- | 42| ••••••••r•=•cm.exception
- | 43| ••••••••assert•r.code•==•302
- | 44| ••••••••assert•r.headers['Location']•==•'/alice/?foo=bar'
- tests/py/test_utils.py
- | 48| ••••••••state•=•self.client.GET('/~1/?x=2',•return_after='dispatch_request_to_filesystem',
- | 49| ••••••••••••••••••••••••••••••••want='state')
- | 50| ••••••••with•self.assertRaises(Response)•as•cm:
- | 51| ••••••••••••utils.get_participant(state,•restrict=False)
- | 52| ••••••••r•=•cm.exception
- | 53| ••••••••assert•r.code•==•302
- | 54| ••••••••assert•r.headers['Location']•==•'/alice/?x=2'
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 230| ••••••••self.db.run("UPDATE•participants•SET•goal•=•-1•WHERE•username='homer'")
- | 231| ••••••••payday•=•Payday.start()
- | 232| ••••••••with•self.db.get_cursor()•as•cursor:
- | 233| ••••••••••••payday.prepare(cursor,•payday.ts_start)
- | 234| ••••••••••••payday.transfer_virtually(cursor)
- | 235| ••••••••••••new_balances•=•self.get_new_balances(cursor)
- | 236| ••••••••••••assert•new_balances[self.janet.id]•==•20
- tests/py/test_billing_payday.py
- | 252| ••••••••self.david.set_tip_to(self.homer,•D('0.50'))
- | 253| ••••••••payday•=•Payday.start()
- | 254| ••••••••with•self.db.get_cursor()•as•cursor:
- | 255| ••••••••••••payday.prepare(cursor,•payday.ts_start)
- | 256| ••••••••••••payday.transfer_virtually(cursor)
- | 257| ••••••••••••new_balances•=•self.get_new_balances(cursor)
- | 258| ••••••••••••assert•new_balances[self.david.id]•==•D('0.49')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 252| ••••••••self.david.set_tip_to(self.homer,•D('0.50'))
- | 253| ••••••••payday•=•Payday.start()
- | 254| ••••••••with•self.db.get_cursor()•as•cursor:
- | 255| ••••••••••••payday.prepare(cursor,•payday.ts_start)
- | 256| ••••••••••••payday.transfer_virtually(cursor)
- | 257| ••••••••••••new_balances•=•self.get_new_balances(cursor)
- | 258| ••••••••••••assert•new_balances[self.david.id]•==•D('0.49')
- tests/py/test_billing_payday.py
- | 269| ••••••••self.david.set_tip_to(self.homer,•D('20'))••#•Should•be•unfunded
- | 270|
- | 271| ••••••••payday•=•Payday.start()
- | 272| ••••••••with•self.db.get_cursor()•as•cursor:
- | 273| ••••••••••••payday.prepare(cursor,•payday.ts_start)
- | 274| ••••••••••••payday.transfer_virtually(cursor)
- | 275| ••••••••••••new_balances•=•self.get_new_balances(cursor)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 230| ••••••••self.db.run("UPDATE•participants•SET•goal•=•-1•WHERE•username='homer'")
- | 231| ••••••••payday•=•Payday.start()
- | 232| ••••••••with•self.db.get_cursor()•as•cursor:
- | 233| ••••••••••••payday.prepare(cursor,•payday.ts_start)
- | 234| ••••••••••••payday.transfer_virtually(cursor)
- | 235| ••••••••••••new_balances•=•self.get_new_balances(cursor)
- | 236| ••••••••••••assert•new_balances[self.janet.id]•==•20
- tests/py/test_billing_payday.py
- | 269| ••••••••self.david.set_tip_to(self.homer,•D('20'))••#•Should•be•unfunded
- | 270|
- | 271| ••••••••payday•=•Payday.start()
- | 272| ••••••••with•self.db.get_cursor()•as•cursor:
- | 273| ••••••••••••payday.prepare(cursor,•payday.ts_start)
- | 274| ••••••••••••payday.transfer_virtually(cursor)
- | 275| ••••••••••••new_balances•=•self.get_new_balances(cursor)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 75| ••••def•test_dbafg_distributes_balance_as_final_gift(self):
- | 76| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 77| ••••••••bob•=•self.make_participant('bob')
- | 78| ••••••••carl•=•self.make_participant('carl')
- | 79| ••••••••alice.set_tip_to(bob,•D('3.00'))
- tests/py/test_close.py
- | 112| ••••def•test_dbafg_skips_zero_tips(self):
- | 113| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 114| ••••••••bob•=•self.make_participant('bob')
- | 115| ••••••••carl•=•self.make_participant('carl')
- | 116| ••••••••alice.set_tip_to(bob,•D('0.00'))
- tests/py/test_close.py
- | 125| ••••def•test_dbafg_favors_highest_tippee_in_rounding_errors(self):
- | 126| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 127| ••••••••bob•=•self.make_participant('bob')
- | 128| ••••••••carl•=•self.make_participant('carl')
- | 129| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 78| ••••••••carl•=•self.make_participant('carl')
- | 79| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 80| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 81| ••••••••with•self.db.get_cursor()•as•cursor:
- | 82| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 83| ••••••••assert•Participant.from_username('bob').balance•==•D('6.00')
- tests/py/test_close.py
- | 103| ••••••••carl•=•self.make_stub()
- | 104| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 105| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 106| ••••••••with•self.db.get_cursor()•as•cursor:
- | 107| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 108| ••••••••assert•Participant.from_id(bob.id).balance•==•D('10.00')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 20| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 21| ••••••••bob•=•self.make_participant('bob')
- | 22| ••••••••carl•=•self.make_participant('carl')
- | 23|
- | 24| ••••••••alice.set_tip_to(bob,•D('3.00'))
- tests/py/test_close.py
- | 76| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 77| ••••••••bob•=•self.make_participant('bob')
- | 78| ••••••••carl•=•self.make_participant('carl')
- | 79| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 80| ••••••••alice.set_tip_to(carl,•D('2.00'))
- tests/py/test_close.py
- | 126| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 127| ••••••••bob•=•self.make_participant('bob')
- | 128| ••••••••carl•=•self.make_participant('carl')
- | 129| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 130| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_pages.py
- | 202| ••••••••r•=•self.client.POST('/janeway/identity',•data,•**kw)
- | 203| ••••••••assert•r.code•==•200,•r.text
- | 204| ••••••••janeway•=•janeway.refetch()
- | 205| ••••••••assert•janeway.mangopay_user_id
- | 206|
- | 207| ••••••••#•Edit•the•natural•user
- | 208| ••••••••data2•=•dict(data,•Nationality='US')
- tests/py/test_pages.py
- | 221| ••••••••r•=•self.client.POST('/janeway/identity',•data,•**kw)
- | 222| ••••••••assert•r.code•==•200,•r.text
- | 223| ••••••••janeway•=•janeway.refetch()
- | 224| ••••••••assert•janeway.mangopay_user_id
- | 225|
- | 226| ••••••••#•Edit•the•legal•user
- | 227| ••••••••data2•=•dict(data,•LegalPersonType='ORGANIZATION')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 89| ••••••••bob•=•self.make_stub()
- | 90| ••••••••carl•=•self.make_stub()
- | 91| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 92| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 93| ••••••••with•self.db.get_cursor()•as•cursor:
- tests/py/test_close.py
- | 102| ••••••••bob•=•self.make_participant('bob')
- | 103| ••••••••carl•=•self.make_stub()
- | 104| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 105| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 106| ••••••••with•self.db.get_cursor()•as•cursor:
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_communities.py
- | 83| ••••••••response•=•self.client.POST('/for/test/unsubscribe',•auth_as=self.bob,
- | 84| ••••••••••••••••••••••••••••••••••••xhr=True)
- | 85|
- | 86| ••••••••response•=•self.client.GET('/bob/communities.json',•auth_as=self.bob)
- | 87|
- | 88| ••••••••assert•len(json.loads(response.body))•==•0
- tests/py/test_communities.py
- | 100| ••••••••response•=•self.client.POST('/for/test/leave',•auth_as=self.bob,
- | 101| ••••••••••••••••••••••••••••••••••••xhr=True)
- | 102|
- | 103| ••••••••response•=•self.client.GET('/bob/communities.json',•auth_as=self.bob)
- | 104|
- | 105| ••••••••assert•len(json.loads(response.body))•==•0
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_pages.py
- | 208| ••••••••data2•=•dict(data,•Nationality='US')
- | 209| ••••••••r•=•self.client.POST('/janeway/identity',•data2,•**kw)
- | 210| ••••••••assert•r.code•==•200,•r.text
- | 211| ••••••••janeway2•=•janeway.refetch()
- | 212| ••••••••assert•janeway2.mangopay_user_id•==•janeway.mangopay_user_id
- tests/py/test_pages.py
- | 227| ••••••••data2•=•dict(data,•LegalPersonType='ORGANIZATION')
- | 228| ••••••••r•=•self.client.POST('/janeway/identity',•data2,•**kw)
- | 229| ••••••••assert•r.code•==•200,•r.text
- | 230| ••••••••janeway2•=•janeway.refetch()
- | 231| ••••••••assert•janeway2.mangopay_user_id•==•janeway.mangopay_user_id
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_public_json.py
- | 104| ••••def•test_authenticated_user_gets_self_for_self(self):
- | 105| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 106| ••••••••bob•=•self.make_participant('bob')
- | 107|
- | 108| ••••••••alice.set_tip_to(bob,•'3.00')
- | 109|
- | 110| ••••••••raw•=•self.client.GET('/bob/public.json',•auth_as=bob).body
- tests/py/test_public_json.py
- | 123| ••••def•test_jsonp_works(self):
- | 124| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 125| ••••••••bob•=•self.make_participant('bob')
- | 126|
- | 127| ••••••••alice.set_tip_to(bob,•'3.00')
- | 128|
- | 129| ••••••••raw•=•self.client.GET('/bob/public.json?callback=foo',•auth_as=bob).body
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_take.py
- | 78| ••••def•test_get_members(self):
- | 79| ••••••••team•=•self.make_team()
- | 80| ••••••••alice•=•self.make_participant('alice')
- | 81| ••••••••self.take_last_week(team,•alice,•'40.00')
- | 82| ••••••••team.set_take_for(alice,•D('42.00'),•team)
- tests/py/test_take.py
- | 120| ••••def•test_changes_to_team_receiving_affect_members_take(self):
- | 121| ••••••••team•=•self.make_team()
- | 122| ••••••••alice•=•self.make_participant('alice')
- | 123| ••••••••self.take_last_week(team,•alice,•'40.00')
- | 124| ••••••••team.set_take_for(alice,•D('42.00'),•alice)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_charts_json.py
- | 60| ••••••••••••••••••••••}
- | 61| •••••••••••••••••••,•{•"date":•today()
- | 62| •••••••••••••••••••••,•"npatrons":•2
- | 63| •••••••••••••••••••••,•"receipts":•3.00
- | 64| ••••••••••••••••••••••}
- | 65| ••••••••••••••••••••]
- | 66| ••••••••actual•=•json.loads(self.client.GET('/carl/charts.json').body)
- | 67|
- | 68| ••••••••assert•actual•==•expected
- | 69|
- | 70| ••••def•test_sandwiched_tipless_payday_comes_through(self):
- tests/py/test_charts_json.py
- | 89| ••••••••••••••••••••••}
- | 90| •••••••••••••••••••,•{•"date":•today()
- | 91| •••••••••••••••••••••,•"npatrons":•2
- | 92| •••••••••••••••••••••,•"receipts":•3.00
- | 93| ••••••••••••••••••••••}
- | 94| ••••••••••••••••••••]
- | 95| ••••••••actual•=•json.loads(self.client.GET('/carl/charts.json').body)
- | 96|
- | 97| ••••••••assert•actual•==•expected
- | 98|
- | 99| ••••def•test_out_of_band_transfer_gets_included_with_prior_payday(self):
- tests/py/test_charts_json.py
- | 115| ••••••••••••••••••••••}
- | 116| •••••••••••••••••••,•{•"date":•today()
- | 117| •••••••••••••••••••••,•"npatrons":•2
- | 118| •••••••••••••••••••••,•"receipts":•3.00
- | 119| ••••••••••••••••••••••}
- | 120| ••••••••••••••••••••]
- | 121| ••••••••actual•=•json.loads(self.client.GET('/carl/charts.json').body)
- | 122|
- | 123| ••••••••assert•actual•==•expected
- | 124|
- | 125| ••••def•test_never_received_gives_empty_array(self):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_utils.py
- | 29| ••••••••state•=•self.client.GET('/~/',•return_after='dispatch_request_to_filesystem',
- | 30| ••••••••••••••••••••••••••••••••want='state')
- | 31| ••••••••with•self.assertRaises(Response)•as•cm:
- | 32| ••••••••••••utils.get_participant(state,•restrict=False)
- | 33| ••••••••r•=•cm.exception
- | 34| ••••••••assert•r.code•==•404
- tests/py/test_utils.py
- | 38| ••••••••state•=•self.client.GET('/Alice/?foo=bar',•return_after='dispatch_request_to_filesystem',
- | 39| ••••••••••••••••••••••••••••••••want='state')
- | 40| ••••••••with•self.assertRaises(Response)•as•cm:
- | 41| ••••••••••••utils.get_participant(state,•restrict=False)
- | 42| ••••••••r•=•cm.exception
- | 43| ••••••••assert•r.code•==•302
- tests/py/test_utils.py
- | 48| ••••••••state•=•self.client.GET('/~1/?x=2',•return_after='dispatch_request_to_filesystem',
- | 49| ••••••••••••••••••••••••••••••••want='state')
- | 50| ••••••••with•self.assertRaises(Response)•as•cm:
- | 51| ••••••••••••utils.get_participant(state,•restrict=False)
- | 52| ••••••••r•=•cm.exception
- | 53| ••••••••assert•r.code•==•302
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 20| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 21| ••••••••bob•=•self.make_participant('bob')
- | 22| ••••••••carl•=•self.make_participant('carl')
- | 23|
- | 24| ••••••••alice.set_tip_to(bob,•D('3.00'))
- tests/py/test_close.py
- | 113| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 114| ••••••••bob•=•self.make_participant('bob')
- | 115| ••••••••carl•=•self.make_participant('carl')
- | 116| ••••••••alice.set_tip_to(bob,•D('0.00'))
- | 117| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_public_json.py
- | 26| •••••••••••••••••••••••••••••••••••••,•hide_giving=True
- | 27| •••••••••••••••••••••••••••••••••••••)
- | 28| ••••••••bob•=•self.make_participant('bob')
- | 29| ••••••••alice.set_tip_to(bob,•'1.00')
- | 30| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 31|
- | 32| ••••••••assert•data['giving']•==•None
- tests/py/test_public_json.py
- | 37| •••••••••••••••••••••••••••••••••••••,•hide_receiving=True
- | 38| •••••••••••••••••••••••••••••••••••••)
- | 39| ••••••••bob•=•self.make_participant('bob')
- | 40| ••••••••alice.set_tip_to(bob,•'1.00')
- | 41| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 42|
- | 43| ••••••••assert•data['receiving']•==•None
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_charts_json.py
- | 40| ••••••••expected•=•[•{•"date":•today()
- | 41| •••••••••••••••••••••,•"npatrons":•2
- | 42| •••••••••••••••••••••,•"receipts":•3.00
- | 43| ••••••••••••••••••••••}
- | 44| ••••••••••••••••••••]
- | 45| ••••••••actual•=•json.loads(self.client.GET('/carl/charts.json').body)
- | 46|
- | 47| ••••••••assert•actual•==•expected
- | 48|
- | 49| ••••def•test_second_payday_comes_through(self):
- tests/py/test_charts_json.py
- | 61| •••••••••••••••••••,•{•"date":•today()
- | 62| •••••••••••••••••••••,•"npatrons":•2
- | 63| •••••••••••••••••••••,•"receipts":•3.00
- | 64| ••••••••••••••••••••••}
- | 65| ••••••••••••••••••••]
- | 66| ••••••••actual•=•json.loads(self.client.GET('/carl/charts.json').body)
- | 67|
- | 68| ••••••••assert•actual•==•expected
- | 69|
- | 70| ••••def•test_sandwiched_tipless_payday_comes_through(self):
- tests/py/test_charts_json.py
- | 90| •••••••••••••••••••,•{•"date":•today()
- | 91| •••••••••••••••••••••,•"npatrons":•2
- | 92| •••••••••••••••••••••,•"receipts":•3.00
- | 93| ••••••••••••••••••••••}
- | 94| ••••••••••••••••••••]
- | 95| ••••••••actual•=•json.loads(self.client.GET('/carl/charts.json').body)
- | 96|
- | 97| ••••••••assert•actual•==•expected
- | 98|
- | 99| ••••def•test_out_of_band_transfer_gets_included_with_prior_payday(self):
- tests/py/test_charts_json.py
- | 116| •••••••••••••••••••,•{•"date":•today()
- | 117| •••••••••••••••••••••,•"npatrons":•2
- | 118| •••••••••••••••••••••,•"receipts":•3.00
- | 119| ••••••••••••••••••••••}
- | 120| ••••••••••••••••••••]
- | 121| ••••••••actual•=•json.loads(self.client.GET('/carl/charts.json').body)
- | 122|
- | 123| ••••••••assert•actual•==•expected
- | 124|
- | 125| ••••def•test_never_received_gives_empty_array(self):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/models/participant.py
- | 87| ••••••••if•kw:
- | 88| ••••••••••••cols,•vals•=•zip(*kw.items())
- | 89| ••••••••••••cols•=•',•'.join(cols)
- | 90| ••••••••••••placeholders•=•',•'.join(['%s']*len(vals))
- liberapay/utils/fake_data.py
- | 20| def•_fake_thing(db,•tablename,•**kw):
- | 21| ••••cols,•vals•=•zip(*kw.items())
- | 22| ••••cols•=•',•'.join(cols)
- | 23| ••••placeholders•=•',•'.join(['%s']*len(vals))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_teams.py
- | 82| ••••••••r•=•self.client.PxST('/about/teams',•{'name':•'Team'},•auth_as=alice)
- | 83| ••••••••assert•r.code•==•302
- | 84| ••••••••assert•r.headers['Location']•==•'/Team/edit'
- | 85| ••••••••t•=•Participant.from_username('Team')
- tests/py/test_teams.py
- | 95| ••••••••r•=•self.client.PxST('/about/teams',•{'name':•'Team'},•auth_as=alice)
- | 96| ••••••••assert•r.code•==•302
- | 97| ••••••••assert•r.headers['Location']•==•'/Team/edit'
- | 98| ••••••••t•=•t.refetch()
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 76| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 77| ••••••••bob•=•self.make_participant('bob')
- | 78| ••••••••carl•=•self.make_participant('carl')
- | 79| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 80| ••••••••alice.set_tip_to(carl,•D('2.00'))
- tests/py/test_close.py
- | 138| ••••••••alice•=•self.make_participant('alice',•balance=D('0.00'))
- | 139| ••••••••bob•=•self.make_participant('bob')
- | 140| ••••••••carl•=•self.make_participant('carl')
- | 141| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 142| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_take.py
- | 50| ••••def•test_take_can_double(self):
- | 51| ••••••••team•=•self.make_team()
- | 52| ••••••••alice•=•self.make_participant('alice')
- | 53| ••••••••self.take_last_week(team,•alice,•'40.00')
- | 54| ••••••••team.set_take_for(alice,•D('80.00'),•alice)
- tests/py/test_take.py
- | 78| ••••def•test_get_members(self):
- | 79| ••••••••team•=•self.make_team()
- | 80| ••••••••alice•=•self.make_participant('alice')
- | 81| ••••••••self.take_last_week(team,•alice,•'40.00')
- | 82| ••••••••team.set_take_for(alice,•D('42.00'),•team)
- tests/py/test_take.py
- | 120| ••••def•test_changes_to_team_receiving_affect_members_take(self):
- | 121| ••••••••team•=•self.make_team()
- | 122| ••••••••alice•=•self.make_participant('alice')
- | 123| ••••••••self.take_last_week(team,•alice,•'40.00')
- | 124| ••••••••team.set_take_for(alice,•D('42.00'),•alice)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_take.py
- | 130| ••••def•test_changes_to_others_take_affects_members_take(self):
- | 131| ••••••••team•=•self.make_team()
- | 132|
- | 133| ••••••••alice•=•self.make_participant('alice')
- | 134| ••••••••self.take_last_week(team,•alice,•'30.00')
- | 135| ••••••••team.set_take_for(alice,•D('40.00'),•alice)
- tests/py/test_take.py
- | 147| ••••def•test_changes_to_others_take_can_increase_members_take(self):
- | 148| ••••••••team•=•self.make_team()
- | 149|
- | 150| ••••••••alice•=•self.make_participant('alice')
- | 151| ••••••••self.take_last_week(team,•alice,•'30.00')
- | 152| ••••••••team.set_take_for(alice,•D('25.00'),•alice)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 338| ••••def•test_only_latest_tip_counts(self):
- | 339| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 340| ••••••••bob•=•self.make_participant('bob',•balance=100)
- | 341| ••••••••carl•=•self.make_participant('carl')
- tests/py/test_public_json.py
- | 90| ••••def•test_authenticated_user_gets_zero_if_they_dont_tip(self):
- | 91| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 92| ••••••••bob•=•self.make_participant('bob',•balance=100)
- | 93| ••••••••carl•=•self.make_participant('carl')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/models/participant.py
- | 88| ••••••••••••cols,•vals•=•zip(*kw.items())
- | 89| ••••••••••••cols•=•',•'.join(cols)
- | 90| ••••••••••••placeholders•=•',•'.join(['%s']*len(vals))
- liberapay/testing/__init__.py
- | 188| ••••••••cols,•vals•=•zip(*kw.items())
- | 189| ••••••••cols•=•',•'.join(cols)
- | 190| ••••••••placeholders•=•',•'.join(['%s']*len(vals))
- liberapay/utils/fake_data.py
- | 21| ••••cols,•vals•=•zip(*kw.items())
- | 22| ••••cols•=•',•'.join(cols)
- | 23| ••••placeholders•=•',•'.join(['%s']*len(vals))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 338| ••••def•test_only_latest_tip_counts(self):
- | 339| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 340| ••••••••bob•=•self.make_participant('bob',•balance=100)
- | 341| ••••••••carl•=•self.make_participant('carl')
- tests/py/test_public_json.py
- | 73| ••••def•test_authenticated_user_doesnt_get_other_peoples_tips(self):
- | 74| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 75| ••••••••bob•=•self.make_participant('bob',•balance=100)
- | 76| ••••••••carl•=•self.make_participant('carl',•balance=100)
- tests/py/test_public_json.py
- | 90| ••••def•test_authenticated_user_gets_zero_if_they_dont_tip(self):
- | 91| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 92| ••••••••bob•=•self.make_participant('bob',•balance=100)
- | 93| ••••••••carl•=•self.make_participant('carl')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 78| ••••••••carl•=•self.make_participant('carl')
- | 79| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 80| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 81| ••••••••with•self.db.get_cursor()•as•cursor:
- tests/py/test_close.py
- | 90| ••••••••carl•=•self.make_stub()
- | 91| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 92| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 93| ••••••••with•self.db.get_cursor()•as•cursor:
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_communities.py
- | 77| ••••••••response•=•self.client.POST('/for/test/subscribe',•auth_as=self.bob,
- | 78| ••••••••••••••••••••••••••••••••••••xhr=True)
- | 79|
- | 80| ••••••••r•=•json.loads(response.body)
- | 81| ••••••••assert•r•==•{}
- | 82|
- | 83| ••••••••response•=•self.client.POST('/for/test/unsubscribe',•auth_as=self.bob,
- tests/py/test_communities.py
- | 94| ••••••••response•=•self.client.POST('/for/test/join',•auth_as=self.bob,
- | 95| ••••••••••••••••••••••••••••••••••••xhr=True)
- | 96|
- | 97| ••••••••r•=•json.loads(response.body)
- | 98| ••••••••assert•r•==•{}
- | 99|
- | 100| ••••••••response•=•self.client.POST('/for/test/leave',•auth_as=self.bob,
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_charts_json.py
- | 53| ••••••••self.bob.set_tip_to(self.carl,•'0.00')
- | 54|
- | 55| ••••••••self.run_payday()•••#•second
- | 56|
- | 57| ••••••••expected•=•[•{•"date":•today()
- | 58| •••••••••••••••••••••,•"npatrons":•1•#•most•recent•first
- | 59| •••••••••••••••••••••,•"receipts":•5.00
- | 60| ••••••••••••••••••••••}
- | 61| •••••••••••••••••••,•{•"date":•today()
- | 62| •••••••••••••••••••••,•"npatrons":•2
- tests/py/test_charts_json.py
- | 79| ••••••••self.alice.set_tip_to(self.carl,•'5.00')
- | 80| ••••••••self.run_payday()•••#•third
- | 81|
- | 82| ••••••••expected•=•[•{•"date":•today()
- | 83| •••••••••••••••••••••,•"npatrons":•1•#•most•recent•first
- | 84| •••••••••••••••••••••,•"receipts":•5.00
- | 85| ••••••••••••••••••••••}
- | 86| •••••••••••••••••••,•{•"date":•today()
- | 87| •••••••••••••••••••••,•"npatrons":•0
- | 88| •••••••••••••••••••••,•"receipts":•0.00
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_tips_json.py
- | 40| ••••••••response•=•self.client.GET('/test_tipper/tips.json',•auth_as=test_tipper)
- | 41| ••••••••assert•response.code•==•200
- | 42| ••••••••assert•len(json.loads(response.body))•==•tippees
- tests/py/test_tips_json.py
- | 47| ••••••••response•=•self.client.GET('/test_tipper/tips.json',•auth_as=test_tipper)
- | 48|
- | 49| ••••••••assert•response.code•==•200
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/facebook.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- | 5| from•liberapay.elsewhere._paginators•import•keys_paginator
- liberapay/elsewhere/gitlab.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- | 5| from•liberapay.elsewhere._paginators•import•header_links_paginator
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 163| ••••••••••••('Payday•started•at•{}.'.format(ts_start)),
- | 164| ••••••••••••('Prepared•the•DB.'),
- | 165| ••••••••]
- | 166| ••••••••expected_logging_call_args.reverse()
- | 167| ••••••••for•args,•_•in•log.call_args_list:
- | 168| ••••••••••••assert•args[0]•==•expected_logging_call_args.pop()
- tests/py/test_billing_payday.py
- | 189| ••••••••••••('Payday•started•at•{}.'.format(second_ts_start)),
- | 190| ••••••••••••('Prepared•the•DB.'),
- | 191| ••••••••]
- | 192| ••••••••expected_logging_call_args.reverse()
- | 193| ••••••••for•args,•_•in•log.call_args_list:
- | 194| ••••••••••••assert•args[0]•==•expected_logging_call_args.pop()
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 315| ••••••••self.clear_tables()
- | 316| ••••••••team•=•self.make_participant('team',•kind='group')
- | 317| ••••••••alice•=•self.make_participant('alice')
- | 318| ••••••••team.set_take_for(alice,•D('1.00'),•alice)
- tests/py/test_billing_payday.py
- | 341| ••••••••self.clear_tables()
- | 342| ••••••••team•=•self.make_participant('team',•kind='group')
- | 343| ••••••••alice•=•self.make_participant('alice')
- | 344| ••••••••team.set_take_for(alice,•D('0.79'),•alice)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 372| ••••••••team.set_take_for(bob,•D('0.75'),•bob)
- | 373|
- | 374| ••••••••Payday.start().run()
- | 375|
- | 376| ••••••••d•=•dict(self.db.all("SELECT•username,•balance•FROM•participants"))
- | 377| ••••••••expected•=•{
- | 378| ••••••••••••'alice':•D('7.75'),••#•8•-•0.50•+•0.25
- tests/py/test_billing_payday.py
- | 390| ••••••••team.set_take_for(bob,•D('1.00'),•bob)
- | 391|
- | 392| ••••••••Payday.start().run()
- | 393|
- | 394| ••••••••d•=•dict(self.db.all("SELECT•username,•balance•FROM•participants"))
- | 395| ••••••••expected•=•{
- | 396| ••••••••••••'alice':•D('0.00'),
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_elsewhere.py
- | 45| ••••••••cookie•=•b64encode_s(json.dumps(['query_data',•'connect',•b64encode_s(then),•'2']))
- | 46| ••••••••response•=•self.client.GxT('/on/github/associate?state=deadbeef',
- | 47| •••••••••••••••••••••••••••••••••••auth_as=alice,
- | 48| •••••••••••••••••••••••••••••••••••cookies={b'github_deadbeef':•cookie})
- | 49| ••••••••assert•response.code•==•302,•response.text
- tests/py/test_elsewhere.py
- | 63| ••••••••cookie•=•b64encode_s(json.dumps(['query_data',•'connect',•'',•'2']))
- | 64| ••••••••response•=•self.client.GxT('/on/github/associate?state=deadbeef',
- | 65| •••••••••••••••••••••••••••••••••••auth_as=alice,
- | 66| •••••••••••••••••••••••••••••••••••cookies={b'github_deadbeef':•cookie})
- | 67| ••••••••assert•response.code•==•302
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 289| ••••def•test_stt_returns_False_for_second_time_tipper(self):
- | 290| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 291| ••••••••bob•=•self.make_participant('bob')
- | 292| ••••••••alice.set_tip_to(bob,•'1.00')
- tests/py/test_public_json.py
- | 10| ••••def•test_anonymous(self):
- | 11| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 12| ••••••••bob•=•self.make_participant('bob')
- | 13|
- tests/py/test_public_json.py
- | 60| ••••def•test_authenticated_user_gets_their_tip(self):
- | 61| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 62| ••••••••bob•=•self.make_participant('bob')
- | 63|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 357| ••••def•test_receiving_is_zero_for_patrons(self):
- | 358| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 359| ••••••••bob•=•self.make_participant('bob')
- | 360| ••••••••alice.set_tip_to(bob,•'3.00')
- tests/py/test_public_json.py
- | 104| ••••def•test_authenticated_user_gets_self_for_self(self):
- | 105| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 106| ••••••••bob•=•self.make_participant('bob')
- | 107|
- tests/py/test_public_json.py
- | 123| ••••def•test_jsonp_works(self):
- | 124| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 125| ••••••••bob•=•self.make_participant('bob')
- | 126|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_search.py
- | 16| ••••••••response•=•self.client.GET('/search.json?q=alice&scope=usernames')
- | 17| ••••••••data•=•json.loads(response.body)['usernames']
- | 18| ••••••••assert•len(data)•==•1
- | 19| ••••••••assert•data[0]['username']•==•'alice'
- | 20|
- | 21| ••••def•test_get_stub_user(self):
- tests/py/test_search.py
- | 29| ••••••••response•=•self.client.GET('/search.json?q=alicia&scope=usernames')
- | 30| ••••••••data•=•json.loads(response.body)['usernames']
- | 31| ••••••••assert•len(data)•==•1
- | 32| ••••••••assert•data[0]['username']•==•'alice'
- | 33|
- | 34| ••••def•test_hide_from_search(self):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 155| ••••••••alice.set_tip_to(self.make_participant('bob'),•D('1.00'))
- | 156| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•current_tips•"
- | 157| ••••••••••••••••••••••••••••••••••••"WHERE•tipper=%s•AND•amount•>•0",
- | 158| ••••••••••••••••••••••••••••••••••••(alice.id,))
- | 159| ••••••••assert•ntips()•==•1
- tests/py/test_close.py
- | 189| ••••••••alice.set_tip_to(self.make_participant('francis'),•D('1.00'))
- | 190| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•current_tips•"
- | 191| ••••••••••••••••••••••••••••••••••••"WHERE•tipper=%s•AND•amount•>•0",
- | 192| ••••••••••••••••••••••••••••••••••••(alice.id,))
- | 193| ••••••••assert•ntips()•==•5
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 75| ••••def•test_dbafg_distributes_balance_as_final_gift(self):
- | 76| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 77| ••••••••bob•=•self.make_participant('bob')
- | 78| ••••••••carl•=•self.make_participant('carl')
- tests/py/test_close.py
- | 100| ••••def•test_dbafg_gives_all_to_claimed(self):
- | 101| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 102| ••••••••bob•=•self.make_participant('bob')
- | 103| ••••••••carl•=•self.make_stub()
- tests/py/test_close.py
- | 112| ••••def•test_dbafg_skips_zero_tips(self):
- | 113| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 114| ••••••••bob•=•self.make_participant('bob')
- | 115| ••••••••carl•=•self.make_participant('carl')
- tests/py/test_close.py
- | 125| ••••def•test_dbafg_favors_highest_tippee_in_rounding_errors(self):
- | 126| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 127| ••••••••bob•=•self.make_participant('bob')
- | 128| ••••••••carl•=•self.make_participant('carl')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 79| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 80| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 81| ••••••••with•self.db.get_cursor()•as•cursor:
- | 82| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 83| ••••••••assert•Participant.from_username('bob').balance•==•D('6.00')
- tests/py/test_close.py
- | 104| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 105| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 106| ••••••••with•self.db.get_cursor()•as•cursor:
- | 107| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 108| ••••••••assert•Participant.from_id(bob.id).balance•==•D('10.00')
- tests/py/test_close.py
- | 116| ••••••••alice.set_tip_to(bob,•D('0.00'))
- | 117| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 118| ••••••••with•self.db.get_cursor()•as•cursor:
- | 119| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 120| ••••••••assert•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tippee=%s",•(bob.id,))•==•1
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 80| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 81| ••••••••with•self.db.get_cursor()•as•cursor:
- | 82| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 83| ••••••••assert•Participant.from_username('bob').balance•==•D('6.00')
- tests/py/test_close.py
- | 130| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | 131| ••••••••with•self.db.get_cursor()•as•cursor:
- | 132| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 133| ••••••••assert•Participant.from_username('bob').balance•==•D('3.33')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 96| ••••••••assert•Participant.from_id(bob.id).balance•==•D('0.00')
- | 97| ••••••••assert•Participant.from_id(carl.id).balance•==•D('0.00')
- | 98| ••••••••assert•Participant.from_id(alice.id).balance•==•D('10.00')
- tests/py/test_close.py
- | 108| ••••••••assert•Participant.from_id(bob.id).balance•==•D('10.00')
- | 109| ••••••••assert•Participant.from_id(carl.id).balance•==•D('0.00')
- | 110| ••••••••assert•Participant.from_id(alice.id).balance•==•D('0.00')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 322| ••••••••charlie.set_tip_to(team,•D('0.26'))
- | 323|
- | 324| ••••••••Payday.start().run()
- | 325|
- | 326| ••••••••d•=•dict(self.db.all("SELECT•username,•balance•FROM•participants"))
- | 327| ••••••••expected•=•{
- | 328| ••••••••••••'alice':•D('0.13'),
- tests/py/test_billing_payday.py
- | 350| ••••••••dan.set_tip_to(team,•D('5.00'))
- | 351|
- | 352| ••••••••Payday.start().run()
- | 353|
- | 354| ••••••••d•=•dict(self.db.all("SELECT•username,•balance•FROM•participants"))
- | 355| ••••••••expected•=•{
- | 356| ••••••••••••'alice':•D('0.79'),
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/_base.py
- | 212| ••••••••••••page_url•=•self.api_team_members_path.format(
- | 213| ••••••••••••••••user_id=quote(account.user_id),
- | 214| ••••••••••••••••user_name=quote(account.user_name•or•''),
- | 215| ••••••••••••)
- | 216| ••••••••r•=•self.api_get(page_url)
- liberapay/elsewhere/_base.py
- | 248| ••••••••••••page_url•=•self.api_friends_path.format(
- | 249| ••••••••••••••••user_id=quote(account.user_id),
- | 250| ••••••••••••••••user_name=quote(account.user_name•or•''),
- | 251| ••••••••••••)
- | 252| ••••••••r•=•self.api_get(page_url,•sess=sess)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 289| ••••def•test_stt_returns_False_for_second_time_tipper(self):
- | 290| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 291| ••••••••bob•=•self.make_participant('bob')
- | 292| ••••••••alice.set_tip_to(bob,•'1.00')
- tests/py/test_participant.py
- | 357| ••••def•test_receiving_is_zero_for_patrons(self):
- | 358| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 359| ••••••••bob•=•self.make_participant('bob')
- | 360| ••••••••alice.set_tip_to(bob,•'3.00')
- tests/py/test_public_json.py
- | 10| ••••def•test_anonymous(self):
- | 11| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 12| ••••••••bob•=•self.make_participant('bob')
- | 13|
- tests/py/test_public_json.py
- | 60| ••••def•test_authenticated_user_gets_their_tip(self):
- | 61| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 62| ••••••••bob•=•self.make_participant('bob')
- | 63|
- tests/py/test_public_json.py
- | 104| ••••def•test_authenticated_user_gets_self_for_self(self):
- | 105| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 106| ••••••••bob•=•self.make_participant('bob')
- | 107|
- tests/py/test_public_json.py
- | 123| ••••def•test_jsonp_works(self):
- | 124| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 125| ••••••••bob•=•self.make_participant('bob')
- | 126|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_communities.py
- | 54| ••••••••response•=•self.client.GET('/alice/communities.json',•auth_as=self.alice)
- | 55|
- | 56| ••••••••assert•len(json.loads(response.body))•==•0
- tests/py/test_communities.py
- | 59| ••••••••response•=•self.client.GET('/alice/communities.json',•auth_as=self.alice)
- | 60| ••••••••assert•len(json.loads(response.body))•==•0
- | 61|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 322| ••••••••charlie.set_tip_to(team,•D('0.26'))
- | 323|
- | 324| ••••••••Payday.start().run()
- | 325|
- | 326| ••••••••d•=•dict(self.db.all("SELECT•username,•balance•FROM•participants"))
- | 327| ••••••••expected•=•{
- | 328| ••••••••••••'alice':•D('0.13'),
- tests/py/test_billing_payday.py
- | 350| ••••••••dan.set_tip_to(team,•D('5.00'))
- | 351|
- | 352| ••••••••Payday.start().run()
- | 353|
- | 354| ••••••••d•=•dict(self.db.all("SELECT•username,•balance•FROM•participants"))
- | 355| ••••••••expected•=•{
- | 356| ••••••••••••'alice':•D('0.79'),
- tests/py/test_billing_payday.py
- | 372| ••••••••team.set_take_for(bob,•D('0.75'),•bob)
- | 373|
- | 374| ••••••••Payday.start().run()
- | 375|
- | 376| ••••••••d•=•dict(self.db.all("SELECT•username,•balance•FROM•participants"))
- | 377| ••••••••expected•=•{
- | 378| ••••••••••••'alice':•D('7.75'),••#•8•-•0.50•+•0.25
- tests/py/test_billing_payday.py
- | 390| ••••••••team.set_take_for(bob,•D('1.00'),•bob)
- | 391|
- | 392| ••••••••Payday.start().run()
- | 393|
- | 394| ••••••••d•=•dict(self.db.all("SELECT•username,•balance•FROM•participants"))
- | 395| ••••••••expected•=•{
- | 396| ••••••••••••'alice':•D('0.00'),
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_take.py
- | 38| ••••def•test_team_member_is_team_member(self):
- | 39| ••••••••team•=•self.make_team()
- | 40| ••••••••alice•=•self.make_participant('alice')
- | 41| ••••••••self.take_last_week(team,•alice,•'40.00')
- | 42| ••••••••assert•alice.member_of(team)
- tests/py/test_take.py
- | 44| ••••def•test_cant_grow_tip_a_lot(self):
- | 45| ••••••••team•=•self.make_team()
- | 46| ••••••••alice•=•self.make_participant('alice')
- | 47| ••••••••self.take_last_week(team,•alice,•'40.00')
- | 48| ••••••••assert•team.set_take_for(alice,•D('100.00'),•alice)•==•80
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_take.py
- | 135| ••••••••team.set_take_for(alice,•D('40.00'),•alice)
- | 136|
- | 137| ••••••••bob•=•self.make_participant('bob')
- | 138| ••••••••self.take_last_week(team,•bob,•'50.00')
- | 139| ••••••••team.set_take_for(bob,•D('60.00'),•bob)
- tests/py/test_take.py
- | 152| ••••••••team.set_take_for(alice,•D('25.00'),•alice)
- | 153|
- | 154| ••••••••bob•=•self.make_participant('bob')
- | 155| ••••••••self.take_last_week(team,•bob,•'50.00')
- | 156| ••••••••team.set_take_for(bob,•D('100.00'),•bob)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_email.py
- | 225| ••••••••Participant.dequeue_emails()
- | 226| ••••••••assert•self.mailer.call_count•==•1
- | 227| ••••••••last_email•=•self.get_last_email()
- | 228| ••••••••assert•last_email['to'][0]•==•'larry•<larry@example.com>'
- tests/py/test_email_notifs.py
- | 21| ••••••••Participant.dequeue_emails()
- | 22| ••••••••assert•self.mailer.call_count•==•1
- | 23| ••••••••last_email•=•self.get_last_email()
- | 24| ••••••••assert•last_email['to'][0]•==•'bob•<bob@example.com>'
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 20| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 21| ••••••••bob•=•self.make_participant('bob')
- | 22| ••••••••carl•=•self.make_participant('carl')
- | 23|
- | 24| ••••••••alice.set_tip_to(bob,•D('3.00'))
- tests/py/test_close.py
- | 138| ••••••••alice•=•self.make_participant('alice',•balance=D('0.00'))
- | 139| ••••••••bob•=•self.make_participant('bob')
- | 140| ••••••••carl•=•self.make_participant('carl')
- | 141| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 142| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_public_json.py
- | 11| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 12| ••••••••bob•=•self.make_participant('bob')
- | 13|
- | 14| ••••••••alice.set_tip_to(bob,•'1.00')
- | 15|
- | 16| ••••••••data•=•json.loads(self.client.GET('/bob/public.json').body)
- tests/py/test_public_json.py
- | 27| •••••••••••••••••••••••••••••••••••••)
- | 28| ••••••••bob•=•self.make_participant('bob')
- | 29| ••••••••alice.set_tip_to(bob,•'1.00')
- | 30| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 31|
- | 32| ••••••••assert•data['giving']•==•None
- tests/py/test_public_json.py
- | 38| •••••••••••••••••••••••••••••••••••••)
- | 39| ••••••••bob•=•self.make_participant('bob')
- | 40| ••••••••alice.set_tip_to(bob,•'1.00')
- | 41| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 42|
- | 43| ••••••••assert•data['receiving']•==•None
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 209| ••••••••""")
- | 210| ••••••••payday•=•Payday.start()
- | 211| ••••••••with•self.db.get_cursor()•as•cursor:
- | 212| ••••••••••••payday.prepare(cursor,•payday.ts_start)
- tests/py/test_billing_payday.py
- | 230| ••••••••self.db.run("UPDATE•participants•SET•goal•=•-1•WHERE•username='homer'")
- | 231| ••••••••payday•=•Payday.start()
- | 232| ••••••••with•self.db.get_cursor()•as•cursor:
- | 233| ••••••••••••payday.prepare(cursor,•payday.ts_start)
- tests/py/test_billing_payday.py
- | 252| ••••••••self.david.set_tip_to(self.homer,•D('0.50'))
- | 253| ••••••••payday•=•Payday.start()
- | 254| ••••••••with•self.db.get_cursor()•as•cursor:
- | 255| ••••••••••••payday.prepare(cursor,•payday.ts_start)
- tests/py/test_billing_payday.py
- | 269| ••••••••self.david.set_tip_to(self.homer,•D('20'))••#•Should•be•unfunded
- | 270|
- | 271| ••••••••payday•=•Payday.start()
- | 272| ••••••••with•self.db.get_cursor()•as•cursor:
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 314| ••••def•test_underfunded_team(self):
- | 315| ••••••••self.clear_tables()
- | 316| ••••••••team•=•self.make_participant('team',•kind='group')
- | 317| ••••••••alice•=•self.make_participant('alice')
- tests/py/test_billing_payday.py
- | 384| ••••def•test_unfunded_tip_to_team_doesnt_cause_NegativeBalance(self):
- | 385| ••••••••self.clear_tables()
- | 386| ••••••••team•=•self.make_participant('team',•kind='group')
- | 387| ••••••••alice•=•self.make_participant('alice')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_take.py
- | 38| ••••def•test_team_member_is_team_member(self):
- | 39| ••••••••team•=•self.make_team()
- | 40| ••••••••alice•=•self.make_participant('alice')
- | 41| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 44| ••••def•test_cant_grow_tip_a_lot(self):
- | 45| ••••••••team•=•self.make_team()
- | 46| ••••••••alice•=•self.make_participant('alice')
- | 47| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 50| ••••def•test_take_can_double(self):
- | 51| ••••••••team•=•self.make_team()
- | 52| ••••••••alice•=•self.make_participant('alice')
- | 53| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 57| ••••def•test_take_can_double_but_not_a_penny_more(self):
- | 58| ••••••••team•=•self.make_team()
- | 59| ••••••••alice•=•self.make_participant('alice')
- | 60| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 78| ••••def•test_get_members(self):
- | 79| ••••••••team•=•self.make_team()
- | 80| ••••••••alice•=•self.make_participant('alice')
- | 81| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 89| ••••def•test_taking_and_receiving_are_updated_correctly(self):
- | 90| ••••••••team•=•self.make_team()
- | 91| ••••••••alice•=•self.make_participant('alice')
- | 92| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 120| ••••def•test_changes_to_team_receiving_affect_members_take(self):
- | 121| ••••••••team•=•self.make_team()
- | 122| ••••••••alice•=•self.make_participant('alice')
- | 123| ••••••••self.take_last_week(team,•alice,•'40.00')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 39| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 40| ••••••••bob•=•self.make_participant('bob')
- | 41| ••••••••carl•=•self.make_participant('carl',•balance=1.56)
- tests/py/test_participant.py
- | 316| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 317| ••••••••bob•=•self.make_participant('bob')
- | 318| ••••••••carl•=•self.make_participant('carl',•last_bill_result="Fail!")
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_search.py
- | 10| ••••••••response•=•self.client.GET('/search.json?q=alice&scope=usernames')
- | 11| ••••••••data•=•json.loads(response.body)['usernames']
- | 12| ••••••••assert•data•==•[]
- tests/py/test_search.py
- | 36| ••••••••response•=•self.client.GET('/search.json?q=alice&scope=usernames')
- | 37| ••••••••data•=•json.loads(response.body)['usernames']
- | 38| ••••••••assert•data•==•[]
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/models/account_elsewhere.py
- | 116| ••••••••cols,•vals•=•zip(*i.__dict__.items())
- | 117| ••••••••cols•=•',•'.join(cols)
- | 118| ••••••••placeholders•=•',•'.join(['%s']*len(vals))
- liberapay/models/participant.py
- | 88| ••••••••••••cols,•vals•=•zip(*kw.items())
- | 89| ••••••••••••cols•=•',•'.join(cols)
- | 90| ••••••••••••placeholders•=•',•'.join(['%s']*len(vals))
- liberapay/models/participant.py
- | 112| ••••••••cols,•vals•=•zip(*d.items())
- | 113| ••••••••cols•=•',•'.join(cols)
- | 114| ••••••••placeholders•=•',•'.join(['%s']*len(vals))
- liberapay/testing/__init__.py
- | 188| ••••••••cols,•vals•=•zip(*kw.items())
- | 189| ••••••••cols•=•',•'.join(cols)
- | 190| ••••••••placeholders•=•',•'.join(['%s']*len(vals))
- liberapay/utils/fake_data.py
- | 21| ••••cols,•vals•=•zip(*kw.items())
- | 22| ••••cols•=•',•'.join(cols)
- | 23| ••••placeholders•=•',•'.join(['%s']*len(vals))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_teams.py
- | 44| ••••••••r•=•self.client.PxST('/A-Team/membership/accept',•auth_as=self.bob)
- | 45| ••••••••assert•r.code•==•302
- | 46| ••••••••is_member•=•self.bob.member_of(self.a_team)
- | 47| ••••••••assert•is_member•is•True
- tests/py/test_teams.py
- | 61| ••••••••r•=•self.client.PxST('/A-Team/membership/refuse',•auth_as=self.bob)
- | 62| ••••••••assert•r.code•==•302
- | 63| ••••••••is_member•=•self.bob.member_of(self.a_team)
- | 64| ••••••••assert•is_member•is•False
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_hooks.py
- | 116| ••••def•test_error_spt_works(self):
- | 117| ••••••••r•=•self.client.POST('/',•csrf_token=False,•raise_immediately=False)
- | 118| ••••••••assert•r.code•==•403
- tests/py/test_hooks.py
- | 146| ••••def•test_no_csrf_cookie(self):
- | 147| ••••••••r•=•self.client.POST('/',•csrf_token=False,•raise_immediately=False)
- | 148| ••••••••assert•r.code•==•403
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 153| ••••def•test_ctg_clears_tips_giving(self):
- | 154| ••••••••alice•=•self.make_participant('alice')
- | 155| ••••••••alice.set_tip_to(self.make_participant('bob'),•D('1.00'))
- tests/py/test_close.py
- | 183| ••••def•test_ctg_clears_multiple_tips_giving(self):
- | 184| ••••••••alice•=•self.make_participant('alice')
- | 185| ••••••••alice.set_tip_to(self.make_participant('bob'),•D('1.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_communities.py
- | 25| class•TestCommunitiesJson(Harness):
- | 26|
- | 27| ••••def•setUp(self):
- | 28| ••••••••Harness.setUp(self)
- | 29| ••••••••self.alice•=•self.make_participant("alice")
- | 30| ••••••••self.c_id•=•str(self.alice.create_community('test').id)
- tests/py/test_communities.py
- | 63| class•TestCommunityActions(Harness):
- | 64|
- | 65| ••••def•setUp(self):
- | 66| ••••••••Harness.setUp(self)
- | 67| ••••••••self.alice•=•self.make_participant("alice")
- | 68| ••••••••self.bob•=•self.make_participant("bob")
- tests/py/test_communities.py
- | 108| class•TestCommunityEdit(Harness):
- | 109|
- | 110| ••••def•setUp(self):
- | 111| ••••••••Harness.setUp(self)
- | 112| ••••••••self.alice•=•self.make_participant("alice")
- | 113| ••••••••self.community•=•Community.create('test',•self.alice.id)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_communities.py
- | 42| •••••••••••••••••••••••••••••••••••,•xhr=True
- | 43| ••••••••••••••••••••••••••••••••••••)
- | 44|
- | 45| ••••••••r•=•json.loads(response.body)
- | 46| ••••••••assert•r•==•{}
- | 47|
- | 48| ••••••••response•=•self.client.POST(•'/alice/communities.json'
- tests/py/test_communities.py
- | 77| ••••••••response•=•self.client.POST('/for/test/subscribe',•auth_as=self.bob,
- | 78| ••••••••••••••••••••••••••••••••••••xhr=True)
- | 79|
- | 80| ••••••••r•=•json.loads(response.body)
- | 81| ••••••••assert•r•==•{}
- | 82|
- | 83| ••••••••response•=•self.client.POST('/for/test/unsubscribe',•auth_as=self.bob,
- tests/py/test_communities.py
- | 94| ••••••••response•=•self.client.POST('/for/test/join',•auth_as=self.bob,
- | 95| ••••••••••••••••••••••••••••••••••••xhr=True)
- | 96|
- | 97| ••••••••r•=•json.loads(response.body)
- | 98| ••••••••assert•r•==•{}
- | 99|
- | 100| ••••••••response•=•self.client.POST('/for/test/leave',•auth_as=self.bob,
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 314| ••••def•test_underfunded_team(self):
- | 315| ••••••••self.clear_tables()
- | 316| ••••••••team•=•self.make_participant('team',•kind='group')
- | 317| ••••••••alice•=•self.make_participant('alice')
- tests/py/test_billing_payday.py
- | 364| ••••def•test_mutual_tipping_through_teams(self):
- | 365| ••••••••self.clear_tables()
- | 366| ••••••••team•=•self.make_participant('team',•kind='group')
- | 367| ••••••••alice•=•self.make_participant('alice',•balance=8)
- tests/py/test_billing_payday.py
- | 384| ••••def•test_unfunded_tip_to_team_doesnt_cause_NegativeBalance(self):
- | 385| ••••••••self.clear_tables()
- | 386| ••••••••team•=•self.make_participant('team',•kind='group')
- | 387| ••••••••alice•=•self.make_participant('alice')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_pages.py
- | 131| ••••def•test_giving_page(self):
- | 132| ••••••••alice•=•self.make_participant('alice')
- | 133| ••••••••bob•=•self.make_participant('bob')
- | 134| ••••••••alice.set_tip_to(bob,•"1.00")
- tests/py/test_pages.py
- | 149| ••••def•test_giving_page_shows_cancelled(self):
- | 150| ••••••••alice•=•self.make_participant('alice')
- | 151| ••••••••bob•=•self.make_participant('bob')
- | 152| ••••••••alice.set_tip_to(bob,•"1.00")
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_take.py
- | 64| ••••def•test_increase_is_based_on_nominal_take_last_week(self):
- | 65| ••••••••team•=•self.make_team()
- | 66| ••••••••alice•=•self.make_participant('alice')
- | 67| ••••••••self.take_last_week(team,•alice,•'20.00',•actual_amount='15.03')
- tests/py/test_take.py
- | 166| ••••def•test_gtlwf_works_during_payday(self):
- | 167| ••••••••team•=•self.make_team()
- | 168| ••••••••alice•=•self.make_participant('alice')
- | 169| ••••••••self.take_last_week(team,•alice,•'20.00')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 401| ••••••••unclaimed•=•self.make_elsewhere('bitbucket',•'1234',•'alice')
- | 402| ••••••••stub•=•Participant.from_username(unclaimed.participant.username)
- | 403| ••••••••actual•=•stub.resolve_stub()
- | 404| ••••••••assert•actual•==•"/on/bitbucket/alice/"
- tests/py/test_participant.py
- | 407| ••••••••unclaimed•=•self.make_elsewhere('github',•'1234',•'alice')
- | 408| ••••••••stub•=•Participant.from_username(unclaimed.participant.username)
- | 409| ••••••••actual•=•stub.resolve_stub()
- | 410| ••••••••assert•actual•==•"/on/github/alice/"
- tests/py/test_participant.py
- | 413| ••••••••unclaimed•=•self.make_elsewhere('twitter',•'1234',•'alice')
- | 414| ••••••••stub•=•Participant.from_username(unclaimed.participant.username)
- | 415| ••••••••actual•=•stub.resolve_stub()
- | 416| ••••••••assert•actual•==•"/on/twitter/alice/"
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/models/participant.py
- | 48| from•liberapay.models.account_elsewhere•import•AccountElsewhere
- | 49| from•liberapay.models.community•import•Community
- | 50| from•liberapay.models.exchange_route•import•ExchangeRoute
- | 51| from•liberapay.notifications•import•EVENTS
- liberapay/wireup.py
- | 23| from•liberapay.models.account_elsewhere•import•AccountElsewhere
- | 24| from•liberapay.models.community•import•Community
- | 25| from•liberapay.models.exchange_route•import•ExchangeRoute
- | 26| from•liberapay.models.participant•import•Participant
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 20| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 21| ••••••••bob•=•self.make_participant('bob')
- | 22| ••••••••carl•=•self.make_participant('carl')
- tests/py/test_close.py
- | 101| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 102| ••••••••bob•=•self.make_participant('bob')
- | 103| ••••••••carl•=•self.make_stub()
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 157| ••••••••••••••••••••••••••••••••••••"WHERE•tipper=%s•AND•amount•>•0",
- | 158| ••••••••••••••••••••••••••••••••••••(alice.id,))
- | 159| ••••••••assert•ntips()•==•1
- | 160| ••••••••with•self.db.get_cursor()•as•cursor:
- | 161| ••••••••••••alice.clear_tips_giving(cursor)
- tests/py/test_close.py
- | 205| ••••••••••••••••••••••••••••••••••••"WHERE•tippee=%s•AND•amount•>•0",
- | 206| ••••••••••••••••••••••••••••••••••••(alice.id,))
- | 207| ••••••••assert•ntips()•==•1
- | 208| ••••••••with•self.db.get_cursor()•as•cursor:
- | 209| ••••••••••••alice.clear_tips_receiving(cursor)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 169| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tipper=%s",•(alice.id,))
- | 170| ••••••••assert•ntips()•==•2
- | 171| ••••••••with•self.db.get_cursor()•as•cursor:
- | 172| ••••••••••••alice.clear_tips_giving(cursor)
- tests/py/test_close.py
- | 217| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tippee=%s",•(alice.id,))
- | 218| ••••••••assert•ntips()•==•2
- | 219| ••••••••with•self.db.get_cursor()•as•cursor:
- | 220| ••••••••••••alice.clear_tips_receiving(cursor)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 177| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tipper=%s",•(alice.id,))
- | 178| ••••••••assert•ntips()•==•0
- | 179| ••••••••with•self.db.get_cursor()•as•cursor:
- | 180| ••••••••••••alice.clear_tips_giving(cursor)
- tests/py/test_close.py
- | 225| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tippee=%s",•(alice.id,))
- | 226| ••••••••assert•ntips()•==•0
- | 227| ••••••••with•self.db.get_cursor()•as•cursor:
- | 228| ••••••••••••alice.clear_tips_receiving(cursor)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 191| ••••••••••••••••••••••••••••••••••••"WHERE•tipper=%s•AND•amount•>•0",
- | 192| ••••••••••••••••••••••••••••••••••••(alice.id,))
- | 193| ••••••••assert•ntips()•==•5
- | 194| ••••••••with•self.db.get_cursor()•as•cursor:
- | 195| ••••••••••••alice.clear_tips_giving(cursor)
- tests/py/test_close.py
- | 239| ••••••••••••••••••••••••••••••••••••"WHERE•tippee=%s•AND•amount•>•0",
- | 240| ••••••••••••••••••••••••••••••••••••(alice.id,))
- | 241| ••••••••assert•ntips()•==•5
- | 242| ••••••••with•self.db.get_cursor()•as•cursor:
- | 243| ••••••••••••alice.clear_tips_receiving(cursor)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 203| ••••••••self.make_participant('bob').set_tip_to(alice,•D('1.00'))
- | 204| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•current_tips•"
- | 205| ••••••••••••••••••••••••••••••••••••"WHERE•tippee=%s•AND•amount•>•0",
- | 206| ••••••••••••••••••••••••••••••••••••(alice.id,))
- | 207| ••••••••assert•ntips()•==•1
- tests/py/test_close.py
- | 237| ••••••••self.make_participant('francis').set_tip_to(alice,•D('5.00'))
- | 238| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•current_tips•"
- | 239| ••••••••••••••••••••••••••••••••••••"WHERE•tippee=%s•AND•amount•>•0",
- | 240| ••••••••••••••••••••••••••••••••••••(alice.id,))
- | 241| ••••••••assert•ntips()•==•5
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_exchanges.py
- | 326| ••••def•test_sync_with_mangopay_transfers(self):
- | 327| ••••••••self.make_exchange('mango-cc',•10,•0,•self.janet)
- | 328| ••••••••with•mock.patch('liberapay.billing.exchanges.record_transfer_result')•as•rtr:
- tests/py/test_billing_exchanges.py
- | 340| ••••def•test_sync_with_mangopay_deletes_transfers_that_didnt_happen(self):
- | 341| ••••••••self.make_exchange('mango-cc',•10,•0,•self.janet)
- | 342| ••••••••with•mock.patch('liberapay.billing.exchanges.record_transfer_result')•as•rtr•\
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_take.py
- | 38| ••••def•test_team_member_is_team_member(self):
- | 39| ••••••••team•=•self.make_team()
- | 40| ••••••••alice•=•self.make_participant('alice')
- | 41| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 44| ••••def•test_cant_grow_tip_a_lot(self):
- | 45| ••••••••team•=•self.make_team()
- | 46| ••••••••alice•=•self.make_participant('alice')
- | 47| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 50| ••••def•test_take_can_double(self):
- | 51| ••••••••team•=•self.make_team()
- | 52| ••••••••alice•=•self.make_participant('alice')
- | 53| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 57| ••••def•test_take_can_double_but_not_a_penny_more(self):
- | 58| ••••••••team•=•self.make_team()
- | 59| ••••••••alice•=•self.make_participant('alice')
- | 60| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 64| ••••def•test_increase_is_based_on_nominal_take_last_week(self):
- | 65| ••••••••team•=•self.make_team()
- | 66| ••••••••alice•=•self.make_participant('alice')
- | 67| ••••••••self.take_last_week(team,•alice,•'20.00',•actual_amount='15.03')
- tests/py/test_take.py
- | 71| ••••def•test_if_last_week_is_less_than_one_can_increase_to_one(self):
- | 72| ••••••••team•=•self.make_team()
- | 73| ••••••••alice•=•self.make_participant('alice')
- | 74| ••••••••self.take_last_week(team,•alice,•'0.01')
- tests/py/test_take.py
- | 78| ••••def•test_get_members(self):
- | 79| ••••••••team•=•self.make_team()
- | 80| ••••••••alice•=•self.make_participant('alice')
- | 81| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 89| ••••def•test_taking_and_receiving_are_updated_correctly(self):
- | 90| ••••••••team•=•self.make_team()
- | 91| ••••••••alice•=•self.make_participant('alice')
- | 92| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 120| ••••def•test_changes_to_team_receiving_affect_members_take(self):
- | 121| ••••••••team•=•self.make_team()
- | 122| ••••••••alice•=•self.make_participant('alice')
- | 123| ••••••••self.take_last_week(team,•alice,•'40.00')
- tests/py/test_take.py
- | 130| ••••def•test_changes_to_others_take_affects_members_take(self):
- | 131| ••••••••team•=•self.make_team()
- | 132|
- | 133| ••••••••alice•=•self.make_participant('alice')
- tests/py/test_take.py
- | 147| ••••def•test_changes_to_others_take_can_increase_members_take(self):
- | 148| ••••••••team•=•self.make_team()
- | 149|
- | 150| ••••••••alice•=•self.make_participant('alice')
- tests/py/test_take.py
- | 166| ••••def•test_gtlwf_works_during_payday(self):
- | 167| ••••••••team•=•self.make_team()
- | 168| ••••••••alice•=•self.make_participant('alice')
- | 169| ••••••••self.take_last_week(team,•alice,•'20.00')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_elsewhere.py
- | 63| ••••••••cookie•=•b64encode_s(json.dumps(['query_data',•'connect',•'',•'2']))
- | 64| ••••••••response•=•self.client.GxT('/on/github/associate?state=deadbeef',
- tests/py/test_elsewhere.py
- | 74| ••••••••cookie•=•b64encode_s(json.dumps(['query_data',•'connect',•'',•'2']))
- | 75| ••••••••response•=•self.client.GxT(url,•auth_as=alice,
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_elsewhere.py
- | 211| ••••••••user_info•=•platform.extract_user_info(user_info_examples.twitter())
- | 212| ••••••••account•=•AccountElsewhere.upsert(user_info)
- | 213| ••••••••friends,•nfriends,•pages_urls•=•platform.get_friends_for(account)
- | 214| ••••••••assert•nfriends•>•0
- tests/py/test_elsewhere.py
- | 218| ••••••••user_info•=•platform.extract_user_info(user_info_examples.github())
- | 219| ••••••••account•=•AccountElsewhere.upsert(user_info)
- | 220| ••••••••friends,•nfriends,•pages_urls•=•platform.get_friends_for(account)
- | 221| ••••••••assert•nfriends•>•0
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 42| ••••def•test_empty_stub_is_deleted(self):
- | 43| ••••••••alice•=•self.make_participant('alice')
- | 44| ••••••••bob•=•self.make_elsewhere('twitter',•2,•'bob')
- | 45| ••••••••alice.take_over(bob)
- tests/py/test_participant.py
- | 57| ••••def•test_zero_cross_tip_doesnt_become_self_tip(self):
- | 58| ••••••••alice•=•self.make_participant('alice')
- | 59| ••••••••bob•=•self.make_elsewhere('twitter',•2,•'bob')
- | 60| ••••••••alice.set_tip_to(bob.participant,•'1.00')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/facebook.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- liberapay/elsewhere/gitlab.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- liberapay/elsewhere/linuxfr.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_stats.py
- | 32| ••••••••carl.set_tip_to(self.bob,•'3.00')
- | 33| ••••••••expected•=•([
- | 34| ••••••••••••[Decimal('1.00'),•1,•Decimal('1.00'),•0.5,•Decimal('0.25')],
- tests/py/test_stats.py
- | 43| ••••••••bad_cc.set_tip_to(self.bob,•'3.00')
- | 44| ••••••••expected•=•([[Decimal('1.00'),•1,•Decimal('1.00'),•1,•Decimal('1')]],
- | 45| ••••••••••••••••••••1.0,•Decimal('1.00'))
- tests/py/test_stats.py
- | 52| ••••••••missing_cc.set_tip_to(self.bob,•'3.00')
- | 53| ••••••••expected•=•([[Decimal('1.00'),•1,•Decimal('1.00'),•1,•Decimal('1')]],
- | 54| ••••••••••••••••••••1.0,•Decimal('1.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_communities.py
- | 7| from•liberapay.testing•import•Harness
- | 8|
- | 9|
- | 10| class•Tests(Harness):
- | 11|
- | 12| ••••def•setUp(self):
- | 13| ••••••••Harness.setUp(self)
- | 14|
- tests/py/test_hooks.py
- | 14| from•liberapay.testing•import•Harness
- | 15|
- | 16|
- | 17| class•Tests(Harness):
- | 18|
- | 19| ••••def•setUp(self):
- | 20| ••••••••Harness.setUp(self)
- | 21| ••••••••self.client.website.canonical_scheme•=•'https'
- tests/py/test_teams.py
- | 5| from•liberapay.testing•import•Harness
- | 6|
- | 7|
- | 8| class•Tests(Harness):
- | 9|
- | 10| ••••def•setUp(self):
- | 11| ••••••••Harness.setUp(self)
- | 12| ••••••••self.a_team•=•self.make_participant('A-Team',•kind='group')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_utils.py
- | 16| ••••••••state•=•self.client.GET('/alice/',•return_after='dispatch_request_to_filesystem',
- | 17| ••••••••••••••••••••••••••••••••want='state')
- | 18| ••••••••actual•=•utils.get_participant(state,•restrict=False)
- | 19| ••••••••assert•actual•==•expected
- | 20|
- | 21| ••••def•test_get_participant_gets_participant_from_id(self):
- tests/py/test_utils.py
- | 23| ••••••••state•=•self.client.POST('/~1/',•return_after='dispatch_request_to_filesystem',
- | 24| •••••••••••••••••••••••••••••••••want='state')
- | 25| ••••••••actual•=•utils.get_participant(state,•restrict=False)
- | 26| ••••••••assert•actual•==•expected
- | 27|
- | 28| ••••def•test_get_participant_raises_404_for_missing_id(self):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 37| ••••def•test_update_cached_amounts(self):
- | 38| ••••••••team•=•self.make_participant('team',•kind='group')
- | 39| ••••••••alice•=•self.make_participant('alice',•balance=100)
- tests/py/test_close.py
- | 18| ••••def•test_close_closes(self):
- | 19| ••••••••team•=•self.make_participant('team',•kind='group')
- | 20| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 43| ••••••••alice•=•self.make_participant('alice')
- | 44| ••••••••body•=•self.client.GET('/alice/settings/close',•auth_as=alice).text
- | 45| ••••••••assert•'Personal•Information'•in•body
- tests/py/test_close.py
- | 49| ••••••••alice•=•self.make_participant('alice')
- | 50| ••••••••body•=•self.client.GET('/alice/settings/close',•auth_as=alice).text
- | 51| ••••••••assert•'Personal•Information'•not•in•body
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 113| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 114| ••••••••bob•=•self.make_participant('bob')
- | 115| ••••••••carl•=•self.make_participant('carl')
- | 116| ••••••••alice.set_tip_to(bob,•D('0.00'))
- tests/py/test_close.py
- | 138| ••••••••alice•=•self.make_participant('alice',•balance=D('0.00'))
- | 139| ••••••••bob•=•self.make_participant('bob')
- | 140| ••••••••carl•=•self.make_participant('carl')
- | 141| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 117| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 118| ••••••••with•self.db.get_cursor()•as•cursor:
- | 119| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 120| ••••••••assert•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tippee=%s",•(bob.id,))•==•1
- tests/py/test_close.py
- | 142| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | 143| ••••••••with•self.db.get_cursor()•as•cursor:
- | 144| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 145| ••••••••assert•self.db.one("SELECT•count(*)•FROM•tips")•==•2
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 121| ••••••••assert•Participant.from_username('bob').balance•==•D('0.00')
- | 122| ••••••••assert•Participant.from_username('carl').balance•==•D('10.00')
- tests/py/test_close.py
- | 146| ••••••••assert•Participant.from_username('bob').balance•==•D('0.00')
- | 147| ••••••••assert•Participant.from_username('carl').balance•==•D('0.00')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_settings.py
- | 27| ••••••••self.hit_edit(data=ALL_ON)
- | 28| ••••••••alice•=•Participant.from_id(self.alice.id)
- | 29| ••••••••for•k•in•PRIVACY_FIELDS:
- | 30| ••••••••••••assert•getattr(alice,•k)•is•True
- tests/py/test_settings.py
- | 33| ••••••••self.hit_edit(data=ALL_OFF)
- | 34| ••••••••alice•=•Participant.from_id(self.alice.id)
- | 35| ••••••••for•k•in•PRIVACY_FIELDS:
- | 36| ••••••••••••assert•getattr(alice,•k)•is•False
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_pages.py
- | 172| ••••••••eid•=•self.make_exchange('mango-ba',•19,•0,•self.david,•'failed',•error)
- | 173| ••••••••r•=•self.client.GET('/david/wallet/payout/?exchange_id=%s'•%•eid,
- | 174| ••••••••••••••••••••••••••••auth_as=self.david)
- | 175| ••••••••assert•r.code•==•200
- | 176| ••••••••assert•error•in•r.body.decode('utf8')
- tests/py/test_pages.py
- | 179| ••••••••eid•=•self.make_exchange('mango-ba',•19,•0,•self.david)
- | 180| ••••••••r•=•self.client.GET('/david/wallet/payout/?exchange_id=%s'•%•eid,
- | 181| ••••••••••••••••••••••••••••auth_as=self.david)
- | 182| ••••••••assert•r.code•==•200
- | 183| ••••••••assert•'€19'•in•r.body.decode('utf8')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 51| ••••••••alice•=•self.make_participant('alice',•elsewhere='twitter')
- | 52| ••••••••bob•=•self.make_elsewhere('twitter',•2,•'bob')
- | 53| ••••••••alice.set_tip_to(bob.participant,•'1.00')
- | 54| ••••••••alice.take_over(bob,•have_confirmation=True)
- tests/py/test_participant.py
- | 58| ••••••••alice•=•self.make_participant('alice')
- | 59| ••••••••bob•=•self.make_elsewhere('twitter',•2,•'bob')
- | 60| ••••••••alice.set_tip_to(bob.participant,•'1.00')
- | 61| ••••••••alice.set_tip_to(bob.participant,•'0.00')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 401| ••••••••unclaimed•=•self.make_elsewhere('bitbucket',•'1234',•'alice')
- | 402| ••••••••stub•=•Participant.from_username(unclaimed.participant.username)
- | 403| ••••••••actual•=•stub.resolve_stub()
- | 404| ••••••••assert•actual•==•"/on/bitbucket/alice/"
- tests/py/test_participant.py
- | 407| ••••••••unclaimed•=•self.make_elsewhere('github',•'1234',•'alice')
- | 408| ••••••••stub•=•Participant.from_username(unclaimed.participant.username)
- | 409| ••••••••actual•=•stub.resolve_stub()
- | 410| ••••••••assert•actual•==•"/on/github/alice/"
- tests/py/test_participant.py
- | 413| ••••••••unclaimed•=•self.make_elsewhere('twitter',•'1234',•'alice')
- | 414| ••••••••stub•=•Participant.from_username(unclaimed.participant.username)
- | 415| ••••••••actual•=•stub.resolve_stub()
- | 416| ••••••••assert•actual•==•"/on/twitter/alice/"
- tests/py/test_participant.py
- | 419| ••••••••unclaimed•=•self.make_elsewhere('openstreetmap',•'1',•'alice')
- | 420| ••••••••stub•=•Participant.from_username(unclaimed.participant.username)
- | 421| ••••••••actual•=•stub.resolve_stub()
- | 422| ••••••••assert•actual•==•"/on/openstreetmap/alice/"
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_search.py
- | 15| ••••••••self.make_participant('alice')
- | 16| ••••••••response•=•self.client.GET('/search.json?q=alice&scope=usernames')
- | 17| ••••••••data•=•json.loads(response.body)['usernames']
- | 18| ••••••••assert•len(data)•==•1
- tests/py/test_search.py
- | 35| ••••••••self.make_participant('alice',•hide_from_search=True)
- | 36| ••••••••response•=•self.client.GET('/search.json?q=alice&scope=usernames')
- | 37| ••••••••data•=•json.loads(response.body)['usernames']
- | 38| ••••••••assert•data•==•[]
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/facebook.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- liberapay/elsewhere/gitlab.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- liberapay/elsewhere/google.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•any_key,•key
- liberapay/elsewhere/linuxfr.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_email.py
- | 48| ••••••••self.hit_email_spt('add-email',•'alice@example.com')
- | 49| ••••••••assert•self.mailer.call_count•==•1
- | 50| ••••••••last_email•=•self.get_last_email()
- | 51| ••••••••assert•last_email['to'][0]•==•'alice•<alice@example.com>'
- tests/py/test_email.py
- | 225| ••••••••Participant.dequeue_emails()
- | 226| ••••••••assert•self.mailer.call_count•==•1
- | 227| ••••••••last_email•=•self.get_last_email()
- | 228| ••••••••assert•last_email['to'][0]•==•'larry•<larry@example.com>'
- tests/py/test_email_notifs.py
- | 21| ••••••••Participant.dequeue_emails()
- | 22| ••••••••assert•self.mailer.call_count•==•1
- | 23| ••••••••last_email•=•self.get_last_email()
- | 24| ••••••••assert•last_email['to'][0]•==•'bob•<bob@example.com>'
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_email.py
- | 91| ••••••••self.hit_email_spt('add-email',•address)
- | 92| ••••••••nonce•=•self.alice.get_email(address).nonce
- | 93| ••••••••r•=•self.alice.verify_email(address,•nonce)
- tests/py/test_email.py
- | 104| ••••••••""",•(self.alice.id,))
- | 105| ••••••••nonce•=•self.alice.get_email(address).nonce
- | 106| ••••••••r•=•self.alice.verify_email(address,•nonce)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/billing/exchanges.py
- | 148| ••••••••return•record_exchange_result(db,•e_id,•payout.Status.lower(),•repr_error(payout),•participant)
- | 149| ••••except•Exception•as•e:
- | 150| ••••••••error•=•repr_exception(e)
- | 151| ••••••••return•record_exchange_result(db,•e_id,•'failed',•error,•participant)
- liberapay/billing/exchanges.py
- | 185| ••••••••payin•=•mangoapi.payIns.Create(payin)
- | 186| ••••except•Exception•as•e:
- | 187| ••••••••error•=•repr_exception(e)
- | 188| ••••••••return•record_exchange_result(db,•e_id,•'failed',•error,•participant)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 168| ••••••••alice.set_tip_to(bob,•D('0.00'))
- | 169| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tipper=%s",•(alice.id,))
- | 170| ••••••••assert•ntips()•==•2
- tests/py/test_close.py
- | 176| ••••••••alice•=•self.make_participant('alice')
- | 177| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tipper=%s",•(alice.id,))
- | 178| ••••••••assert•ntips()•==•0
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 216| ••••••••bob.set_tip_to(alice,•D('0.00'))
- | 217| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tippee=%s",•(alice.id,))
- | 218| ••••••••assert•ntips()•==•2
- tests/py/test_close.py
- | 224| ••••••••alice•=•self.make_participant('alice')
- | 225| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tippee=%s",•(alice.id,))
- | 226| ••••••••assert•ntips()•==•0
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_communities.py
- | 10| class•Tests(Harness):
- | 11|
- | 12| ••••def•setUp(self):
- | 13| ••••••••Harness.setUp(self)
- | 14|
- tests/py/test_settings.py
- | 13| class•TestPrivacy(Harness):
- | 14|
- | 15| ••••def•setUp(self):
- | 16| ••••••••Harness.setUp(self)
- | 17| ••••••••self.alice•=•self.make_participant('alice')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_exchanges.py
- | 290| ••••••••••••••••charge(self.db,•self.janet,•CHARGE_MIN,•'http://localhost/')
- | 291| ••••••••exchange•=•self.db.one("SELECT•*•FROM•exchanges")
- | 292| ••••••••assert•exchange.status•==•'pre'
- | 293| ••••••••sync_with_mangopay(self.db)
- tests/py/test_billing_exchanges.py
- | 303| ••••••••••••••••charge(self.db,•self.janet,•D('33.67'),•'http://localhost/')
- | 304| ••••••••exchange•=•self.db.one("SELECT•*•FROM•exchanges")
- | 305| ••••••••assert•exchange.status•==•'pre'
- | 306| ••••••••sync_with_mangopay(self.db)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 341| ••••••••self.clear_tables()
- | 342| ••••••••team•=•self.make_participant('team',•kind='group')
- | 343| ••••••••alice•=•self.make_participant('alice')
- tests/py/test_billing_payday.py
- | 385| ••••••••self.clear_tables()
- | 386| ••••••••team•=•self.make_participant('team',•kind='group')
- | 387| ••••••••alice•=•self.make_participant('alice')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/_extractors.py
- | 82| ••••••••••••••••msg•%=•(path,•self.name,•ET.tostring(info))
- | 83| ••••••••••••••••log(msg)
- | 84| ••••••••••••••••raise•ValueError(msg)
- liberapay/elsewhere/_extractors.py
- | 104| ••••••••••••msg•%=•(path,•self.name,•ET.tostring(info))
- | 105| ••••••••••••log(msg)
- | 106| ••••••••••••raise•ValueError(msg)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_pages.py
- | 120| ••••def•test_sign_out_overwrites_session_cookie(self):
- | 121| ••••••••alice•=•self.make_participant('alice')
- | 122| ••••••••response•=•self.client.PxST('/sign-out.html',•auth_as=alice)
- tests/py/test_pages.py
- | 126| ••••def•test_sign_out_doesnt_redirect_xhr(self):
- | 127| ••••••••alice•=•self.make_participant('alice')
- | 128| ••••••••response•=•self.client.PxST('/sign-out.html',•auth_as=alice,•xhr=True)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/openstreetmap.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth1
- | 4| from•liberapay.elsewhere._extractors•import•not_available,•xpath
- liberapay/elsewhere/twitter.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth1
- | 4| from•liberapay.elsewhere._extractors•import•key,•not_available
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_elsewhere.py
- | 183| ••••••••response•=•self.client.GxT(url,•auth_as=self.bob)
- | 184| ••••••••assert•response.code•==•400
- | 185| ••••••••assert•'bad•connect•token'•in•response.text
- | 186|
- | 187| ••••••••response•=•self.client.GET(url,•auth_as=self.bob,•cookies=self.connect_cookie)
- tests/py/test_elsewhere.py
- | 197| ••••••••response•=•self.client.PxST('/on/take-over.html',•data=data,•auth_as=self.bob)
- | 198| ••••••••assert•response.code•==•400
- | 199| ••••••••assert•'bad•connect•token'•in•response.text
- | 200|
- | 201| ••••••••response•=•self.client.PxST('/on/take-over.html',•data=data,•auth_as=self.bob,
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 280| ••••def•test_stt_works_for_donations(self):
- | 281| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 282| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 289| ••••def•test_stt_returns_False_for_second_time_tipper(self):
- | 290| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 291| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 302| ••••def•test_stt_doesnt_allow_just_any_ole_amount(self):
- | 303| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 304| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 315| ••••def•test_only_funded_tips_count(self):
- | 316| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 317| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 357| ••••def•test_receiving_is_zero_for_patrons(self):
- | 358| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 359| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 10| ••••def•test_anonymous(self):
- | 11| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 12| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 60| ••••def•test_authenticated_user_gets_their_tip(self):
- | 61| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 62| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 104| ••••def•test_authenticated_user_gets_self_for_self(self):
- | 105| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 106| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 123| ••••def•test_jsonp_works(self):
- | 124| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 125| ••••••••bob•=•self.make_participant('bob')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 338| ••••def•test_only_latest_tip_counts(self):
- | 339| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 340| ••••••••bob•=•self.make_participant('bob',•balance=100)
- tests/py/test_participant.py
- | 351| ••••def•test_receiving_includes_taking_when_updated_from_set_tip_to(self):
- | 352| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 353| ••••••••bob•=•self.make_participant('bob',•taking=Decimal('42.00'))
- tests/py/test_public_json.py
- | 73| ••••def•test_authenticated_user_doesnt_get_other_peoples_tips(self):
- | 74| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 75| ••••••••bob•=•self.make_participant('bob',•balance=100)
- tests/py/test_public_json.py
- | 90| ••••def•test_authenticated_user_gets_zero_if_they_dont_tip(self):
- | 91| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 92| ••••••••bob•=•self.make_participant('bob',•balance=100)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_search.py
- | 10| ••••••••response•=•self.client.GET('/search.json?q=alice&scope=usernames')
- | 11| ••••••••data•=•json.loads(response.body)['usernames']
- | 12| ••••••••assert•data•==•[]
- tests/py/test_search.py
- | 16| ••••••••response•=•self.client.GET('/search.json?q=alice&scope=usernames')
- | 17| ••••••••data•=•json.loads(response.body)['usernames']
- | 18| ••••••••assert•len(data)•==•1
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_tips_json.py
- | 24| •••••••••••••••••••••••••••••••••••,•auth_as=test_tipper
- | 25| ••••••••••••••••••••••••••••••••••••)
- | 26|
- | 27| ••••••••assert•response.code•==•200
- | 28| ••••••••assert•len(json.loads(response.body))•==•2
- tests/py/test_tips_json.py
- | 40| ••••••••response•=•self.client.GET('/test_tipper/tips.json',•auth_as=test_tipper)
- | 41| ••••••••assert•response.code•==•200
- | 42| ••••••••assert•len(json.loads(response.body))•==•tippees
- | 43|
- | 44| ••••def•test_get_response(self):
- tests/py/test_tips_json.py
- | 47| ••••••••response•=•self.client.GET('/test_tipper/tips.json',•auth_as=test_tipper)
- | 48|
- | 49| ••••••••assert•response.code•==•200
- | 50| ••••••••assert•len(json.loads(response.body))•==•0•#•empty•array
- | 51|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_email.py
- | 222| ••••••••larry.queue_email("verification",•link='https://example.com/larry')
- | 223|
- | 224| ••••••••assert•self.db.one("SELECT•spt_name•FROM•email_queue")•==•"verification"
- | 225| ••••••••Participant.dequeue_emails()
- | 226| ••••••••assert•self.mailer.call_count•==•1
- tests/py/test_email.py
- | 235| ••••••••larry.queue_email("verification")
- | 236|
- | 237| ••••••••assert•self.db.one("SELECT•spt_name•FROM•email_queue")•==•"verification"
- | 238| ••••••••Participant.dequeue_emails()
- | 239| ••••••••assert•self.mailer.call_count•==•0
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 91| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 92| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 93| ••••••••with•self.db.get_cursor()•as•cursor:
- tests/py/test_close.py
- | 116| ••••••••alice.set_tip_to(bob,•D('0.00'))
- | 117| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 118| ••••••••with•self.db.get_cursor()•as•cursor:
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 160| ••••••••with•self.db.get_cursor()•as•cursor:
- | 161| ••••••••••••alice.clear_tips_giving(cursor)
- | 162| ••••••••assert•ntips()•==•0
- | 163|
- | 164| ••••def•test_ctg_doesnt_duplicate_zero_tips(self):
- tests/py/test_close.py
- | 179| ••••••••with•self.db.get_cursor()•as•cursor:
- | 180| ••••••••••••alice.clear_tips_giving(cursor)
- | 181| ••••••••assert•ntips()•==•0
- | 182|
- | 183| ••••def•test_ctg_clears_multiple_tips_giving(self):
- tests/py/test_close.py
- | 194| ••••••••with•self.db.get_cursor()•as•cursor:
- | 195| ••••••••••••alice.clear_tips_giving(cursor)
- | 196| ••••••••assert•ntips()•==•0
- | 197|
- | 198|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 208| ••••••••with•self.db.get_cursor()•as•cursor:
- | 209| ••••••••••••alice.clear_tips_receiving(cursor)
- | 210| ••••••••assert•ntips()•==•0
- | 211|
- | 212| ••••def•test_ctr_doesnt_duplicate_zero_tips(self):
- tests/py/test_close.py
- | 227| ••••••••with•self.db.get_cursor()•as•cursor:
- | 228| ••••••••••••alice.clear_tips_receiving(cursor)
- | 229| ••••••••assert•ntips()•==•0
- | 230|
- | 231| ••••def•test_ctr_clears_multiple_tips_receiving(self):
- tests/py/test_close.py
- | 242| ••••••••with•self.db.get_cursor()•as•cursor:
- | 243| ••••••••••••alice.clear_tips_receiving(cursor)
- | 244| ••••••••assert•ntips()•==•0
- | 245|
- | 246|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_communities.py
- | 10| class•Tests(Harness):
- | 11|
- | 12| ••••def•setUp(self):
- | 13| ••••••••Harness.setUp(self)
- | 14|
- tests/py/test_communities.py
- | 25| class•TestCommunitiesJson(Harness):
- | 26|
- | 27| ••••def•setUp(self):
- | 28| ••••••••Harness.setUp(self)
- | 29| ••••••••self.alice•=•self.make_participant("alice")
- tests/py/test_communities.py
- | 63| class•TestCommunityActions(Harness):
- | 64|
- | 65| ••••def•setUp(self):
- | 66| ••••••••Harness.setUp(self)
- | 67| ••••••••self.alice•=•self.make_participant("alice")
- tests/py/test_communities.py
- | 108| class•TestCommunityEdit(Harness):
- | 109|
- | 110| ••••def•setUp(self):
- | 111| ••••••••Harness.setUp(self)
- | 112| ••••••••self.alice•=•self.make_participant("alice")
- tests/py/test_settings.py
- | 13| class•TestPrivacy(Harness):
- | 14|
- | 15| ••••def•setUp(self):
- | 16| ••••••••Harness.setUp(self)
- | 17| ••••••••self.alice•=•self.make_participant('alice')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_exchanges.py
- | 145| ••••••••janet•=•Participant.from_id(self.janet.id)
- | 146| ••••••••assert•self.janet.balance•==•janet.balance•==•0
- tests/py/test_billing_exchanges.py
- | 241| ••••••••janet•=•Participant.from_id(self.janet.id)
- | 242| ••••••••assert•self.janet.balance•==•janet.balance•==•0
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_exchanges.py
- | 154| ••••••••bob•=•self.make_participant('bob')
- | 155| ••••••••with•self.assertRaises(AssertionError):
- | 156| ••••••••••••charge(self.db,•bob,•D('10.00'),•'http://localhost/')
- tests/py/test_billing_exchanges.py
- | 159| ••••••••bob•=•self.make_participant('bob',•last_bill_result='invalidated')
- | 160| ••••••••with•self.assertRaises(AssertionError):
- | 161| ••••••••••••charge(self.db,•bob,•D('10.00'),•'http://localhost/')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/facebook.py
- | 31| ••••x_user_id•=•key('id')
- | 32| ••••x_user_name•=•key('username')
- | 33| ••••x_display_name•=•key('name')
- | 34| ••••x_email•=•key('email')
- liberapay/elsewhere/gitlab.py
- | 34| ••••x_user_id•=•key('id')
- | 35| ••••x_user_name•=•key('username')
- | 36| ••••x_display_name•=•key('name')
- | 37| ••••x_email•=•key('email')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_public_json.py
- | 51| ••••••••self.make_participant('alice',•balance=100)
- | 52| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 53| ••••••••assert•data['goal']•==•None
- tests/py/test_public_json.py
- | 56| ••••••••self.make_participant('alice',•balance=100,•goal=1)
- | 57| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 58| ••••••••assert•data['goal']•==•'1.00'
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_public_json.py
- | 97| ••••••••raw•=•self.client.GET('/carl/public.json',•auth_as=alice).body
- | 98|
- | 99| ••••••••data•=•json.loads(raw)
- | 100|
- | 101| ••••••••assert•data['receiving']•==•'3.00'
- | 102| ••••••••assert•data['my_tip']•==•'0.00'
- tests/py/test_public_json.py
- | 110| ••••••••raw•=•self.client.GET('/bob/public.json',•auth_as=bob).body
- | 111|
- | 112| ••••••••data•=•json.loads(raw)
- | 113|
- | 114| ••••••••assert•data['receiving']•==•'3.00'
- | 115| ••••••••assert•data['my_tip']•==•'self'
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 341| ••••••••self.clear_tables()
- | 342| ••••••••team•=•self.make_participant('team',•kind='group')
- | 343| ••••••••alice•=•self.make_participant('alice')
- tests/py/test_billing_payday.py
- | 365| ••••••••self.clear_tables()
- | 366| ••••••••team•=•self.make_participant('team',•kind='group')
- | 367| ••••••••alice•=•self.make_participant('alice',•balance=8)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/_extractors.py
- | 53| def•key(k,•clean=lambda•a:•a):
- | 54| ••••def•f(self,•extracted,•info,•*default):
- | 55| ••••••••try:
- liberapay/elsewhere/_extractors.py
- | 76| def•xpath(path,•attr=None,•clean=lambda•a:•a):
- | 77| ••••def•f(self,•extracted,•info,•*default):
- | 78| ••••••••try:
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 280| ••••def•test_stt_works_for_donations(self):
- | 281| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 282| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 289| ••••def•test_stt_returns_False_for_second_time_tipper(self):
- | 290| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 291| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 302| ••••def•test_stt_doesnt_allow_just_any_ole_amount(self):
- | 303| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 304| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 315| ••••def•test_only_funded_tips_count(self):
- | 316| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 317| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 338| ••••def•test_only_latest_tip_counts(self):
- | 339| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 340| ••••••••bob•=•self.make_participant('bob',•balance=100)
- tests/py/test_participant.py
- | 351| ••••def•test_receiving_includes_taking_when_updated_from_set_tip_to(self):
- | 352| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 353| ••••••••bob•=•self.make_participant('bob',•taking=Decimal('42.00'))
- tests/py/test_participant.py
- | 357| ••••def•test_receiving_is_zero_for_patrons(self):
- | 358| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 359| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 10| ••••def•test_anonymous(self):
- | 11| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 12| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 60| ••••def•test_authenticated_user_gets_their_tip(self):
- | 61| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 62| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 73| ••••def•test_authenticated_user_doesnt_get_other_peoples_tips(self):
- | 74| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 75| ••••••••bob•=•self.make_participant('bob',•balance=100)
- tests/py/test_public_json.py
- | 90| ••••def•test_authenticated_user_gets_zero_if_they_dont_tip(self):
- | 91| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 92| ••••••••bob•=•self.make_participant('bob',•balance=100)
- tests/py/test_public_json.py
- | 104| ••••def•test_authenticated_user_gets_self_for_self(self):
- | 105| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 106| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 123| ••••def•test_jsonp_works(self):
- | 124| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 125| ••••••••bob•=•self.make_participant('bob')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/facebook.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- liberapay/elsewhere/github.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._exceptions•import•CantReadMembership
- liberapay/elsewhere/gitlab.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- liberapay/elsewhere/google.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•any_key,•key
- liberapay/elsewhere/linuxfr.py
- | 1| from•__future__•import•absolute_import,•division,•print_function,•unicode_literals
- | 2|
- | 3| from•liberapay.elsewhere._base•import•PlatformOAuth2
- | 4| from•liberapay.elsewhere._extractors•import•key
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 47| ••••def•test_close_page_is_not_available_during_payday(self):
- | 48| ••••••••Payday.start()
- | 49| ••••••••alice•=•self.make_participant('alice')
- | 50| ••••••••body•=•self.client.GET('/alice/settings/close',•auth_as=alice).text
- tests/py/test_close.py
- | 66| ••••def•test_cant_post_to_close_page_during_payday(self):
- | 67| ••••••••Payday.start()
- | 68| ••••••••alice•=•self.make_participant('alice')
- | 69| ••••••••body•=•self.client.POST('/alice/settings/close',•auth_as=alice).text
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 75| ••••def•test_dbafg_distributes_balance_as_final_gift(self):
- | 76| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 77| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_close.py
- | 87| ••••def•test_dbafg_needs_claimed_tips(self):
- | 88| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 89| ••••••••bob•=•self.make_stub()
- tests/py/test_close.py
- | 100| ••••def•test_dbafg_gives_all_to_claimed(self):
- | 101| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 102| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_close.py
- | 112| ••••def•test_dbafg_skips_zero_tips(self):
- | 113| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 114| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_close.py
- | 125| ••••def•test_dbafg_favors_highest_tippee_in_rounding_errors(self):
- | 126| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | 127| ••••••••bob•=•self.make_participant('bob')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_tip_json.py
- | 63| ••••••••response•=•self.tip(bob,•alice.participant.username,•"10.00")
- | 64| ••••••••data•=•json.loads(response.body)
- | 65| ••••••••assert•response.code•==•200
- | 66| ••••••••assert•data['amount']•==•"10.00"
- tests/py/test_tip_json.py
- | 70| ••••••••response•=•self.tip(bob,•alice.participant.username,•"0.00")
- | 71| ••••••••data•=•json.loads(response.body)
- | 72| ••••••••assert•response.code•==•200
- | 73| ••••••••assert•data['amount']•==•"0.00"
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/_paginators.py
- | 60| ••••••••total_count•=•parsed.get(total_key,•-1)•if•links•else•len(page)
- | 61| ••••••••return•page,•total_count,•links
- | 62| ••••return•f
- liberapay/elsewhere/_paginators.py
- | 88| ••••••••total_count•=•paging.get(total_key,•-1)•if•links•else•len(page)
- | 89| ••••••••return•page,•total_count,•links
- | 90| ••••return•f
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_public_json.py
- | 20| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 21| ••••••••assert•data['giving']•==•'1.00'
- tests/py/test_public_json.py
- | 30| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 31|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/utils/fake_data.py
- | 173| ••••••••team•=•fake_participant(db,•kind="group")
- | 174| ••••••••#Add•1•to•3•members•to•the•team
- | 175| ••••••••members•=•random.sample(participants,•random.randint(1,•3))
- | 176| ••••••••for•p•in•members:
- liberapay/utils/fake_data.py
- | 192| ••••••••community•=•fake_community(db,•creator[0])
- | 193|
- | 194| ••••••••members•=•random.sample(participants,•random.randint(1,•3))
- | 195| ••••••••for•p•in•members:
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_charts_json.py
- | 38| ••••••••self.run_payday()•••#•first
- | 39|
- | 40| ••••••••expected•=•[•{•"date":•today()
- | 41| •••••••••••••••••••••,•"npatrons":•2
- | 42| •••••••••••••••••••••,•"receipts":•3.00
- | 43| ••••••••••••••••••••••}
- tests/py/test_charts_json.py
- | 106| ••••••••self.run_payday()•••#•third
- | 107|
- | 108| ••••••••expected•=•[•{•"date":•today()
- | 109| •••••••••••••••••••••,•"npatrons":•2•#•most•recent•first
- | 110| •••••••••••••••••••••,•"receipts":•3.00
- | 111| ••••••••••••••••••••••}
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_elsewhere.py
- | 26| ••••def•test_extract_user_info(self):
- | 27| ••••••••for•platform•in•self.platforms:
- | 28| ••••••••••••user_info•=•getattr(user_info_examples,•platform.name)()
- tests/py/test_elsewhere.py
- | 91| ••••def•test_upsert(self):
- | 92| ••••••••for•platform•in•self.platforms:
- | 93| ••••••••••••user_info•=•getattr(user_info_examples,•platform.name)()
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 50| ••••def•test_cross_tip_doesnt_become_self_tip(self):
- | 51| ••••••••alice•=•self.make_participant('alice',•elsewhere='twitter')
- | 52| ••••••••bob•=•self.make_elsewhere('twitter',•2,•'bob')
- tests/py/test_participant.py
- | 89| ••••def•test_idempotent(self):
- | 90| ••••••••alice•=•self.make_participant('alice',•elsewhere='twitter')
- | 91| ••••••••bob•=•self.make_elsewhere('github',•2,•'bob')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 261| ••••def•test_stt_sets_tip_to(self):
- | 262| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 263| ••••••••bob•=•self.make_stub()
- tests/py/test_participant.py
- | 370| ••••def•test_cant_pledge_to_locked_accounts(self):
- | 371| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 372| ••••••••bob•=•self.make_stub(goal=-1)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 74| ••••••••••••assert•emma.npatrons•==•1
- | 75| ••••••••••••funded_tips•=•self.db.all("SELECT•amount•FROM•tips•WHERE•is_funded•ORDER•BY•id")
- | 76| ••••••••••••assert•funded_tips•==•[3,•6,•0.5,•D('1.20'),•D('0.49'),•5,•2]
- | 77|
- tests/py/test_participant.py
- | 333| ••••••••assert•dana.npatrons•==•1
- | 334|
- | 335| ••••••••funded_tips•=•self.db.all("SELECT•amount•FROM•tips•WHERE•is_funded•ORDER•BY•id")
- | 336| ••••••••assert•funded_tips•==•[3,•6,•5]
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_teams.py
- | 60| ••••••••self.a_team.invite(self.bob,•self.alice)
- | 61| ••••••••r•=•self.client.PxST('/A-Team/membership/refuse',•auth_as=self.bob)
- tests/py/test_teams.py
- | 68| ••••••••self.a_team.invite(self.bob,•self.alice)
- | 69|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 38| ••••••••team•=•self.make_participant('team',•kind='group')
- | 39| ••••••••alice•=•self.make_participant('alice',•balance=100)
- tests/py/test_billing_payday.py
- | 366| ••••••••team•=•self.make_participant('team',•kind='group')
- | 367| ••••••••alice•=•self.make_participant('alice',•balance=8)
- tests/py/test_close.py
- | 19| ••••••••team•=•self.make_participant('team',•kind='group')
- | 20| ••••••••alice•=•self.make_participant('alice',•balance=D('10.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 105| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 106| ••••••••with•self.db.get_cursor()•as•cursor:
- | 107| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 108| ••••••••assert•Participant.from_id(bob.id).balance•==•D('10.00')
- tests/py/test_close.py
- | 130| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | 131| ••••••••with•self.db.get_cursor()•as•cursor:
- | 132| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 133| ••••••••assert•Participant.from_username('bob').balance•==•D('3.33')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 160| ••••••••with•self.db.get_cursor()•as•cursor:
- | 161| ••••••••••••alice.clear_tips_giving(cursor)
- | 162| ••••••••assert•ntips()•==•0
- tests/py/test_close.py
- | 171| ••••••••with•self.db.get_cursor()•as•cursor:
- | 172| ••••••••••••alice.clear_tips_giving(cursor)
- | 173| ••••••••assert•ntips()•==•2
- tests/py/test_close.py
- | 179| ••••••••with•self.db.get_cursor()•as•cursor:
- | 180| ••••••••••••alice.clear_tips_giving(cursor)
- | 181| ••••••••assert•ntips()•==•0
- tests/py/test_close.py
- | 194| ••••••••with•self.db.get_cursor()•as•cursor:
- | 195| ••••••••••••alice.clear_tips_giving(cursor)
- | 196| ••••••••assert•ntips()•==•0
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 175| ••••def•test_ctg_doesnt_zero_when_theres_no_tip(self):
- | 176| ••••••••alice•=•self.make_participant('alice')
- | 177| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tipper=%s",•(alice.id,))
- tests/py/test_close.py
- | 223| ••••def•test_ctr_doesnt_zero_when_theres_no_tip(self):
- | 224| ••••••••alice•=•self.make_participant('alice')
- | 225| ••••••••ntips•=•lambda:•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tippee=%s",•(alice.id,))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 208| ••••••••with•self.db.get_cursor()•as•cursor:
- | 209| ••••••••••••alice.clear_tips_receiving(cursor)
- | 210| ••••••••assert•ntips()•==•0
- tests/py/test_close.py
- | 219| ••••••••with•self.db.get_cursor()•as•cursor:
- | 220| ••••••••••••alice.clear_tips_receiving(cursor)
- | 221| ••••••••assert•ntips()•==•2
- tests/py/test_close.py
- | 227| ••••••••with•self.db.get_cursor()•as•cursor:
- | 228| ••••••••••••alice.clear_tips_receiving(cursor)
- | 229| ••••••••assert•ntips()•==•0
- tests/py/test_close.py
- | 242| ••••••••with•self.db.get_cursor()•as•cursor:
- | 243| ••••••••••••alice.clear_tips_receiving(cursor)
- | 244| ••••••••assert•ntips()•==•0
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 315| ••••••••self.clear_tables()
- | 316| ••••••••team•=•self.make_participant('team',•kind='group')
- | 317| ••••••••alice•=•self.make_participant('alice')
- tests/py/test_billing_payday.py
- | 341| ••••••••self.clear_tables()
- | 342| ••••••••team•=•self.make_participant('team',•kind='group')
- | 343| ••••••••alice•=•self.make_participant('alice')
- tests/py/test_billing_payday.py
- | 385| ••••••••self.clear_tables()
- | 386| ••••••••team•=•self.make_participant('team',•kind='group')
- | 387| ••••••••alice•=•self.make_participant('alice')
- tests/py/test_history.py
- | 43| ••••••••Payday.start().run()
- | 44| ••••••••team•=•self.make_participant('team',•kind='group')
- | 45| ••••••••alice•=•self.make_participant('alice')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_notifications.py
- | 13| ••••def•test_remove_notification(self):
- | 14| ••••••••alice•=•self.make_participant('alice')
- | 15| ••••••••bob•=•self.make_participant('bob')
- | 16| ••••••••alice.add_notification('abcd')
- tests/py/test_pages.py
- | 131| ••••def•test_giving_page(self):
- | 132| ••••••••alice•=•self.make_participant('alice')
- | 133| ••••••••bob•=•self.make_participant('bob')
- | 134| ••••••••alice.set_tip_to(bob,•"1.00")
- tests/py/test_pages.py
- | 149| ••••def•test_giving_page_shows_cancelled(self):
- | 150| ••••••••alice•=•self.make_participant('alice')
- | 151| ••••••••bob•=•self.make_participant('bob')
- | 152| ••••••••alice.set_tip_to(bob,•"1.00")
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 318| ••••••••team.set_take_for(alice,•D('1.00'),•alice)
- | 319| ••••••••bob•=•self.make_participant('bob')
- | 320| ••••••••team.set_take_for(bob,•D('1.00'),•bob)
- tests/py/test_billing_payday.py
- | 388| ••••••••alice.set_tip_to(team,•D('1.00'))••#•unfunded•tip
- | 389| ••••••••bob•=•self.make_participant('bob')
- | 390| ••••••••team.set_take_for(bob,•D('1.00'),•bob)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_elsewhere.py
- | 34| ••••@mock.patch('requests_oauthlib.OAuth2Session.fetch_token')
- | 35| ••••@mock.patch('liberapay.elsewhere._base.Platform.get_user_self_info')
- | 36| ••••@mock.patch('liberapay.elsewhere._base.Platform.get_user_info')
- | 37| ••••def•test_connect_success(self,•gui,•gusi,•ft):
- tests/py/test_elsewhere.py
- | 52| ••••@mock.patch('requests_oauthlib.OAuth2Session.fetch_token')
- | 53| ••••@mock.patch('liberapay.elsewhere._base.Platform.get_user_self_info')
- | 54| ••••@mock.patch('liberapay.elsewhere._base.Platform.get_user_info')
- | 55| ••••def•test_connect_might_need_confirmation(self,•gui,•gusi,•ft):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 297| ••••def•test_stt_doesnt_allow_self_tipping(self):
- | 298| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 299| ••••••••with•pytest.raises(NoSelfTipping):
- tests/py/test_participant.py
- | 308| ••••def•test_stt_fails_to_tip_unknown_people(self):
- | 309| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 310| ••••••••with•pytest.raises(NoTippee):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/utils/fake_data.py
- | 12| from•liberapay.models.exchange_route•import•ExchangeRoute
- | 13| from•liberapay.models.participant•import•Participant
- | 14| from•liberapay.models•import•community
- liberapay/wireup.py
- | 25| from•liberapay.models.exchange_route•import•ExchangeRoute
- | 26| from•liberapay.models.participant•import•Participant
- | 27| from•liberapay.models•import•DB
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/wireup.py
- | 148| ••••••••k[5:]:•v•for•k,•v•in•app_conf.__dict__.items()•if•k.startswith('smtp_')
- liberapay/wireup.py
- | 250| ••••••••••••k[len(cls.name)+1:]:•v
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_email.py
- | 114| ••••••••self.verify_email('alice@example.com',•nonce)
- | 115| ••••••••expected•=•'alice@example.com'
- | 116| ••••••••actual•=•Participant.from_username('alice').email
- | 117| ••••••••assert•expected•==•actual
- | 118|
- | 119| ••••def•test_email_verification_is_backwards_compatible(self):
- tests/py/test_email.py
- | 144| ••••••••self.verify_email('alice@example.net',•nonce)
- | 145| ••••••••expected•=•'alice@example.com'
- | 146| ••••••••actual•=•Participant.from_username('alice').email
- | 147| ••••••••assert•expected•==•actual
- | 148|
- | 149| ••••def•test_nonce_is_reused_when_resending_email(self):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 94| ••••••••••••with•pytest.raises(alice.NoOneToGiveFinalGiftTo):
- | 95| ••••••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 96| ••••••••assert•Participant.from_id(bob.id).balance•==•D('0.00')
- tests/py/test_close.py
- | 106| ••••••••with•self.db.get_cursor()•as•cursor:
- | 107| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 108| ••••••••assert•Participant.from_id(bob.id).balance•==•D('10.00')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_settings.py
- | 45| ••••def•test_team_participant_does_show_up_on_explore_teams(self):
- | 46| ••••••••alice•=•Participant.from_username('alice')
- | 47| ••••••••self.make_participant('A-Team',•kind='group').add_member(alice)
- tests/py/test_settings.py
- | 50| ••••def•test_team_participant_doesnt_show_up_on_explore_teams(self):
- | 51| ••••••••alice•=•Participant.from_username('alice')
- | 52| ••••••••self.make_participant('A-Team',•kind='group',•hide_from_search=True).add_member(alice)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_exchanges.py
- | 245| ••••def•test_record_exchange_result_restores_balance_on_error(self):
- | 246| ••••••••homer,•ba•=•self.homer,•self.homer_route
- | 247| ••••••••self.make_exchange('mango-cc',•30,•0,•homer)
- tests/py/test_billing_exchanges.py
- | 254| ••••def•test_record_exchange_result_restores_balance_on_error_with_invalidated_route(self):
- | 255| ••••••••homer,•ba•=•self.homer,•self.homer_route
- | 256| ••••••••self.make_exchange('mango-cc',•37,•0,•homer)
- tests/py/test_billing_exchanges.py
- | 265| ••••def•test_record_exchange_result_doesnt_restore_balance_on_success(self):
- | 266| ••••••••homer,•ba•=•self.homer,•self.homer_route
- | 267| ••••••••self.make_exchange('mango-cc',•50,•0,•homer)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_exchanges.py
- | 291| ••••••••exchange•=•self.db.one("SELECT•*•FROM•exchanges")
- | 292| ••••••••assert•exchange.status•==•'pre'
- | 293| ••••••••sync_with_mangopay(self.db)
- | 294| ••••••••exchange•=•self.db.one("SELECT•*•FROM•exchanges")
- tests/py/test_billing_exchanges.py
- | 318| ••••••••exchange•=•self.db.one("SELECT•*•FROM•exchanges•WHERE•amount•<•0")
- | 319| ••••••••assert•exchange.status•==•'pre'
- | 320| ••••••••sync_with_mangopay(self.db)
- | 321| ••••••••exchange•=•self.db.one("SELECT•*•FROM•exchanges•WHERE•amount•<•0")
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 365| ••••••••self.clear_tables()
- | 366| ••••••••team•=•self.make_participant('team',•kind='group')
- | 367| ••••••••alice•=•self.make_participant('alice',•balance=8)
- tests/py/test_history.py
- | 43| ••••••••Payday.start().run()
- | 44| ••••••••team•=•self.make_participant('team',•kind='group')
- | 45| ••••••••alice•=•self.make_participant('alice')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/utils/query_cache.py
- | 121| ••••••••self.locks.checkout.acquire()
- | 122| ••••••••try:••#•critical•section
- | 123| ••••••••••••if•key•in•self.cache:
- | 124|
- | 125| ••••••••••••••••#•Retrieve•an•already•cached•query.
- | 126| ••••••••••••••••#•=================================
- | 127| ••••••••••••••••#•The•cached•entry•may•be•a•dummy.•The•best•way•to•guarantee•we
- | 128| ••••••••••••••••#•will•catch•this•case•is•to•simply•refresh•our•entry•after•we
- | 129| ••••••••••••••••#•acquire•its•lock.
- | 130|
- | 131| ••••••••••••••••entry•=•self.cache[key]
- liberapay/utils/query_cache.py
- | 142| ••••••••••••••••self.locks.checkin.acquire()
- | 143| ••••••••••••••••try:••#•critical•section
- | 144| ••••••••••••••••••••if•key•in•self.cache:
- | 145| ••••••••••••••••••••••••#•Someone•beat•us•to•it.•XXX:•can•this•actually•happen?
- | 146| ••••••••••••••••••••••••entry•=•self.cache[key]
- | 147| ••••••••••••••••••••else:
- | 148| ••••••••••••••••••••••••self.cache[key]•=•dummy
- | 149| ••••••••••••••••••••••••entry•=•dummy
- | 150| ••••••••••••••••finally:
- | 151| ••••••••••••••••••••self.locks.checkin.release()
- | 152|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/cron.py
- | 26| ••••••••••••••••sleep(period)
- | 27| ••••••••t•=•threading.Thread(target=f)
- | 28| ••••••••t.daemon•=•True
- | 29| ••••••••t.start()
- liberapay/cron.py
- | 43| ••••••••••••••••self(*job,•exclusive=True)
- | 44| ••••••••t•=•threading.Thread(target=f)
- | 45| ••••••••t.daemon•=•True
- | 46| ••••••••t.start()
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/models/exchange_route.py
- | 33| ••••••••""",•locals())
- | 34| ••••••••if•r:
- | 35| ••••••••••••r.__dict__['participant']•=•participant
- | 36| ••••••••return•r
- | 37|
- | 38| ••••@classmethod
- | 39| ••••def•from_address(cls,•participant,•network,•address):
- liberapay/models/exchange_route.py
- | 47| ••••••••""",•locals())
- | 48| ••••••••if•r:
- | 49| ••••••••••••r.__dict__['participant']•=•participant
- | 50| ••••••••return•r
- | 51|
- | 52| ••••@classmethod
- | 53| ••••def•insert(cls,•participant,•network,•address,•error='',•one_off=False):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_public_json.py
- | 29| ••••••••alice.set_tip_to(bob,•'1.00')
- | 30| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 31|
- | 32| ••••••••assert•data['giving']•==•None
- tests/py/test_public_json.py
- | 40| ••••••••alice.set_tip_to(bob,•'1.00')
- | 41| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 42|
- | 43| ••••••••assert•data['receiving']•==•None
- tests/py/test_public_json.py
- | 51| ••••••••self.make_participant('alice',•balance=100)
- | 52| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 53| ••••••••assert•data['goal']•==•None
- | 54|
- tests/py/test_public_json.py
- | 56| ••••••••self.make_participant('alice',•balance=100,•goal=1)
- | 57| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 58| ••••••••assert•data['goal']•==•'1.00'
- | 59|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_public_json.py
- | 66| ••••••••raw•=•self.client.GET('/bob/public.json',•auth_as=alice).body
- | 67|
- | 68| ••••••••data•=•json.loads(raw)
- | 69|
- | 70| ••••••••assert•data['receiving']•==•'1.00'
- tests/py/test_public_json.py
- | 83| ••••••••raw•=•self.client.GET('/dana/public.json',•auth_as=alice).body
- | 84|
- | 85| ••••••••data•=•json.loads(raw)
- | 86|
- | 87| ••••••••assert•data['receiving']•==•'16.00'
- tests/py/test_public_json.py
- | 97| ••••••••raw•=•self.client.GET('/carl/public.json',•auth_as=alice).body
- | 98|
- | 99| ••••••••data•=•json.loads(raw)
- | 100|
- | 101| ••••••••assert•data['receiving']•==•'3.00'
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/elsewhere/_extractors.py
- | 82| ••••••••••••••••msg•%=•(path,•self.name,•ET.tostring(info))
- | 83| ••••••••••••••••log(msg)
- | 84| ••••••••••••••••raise•ValueError(msg)
- liberapay/elsewhere/_extractors.py
- | 90| ••••••••••••msg•%=•(path,•self.name,•ET.tostring(info))
- | 91| ••••••••••••log(msg)
- | 92| ••••••••••••raise•IndexError(msg)
- liberapay/elsewhere/_extractors.py
- | 104| ••••••••••••msg•%=•(path,•self.name,•ET.tostring(info))
- | 105| ••••••••••••log(msg)
- | 106| ••••••••••••raise•ValueError(msg)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_take.py
- | 139| ••••••••team.set_take_for(bob,•D('60.00'),•bob)
- | 140|
- | 141| ••••••••alice•=•Participant.from_username('alice')
- | 142| ••••••••assert•alice.receiving•==•alice.taking•==•40
- tests/py/test_take.py
- | 156| ••••••••team.set_take_for(bob,•D('100.00'),•bob)
- | 157| ••••••••alice•=•Participant.from_username('alice')
- | 158| ••••••••assert•alice.receiving•==•alice.taking•==•20
- | 159|
- tests/py/test_take.py
- | 160| ••••••••team.set_take_for(bob,•D('75.00'),•bob)
- | 161| ••••••••alice•=•Participant.from_username('alice')
- | 162| ••••••••assert•alice.receiving•==•alice.taking•==•25
- | 163|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_sign_in.py
- | 53| ••••def•test_log_in(self):
- | 54| ••••••••password•=•'password'
- | 55| ••••••••alice•=•self.make_participant('alice')
- | 56| ••••••••alice.update_password(password)
- tests/py/test_sign_in.py
- | 68| ••••def•test_log_in_switch_user(self):
- | 69| ••••••••password•=•'password'
- | 70| ••••••••alice•=•self.make_participant('alice')
- | 71| ••••••••alice.update_password(password)
- tests/py/test_sign_in.py
- | 78| ••••def•test_log_in_closed_account(self):
- | 79| ••••••••password•=•'password'
- | 80| ••••••••alice•=•self.make_participant('alice')
- | 81| ••••••••alice.update_password(password)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_sign_in.py
- | 55| ••••••••alice•=•self.make_participant('alice')
- | 56| ••••••••alice.update_password(password)
- | 57| ••••••••self.log_in_and_check(alice,•password)
- tests/py/test_sign_in.py
- | 104| ••••••••alice•=•self.make_participant('alice')
- | 105| ••••••••alice.update_password(password)
- | 106| ••••••••self.log_in_and_check(alice,•password.encode('utf8'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 212| ••••def•test_ctr_doesnt_duplicate_zero_tips(self):
- | 213| ••••••••alice•=•self.make_participant('alice')
- | 214| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_notifications.py
- | 13| ••••def•test_remove_notification(self):
- | 14| ••••••••alice•=•self.make_participant('alice')
- | 15| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_pages.py
- | 131| ••••def•test_giving_page(self):
- | 132| ••••••••alice•=•self.make_participant('alice')
- | 133| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_pages.py
- | 149| ••••def•test_giving_page_shows_cancelled(self):
- | 150| ••••••••alice•=•self.make_participant('alice')
- | 151| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 65| ••••def•test_do_not_take_over_zero_tips_receiving(self):
- | 66| ••••••••alice•=•self.make_participant('alice')
- | 67| ••••••••bob•=•self.make_participant('bob')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 76| ••••def•test_consolidated_tips_receiving(self):
- | 77| ••••••••alice•=•self.make_participant('alice',•balance=1)
- | 78| ••••••••bob•=•self.make_participant('bob',•elsewhere='twitter')
- tests/py/test_participant.py
- | 269| ••••def•test_stt_works_for_pledges(self):
- | 270| ••••••••alice•=•self.make_participant('alice',•balance=1)
- | 271| ••••••••bob•=•self.make_stub()
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_participant.py
- | 261| ••••def•test_stt_sets_tip_to(self):
- | 262| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 263| ••••••••bob•=•self.make_stub()
- tests/py/test_participant.py
- | 280| ••••def•test_stt_works_for_donations(self):
- | 281| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 282| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 289| ••••def•test_stt_returns_False_for_second_time_tipper(self):
- | 290| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 291| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 302| ••••def•test_stt_doesnt_allow_just_any_ole_amount(self):
- | 303| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 304| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 315| ••••def•test_only_funded_tips_count(self):
- | 316| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 317| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 338| ••••def•test_only_latest_tip_counts(self):
- | 339| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 340| ••••••••bob•=•self.make_participant('bob',•balance=100)
- tests/py/test_participant.py
- | 351| ••••def•test_receiving_includes_taking_when_updated_from_set_tip_to(self):
- | 352| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 353| ••••••••bob•=•self.make_participant('bob',•taking=Decimal('42.00'))
- tests/py/test_participant.py
- | 357| ••••def•test_receiving_is_zero_for_patrons(self):
- | 358| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 359| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 370| ••••def•test_cant_pledge_to_locked_accounts(self):
- | 371| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 372| ••••••••bob•=•self.make_stub(goal=-1)
- tests/py/test_participant.py
- | 376| ••••def•test_pledging_isnt_giving(self):
- | 377| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 378| ••••••••bob•=•self.make_elsewhere('github',•58946,•'bob').participant
- tests/py/test_public_json.py
- | 10| ••••def•test_anonymous(self):
- | 11| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 12| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 60| ••••def•test_authenticated_user_gets_their_tip(self):
- | 61| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 62| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 73| ••••def•test_authenticated_user_doesnt_get_other_peoples_tips(self):
- | 74| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 75| ••••••••bob•=•self.make_participant('bob',•balance=100)
- tests/py/test_public_json.py
- | 90| ••••def•test_authenticated_user_gets_zero_if_they_dont_tip(self):
- | 91| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 92| ••••••••bob•=•self.make_participant('bob',•balance=100)
- tests/py/test_public_json.py
- | 104| ••••def•test_authenticated_user_gets_self_for_self(self):
- | 105| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 106| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 123| ••••def•test_jsonp_works(self):
- | 124| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 125| ••••••••bob•=•self.make_participant('bob')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 39| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 40| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 281| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 282| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 290| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 291| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 303| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 304| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_participant.py
- | 358| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 359| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 11| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 12| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 61| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 62| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 105| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 106| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_public_json.py
- | 124| ••••••••alice•=•self.make_participant('alice',•balance=100)
- | 125| ••••••••bob•=•self.make_participant('bob')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_search.py
- | 10| ••••••••response•=•self.client.GET('/search.json?q=alice&scope=usernames')
- | 11| ••••••••data•=•json.loads(response.body)['usernames']
- | 12| ••••••••assert•data•==•[]
- | 13|
- | 14| ••••def•test_get_existing_user(self):
- tests/py/test_search.py
- | 23| ••••••••response•=•self.client.GET('/search.json?q=ali&scope=usernames')
- | 24| ••••••••data•=•json.loads(response.body)['usernames']
- | 25| ••••••••assert•data•==•[]
- | 26|
- | 27| ••••def•test_get_fuzzy_match(self):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- liberapay/models/participant.py
- |1070| ••••••••••••self.set_attributes(goal=goal)
- |1071| ••••••••••••if•not•self.accepts_tips:
- |1072| ••••••••••••••••self.clear_tips_receiving(c)
- |1073| ••••••••••••••••self.update_receiving(c)
- |1074|
- |1075| ••••def•update_status(self,•status,•cursor=None):
- liberapay/models/participant.py
- |1091| ••••••••••••self.add_event(c,•'set_status',•status)
- |1092| ••••••••••••if•not•self.accepts_tips:
- |1093| ••••••••••••••••self.clear_tips_receiving(c)
- |1094| ••••••••••••••••self.update_receiving(c)
- |1095|
- |1096| ••••def•update_giving_and_tippees(self,•cursor):
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_hooks.py
- | 59| ••••••••response•=•self.client.GET(•'/alice/public.json'
- | 60| ••••••••••••••••••••••••••••••••••,•HTTP_AUTHORIZATION=auth_header
- | 61| ••••••••••••••••••••••••••••••••••,•HTTP_X_FORWARDED_PROTO=b'https'
- | 62| ••••••••••••••••••••••••••••••••••,•HTTP_HOST=b'example.com'
- | 63| •••••••••••••••••••••••••••••••••••)
- | 64|
- | 65| ••••••••assert•response.code•==•200
- tests/py/test_hooks.py
- | 71| ••••••••response•=•self.client.GxT(•'/alice/public.json'
- | 72| ••••••••••••••••••••••••••••••••••,•HTTP_AUTHORIZATION=auth_header
- | 73| ••••••••••••••••••••••••••••••••••,•HTTP_X_FORWARDED_PROTO=b'https'
- | 74| ••••••••••••••••••••••••••••••••••,•HTTP_HOST=b'example.com'
- | 75| •••••••••••••••••••••••••••••••••••)
- | 76| ••••••••assert•response.code•==•401
- | 77|
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_email.py
- | 112| ••••••••self.hit_email_spt('add-email',•'alice@example.com')
- | 113| ••••••••nonce•=•self.alice.get_email('alice@example.com').nonce
- tests/py/test_email.py
- | 122| ••••••••self.hit_email_spt('add-email',•'alice@example.com')
- | 123| ••••••••nonce•=•self.alice.get_email('alice@example.com').nonce
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_email.py
- | 192| ••••••••self.verify_and_change_email('alice@example.com',•'alice@example.net')
- | 193| ••••••••self.verify_and_change_email('alice@example.net',•'alice@example.org')
- | 194| ••••••••self.hit_email_spt('set-primary',•'alice@example.com')
- tests/py/test_email.py
- | 206| ••••••••self.verify_and_change_email('alice@example.com',•'alice@example.net')
- | 207| ••••••••self.verify_and_change_email('alice@example.net',•'alice@example.org')
- | 208| ••••••••self.hit_email_spt('remove',•'alice@example.net')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 42| ••••def•test_close_page_is_usually_available(self):
- | 43| ••••••••alice•=•self.make_participant('alice')
- | 44| ••••••••body•=•self.client.GET('/alice/settings/close',•auth_as=alice).text
- tests/py/test_pages.py
- | 158| ••••def•test_new_participant_can_edit_profile(self):
- | 159| ••••••••alice•=•self.make_participant('alice')
- | 160| ••••••••body•=•self.client.GET("/alice/",•auth_as=alice).text
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 80| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 81| ••••••••with•self.db.get_cursor()•as•cursor:
- | 82| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 83| ••••••••assert•Participant.from_username('bob').balance•==•D('6.00')
- tests/py/test_close.py
- | 105| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 106| ••••••••with•self.db.get_cursor()•as•cursor:
- | 107| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 108| ••••••••assert•Participant.from_id(bob.id).balance•==•D('10.00')
- tests/py/test_close.py
- | 142| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | 143| ••••••••with•self.db.get_cursor()•as•cursor:
- | 144| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 145| ••••••••assert•self.db.one("SELECT•count(*)•FROM•tips")•==•2
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 90| ••••••••carl•=•self.make_stub()
- | 91| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 92| ••••••••alice.set_tip_to(carl,•D('2.00'))
- tests/py/test_close.py
- | 103| ••••••••carl•=•self.make_stub()
- | 104| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 105| ••••••••alice.set_tip_to(carl,•D('2.00'))
- tests/py/test_close.py
- | 128| ••••••••carl•=•self.make_participant('carl')
- | 129| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 130| ••••••••alice.set_tip_to(carl,•D('6.00'))
- tests/py/test_close.py
- | 140| ••••••••carl•=•self.make_participant('carl')
- | 141| ••••••••alice.set_tip_to(bob,•D('3.00'))
- | 142| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_close.py
- | 117| ••••••••alice.set_tip_to(carl,•D('2.00'))
- | 118| ••••••••with•self.db.get_cursor()•as•cursor:
- | 119| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 120| ••••••••assert•self.db.one("SELECT•count(*)•FROM•tips•WHERE•tippee=%s",•(bob.id,))•==•1
- tests/py/test_close.py
- | 130| ••••••••alice.set_tip_to(carl,•D('6.00'))
- | 131| ••••••••with•self.db.get_cursor()•as•cursor:
- | 132| ••••••••••••alice.distribute_balance_as_final_gift(cursor)
- | 133| ••••••••assert•Participant.from_username('bob').balance•==•D('3.33')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_public_json.py
- | 20| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 21| ••••••••assert•data['giving']•==•'1.00'
- tests/py/test_public_json.py
- | 41| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 42|
- tests/py/test_public_json.py
- | 52| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 53| ••••••••assert•data['goal']•==•None
- tests/py/test_public_json.py
- | 57| ••••••••data•=•json.loads(self.client.GET('/alice/public.json').body)
- | 58| ••••••••assert•data['goal']•==•'1.00'
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 284| ••••••••a_team.set_take_for(alice,•D('1.00'),•alice)
- | 285| ••••••••bob•=•self.make_participant('bob')
- tests/py/test_billing_payday.py
- | 318| ••••••••team.set_take_for(alice,•D('1.00'),•alice)
- | 319| ••••••••bob•=•self.make_participant('bob')
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 286| ••••••••a_team.set_take_for(bob,•D('0.01'),•bob)
- | 287| ••••••••charlie•=•self.make_participant('charlie',•balance=1000)
- | 288| ••••••••charlie.set_tip_to(a_team,•D('1.01'))
- tests/py/test_billing_payday.py
- | 320| ••••••••team.set_take_for(bob,•D('1.00'),•bob)
- | 321| ••••••••charlie•=•self.make_participant('charlie',•balance=1000)
- | 322| ••••••••charlie.set_tip_to(team,•D('0.26'))
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- tests/py/test_billing_payday.py
- | 318| ••••••••team.set_take_for(alice,•D('1.00'),•alice)
- | 319| ••••••••bob•=•self.make_participant('bob')
- | 320| ••••••••team.set_take_for(bob,•D('1.00'),•bob)
- tests/py/test_billing_payday.py
- | 344| ••••••••team.set_take_for(alice,•D('0.79'),•alice)
- | 345| ••••••••bob•=•self.make_participant('bob')
- | 346| ••••••••team.set_take_for(bob,•D('0.21'),•bob)
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- Executing section js-analysis...
- js/mangopay.js
- | 468| ••••••••_ajax:•function(settings)•{
- | | [NORMAL] JSComplexityBear:
- | | _ajax has a cyclomatic complexity of 10.
- js/iban.js
- | 158| ••••••••return•this._regex().exec(iban.slice(4)).slice(1).join(separator);
- | 159| ••••};
- | 160|
- | 161| ••••/**
- | 162| •••••*•Convert•the•passed•BBAN•to•an•IBAN•for•this•country•specification.
- | 163| •••••*•Please•note•that•<i>"generation•of•the•IBAN•shall•be•the•exclusive•responsibility•of•the•bank/branch•servicing•the•account"</i>.
- | 164| •••••*•This•method•implements•the•preferred•algorithm•described•in•http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
- | 165| •••••*
- js/iban.js
- | 341| ••••••••return•countryStructure.toBBAN(iban,•separator);
- | 342| ••••};
- | 343|
- | 344| ••••/**
- | 345| •••••*•Convert•the•passed•BBAN•to•an•IBAN•for•this•country•specification.
- | 346| •••••*•Please•note•that•<i>"generation•of•the•IBAN•shall•be•the•exclusive•responsibility•of•the•bank/branch•servicing•the•account"</i>.
- | 347| •••••*•This•method•implements•the•preferred•algorithm•described•in•http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
- | 348| •••••*
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
- js/mangopay.js
- | 512| ••••••••••••••••xmlhttp.open(settings.type,•url,•true);
- | 513| ••••••••••••}•catch•(e)•{
- | 514| ••••••••••••••••if•(settings.crossDomain)
- | 515| ••••••••••••••••••••return•settings.error({ResultCode:•"1000000",•ResultMessage:•"CORS_FAIL"});
- | 516| ••••••••••••••••else
- | 517| ••••••••••••••••••••return•settings.error({ResultCode:•"1000001",•ResultMessage:•"XHR_FAIL"});
- js/mangopay.js
- | 527| ••••••••••••••••xmlhttp.send(settings.type•===•"post"•?•parameters•:•null);
- | 528| ••••••••••••}•catch•(e)•{
- | 529| ••••••••••••••••if•(settings.crossDomain)
- | 530| ••••••••••••••••••••return•settings.error({ResultCode:•"1000000",•ResultMessage:•"CORS_FAIL"});
- | 531| ••••••••••••••••else
- | 532| ••••••••••••••••••••return•settings.error({ResultCode:•"1000001",•ResultMessage:•"XHR_FAIL"});
- | | [NORMAL] CPDBear:
- | | Duplicate code found.
Add Comment
Please, Sign In to add comment