ocf / ocflib

Python libraries for account and server management
https://pypi.python.org/pypi/ocflib
Other
15 stars 32 forks source link

Fix date-dependent testcases #44

Open kpengboy opened 7 years ago

kpengboy commented 7 years ago

Some testcases in tests/printing/quota_tests.py don't work properly on the first day of each semester.

IRC discussion:

<jvperrin-slack> Any idea why printing quotas aren't changing at all?
<jvperrin-slack> Seems like it's related to it being a new year, but I can't see why that would matter
<jvperrin-slack> Ah, I think I found it
<jvperrin-slack> It's a greater when there should be a greater than or equal to
<jvperrin-slack> https://github.com/ocf/ocflib/blob/master/ocflib/printing/ocfprinting.sql#L85
<kochira> Web Page Title: ocflib/ocfprinting.sql at master · ocf/ocflib · GitHub
<jvperrin-slack> and https://github.com/ocf/ocflib/blob/master/ocflib/printing/ocfprinting.sql#L92
<kochira> Web Page Title: ocflib/ocfprinting.sql at master · ocf/ocflib · GitHub
<jvperrin-slack> So that means nothing done on the first day of the year (or approximately the first of August) has any effect on quotas lol
<jvperrin-slack> Unofficial free printing days :P
<jvperrin-slack> This really doesn't work when yesterday is in a different year lol: https://github.com/ocf/ocflib/blob/master/tests/printing/quota_test.py#L181
<kochira> Web Page Title: ocflib/quota_test.py at master · ocf/ocflib · GitHub
<jvperrin-slack> This is great
<ckuehl> lol these are my favorite kind of test failures
<kpengboy> Do we need the test to test today or can we just fix a date
<jvperrin-slack> Uh, it can probably just fix a date?
<jvperrin-slack> The issue with fixing a date is that it uses the database table that still uses the actual date for the current day's quota, so that doesn't exactly work
<ckuehl> yea our other tests use freezegun for that
<ckuehl> but not sure how you'd do that given these actually reach out to a mysql
<ckuehl> at least one of the tests also fails if it hits midnight in the middle of the test
<ckuehl> lol
<jvperrin-slack> Yup, I was thinking about that one too
<jvperrin-slack> Hmm :/
<jvperrin-slack> Well only 45 minutes left to fix it :P
<ckuehl> lol yea
<ckuehl> it's a true "wait for it to fix itself" bug
<jvperrin-slack> It'll break again someday in August though
<jvperrin-slack> And if the day changes in the middle of a test I suppose
<jvperrin-slack> Not sure how you really make this a reproducible test though, fake the time in mysql or something?
<jvperrin-slack> Hmm: http://dba.stackexchange.com/questions/81305/how-do-i-unit-test-queries-which-are-based-on-dates-from-now
<kochira> Web Page Title: mysql - How do I unit test queries which are based on dates from now? - Database Administrators Stack Exchange