diff --git a/students/aaron/lesson06/assignment/data/exercise.csv b/students/aaron/lesson06/assignment/data/exercise.csv new file mode 100755 index 0000000..38ea4a8 --- /dev/null +++ b/students/aaron/lesson06/assignment/data/exercise.csv @@ -0,0 +1,10 @@ +seq, guid, seq, seq, ccnumber, date, sentence +1,06fe5141-da4b-5c58-9883-3f39136908c7,1,1,6011220731845325,05/11/1982,Mu jug deewito acotutwap disi rusun fikfadfuz woabibab rugijugah egegetvu ama torpefik hiuzi wek cakotne apucu wutboftiw cikdosvo. +2,5150a0ff-ce1f-52f2-ab34-8a7cae869af3,2,2,6011640776177732,06/11/1948,Miriguuro pi uwgi gaev dot ma inuvi fecemado zi kipjuc fain amifa matmam ow bakim. +3,32956473-9b8f-5e24-b69f-87ec0eb66836,3,3,201485000768549,12/01/2064,Ofolo dosal junos ne tekkuzvaz siga ubifanula jedat virtawzib ibipaseju baweg ulvaf uk vib dirvotu ubhe utospup etku. +4,382042bb-b23e-5671-9345-c19e9b04f543,4,4,6011741283125501,01/21/1942,Jej ce fif vecceg igazuba or sitos peni if enoz nauta iba. +5,e9f9ede7-934f-5b4f-aa4d-1b2821b5cc9f,5,5,4026074029741607,07/25/2035,Gelucgi wi up zolro mifjet tahoti lakiwozu awodeg repta lahwe mewdif fosoc rudurit ada. +6,43e8ff8c-9bee-5e9c-b0a4-ff3135921114,6,6,201449918655776,07/08/2042,Sitono fa li gi colkeasi ce terhazef orreb ha tuikawa ocuguc fiza ruda cueh zamraguf wudafica dujjor rujcohca. +7,187c20d2-a1d0-5601-8c63-2e64f3929d69,7,7,5018862501514733,10/03/1952,Ralutozu misidor elzir pehmatkuk lagmon za dip sufzuc gecwi miwimbi pejoja ca ve ozeli. +8,a8be3615-9225-522b-9e7e-82d8670b48e6,8,8,345621524909394,05/15/2015,Tufemi pejif tostal roopha bid vet muhooz ciwguwal kicfugnuz iteva ale ci akulij vanhoklu nohameozi pubosoz wotpatven. +9,9fd239f2-d300-5fa3-a8a4-94a1a93ea798,9,9,6264530923933190,07/21/1901,Feego ekzefe kuma pitzu zulome itrosza cimna gotwul vur remo ej finande hora. diff --git a/students/aaron/lesson06/assignment/good_perf.log b/students/aaron/lesson06/assignment/good_perf.log new file mode 100644 index 0000000..45e5ea0 --- /dev/null +++ b/students/aaron/lesson06/assignment/good_perf.log @@ -0,0 +1,154 @@ +{'2013': 0, '2014': 0, '2015': 1, '2016': 0, '2017': 0, '2018': 0} +'ao' was found 0 times + 1606 function calls (1589 primitive calls) in 0.004 seconds + + Ordered by: standard name + + ncalls tottime percall cumtime percall filename:lineno(function) + 6 0.000 0.000 0.000 0.000 :1009(_handle_fromlist) + 5 0.000 0.000 0.000 0.000 :103(release) + 5 0.000 0.000 0.000 0.000 :143(__init__) + 5 0.000 0.000 0.000 0.000 :147(__enter__) + 5 0.000 0.000 0.000 0.000 :151(__exit__) + 5 0.000 0.000 0.000 0.000 :157(_get_module_lock) + 5 0.000 0.000 0.000 0.000 :176(cb) + 8/2 0.000 0.000 0.002 0.001 :211(_call_with_frames_removed) + 91 0.000 0.000 0.000 0.000 :222(_verbose_message) + 5 0.000 0.000 0.000 0.000 :307(__init__) + 5 0.000 0.000 0.000 0.000 :311(__enter__) + 5 0.000 0.000 0.000 0.000 :318(__exit__) + 20 0.000 0.000 0.000 0.000 :321() + 2 0.000 0.000 0.000 0.000 :35(_new_module) + 5 0.000 0.000 0.000 0.000 :369(__init__) + 7 0.000 0.000 0.000 0.000 :403(cached) + 5 0.000 0.000 0.000 0.000 :416(parent) + 5 0.000 0.000 0.000 0.000 :424(has_location) + 5 0.000 0.000 0.000 0.000 :504(_init_module_attrs) + 5 0.000 0.000 0.001 0.000 :576(module_from_spec) + 5 0.000 0.000 0.000 0.000 :58(__init__) + 5/2 0.000 0.000 0.004 0.002 :663(_load_unlocked) + 5 0.000 0.000 0.000 0.000 :719(find_spec) + 5 0.000 0.000 0.000 0.000 :78(acquire) + 5 0.000 0.000 0.000 0.000 :792(find_spec) + 15 0.000 0.000 0.000 0.000 :855(__enter__) + 15 0.000 0.000 0.000 0.000 :859(__exit__) + 5 0.000 0.000 0.001 0.000 :882(_find_spec) + 5/2 0.000 0.000 0.004 0.002 :948(_find_and_load_unlocked) + 5/2 0.000 0.000 0.004 0.002 :978(_find_and_load) + 3 0.000 0.000 0.000 0.000 :1029(__init__) + 3 0.000 0.000 0.001 0.000 :1040(create_module) + 3 0.000 0.000 0.000 0.000 :1048(exec_module) + 1 0.000 0.000 0.000 0.000 :1190(_path_hooks) + 23 0.000 0.000 0.000 0.000 :1203(_path_importer_cache) + 5 0.000 0.000 0.001 0.000 :1240(_get_spec) + 5 0.000 0.000 0.001 0.000 :1272(find_spec) + 1 0.000 0.000 0.000 0.000 :1319(__init__) + 8 0.000 0.000 0.000 0.000 :1325() + 5 0.000 0.000 0.000 0.000 :1351(_get_spec) + 18 0.000 0.000 0.001 0.000 :1356(find_spec) + 1 0.000 0.000 0.000 0.000 :1404(_fill_cache) + 1 0.000 0.000 0.000 0.000 :1433() + 1 0.000 0.000 0.000 0.000 :1445(path_hook_for_FileFinder) + 4 0.000 0.000 0.000 0.000 :271(cache_from_source) + 18 0.000 0.000 0.000 0.000 :36(_relax_case) + 5 0.000 0.000 0.000 0.000 :369(_get_cached) + 2 0.000 0.000 0.000 0.000 :401(_check_name_wrapper) + 2 0.000 0.000 0.000 0.000 :438(_classify_pyc) + 2 0.000 0.000 0.000 0.000 :471(_validate_timestamp_pyc) + 6 0.000 0.000 0.000 0.000 :51(_r_long) + 2 0.000 0.000 0.001 0.000 :523(_compile_bytecode) + 80 0.000 0.000 0.000 0.000 :56(_path_join) + 5 0.000 0.000 0.000 0.000 :574(spec_from_file_location) + 80 0.000 0.000 0.000 0.000 :58() + 4 0.000 0.000 0.000 0.000 :62(_path_split) + 2 0.000 0.000 0.000 0.000 :719(create_module) + 2 0.000 0.000 0.003 0.002 :722(exec_module) + 26 0.000 0.000 0.000 0.000 :74(_path_stat) + 2 0.000 0.000 0.001 0.000 :793(get_code) + 6 0.000 0.000 0.000 0.000 :84(_path_is_mode_type) + 2 0.000 0.000 0.000 0.000 :884(__init__) + 2 0.000 0.000 0.000 0.000 :909(get_filename) + 2 0.000 0.000 0.000 0.000 :914(get_data) + 5 0.000 0.000 0.000 0.000 :93(_path_isfile) + 2 0.000 0.000 0.000 0.000 :951(path_stats) + 1 0.000 0.000 0.000 0.000 :98(_path_isdir) + 1 0.000 0.000 0.000 0.000 _bootlocale.py:33(getpreferredencoding) + 1 0.000 0.000 0.000 0.000 codecs.py:260(__init__) + 1 0.000 0.000 0.000 0.000 codecs.py:309(__init__) + 2 0.000 0.000 0.000 0.000 codecs.py:319(decode) + 1 0.000 0.000 0.000 0.000 csv.py:131(DictWriter) + 1 0.000 0.000 0.000 0.000 csv.py:166(Sniffer) + 1 0.000 0.000 0.000 0.000 csv.py:24(Dialect) + 1 0.000 0.000 0.001 0.001 csv.py:4() + 1 0.000 0.000 0.000 0.000 csv.py:55(excel) + 1 0.000 0.000 0.000 0.000 csv.py:65(excel_tab) + 1 0.000 0.000 0.000 0.000 csv.py:70(unix_dialect) + 1 0.000 0.000 0.000 0.000 csv.py:81(DictReader) + 1 0.000 0.000 0.000 0.000 datetime.py:1092(tzinfo) + 1 0.000 0.000 0.000 0.000 datetime.py:1162(time) + 2 0.000 0.000 0.000 0.000 datetime.py:1187(__new__) + 1 0.000 0.000 0.000 0.000 datetime.py:1509(datetime) + 3 0.000 0.000 0.000 0.000 datetime.py:1517(__new__) + 1 0.000 0.000 0.000 0.000 datetime.py:2136(timezone) + 3 0.000 0.000 0.000 0.000 datetime.py:2156(_create) + 35 0.000 0.000 0.000 0.000 datetime.py:379(_check_int_field) + 5 0.000 0.000 0.000 0.000 datetime.py:396(_check_date_fields) + 5 0.000 0.000 0.000 0.000 datetime.py:409(_check_time_fields) + 3 0.000 0.000 0.000 0.000 datetime.py:41(_days_before_year) + 5 0.000 0.000 0.000 0.000 datetime.py:426(_check_tzinfo_arg) + 1 0.000 0.000 0.000 0.000 datetime.py:454(timedelta) + 5 0.000 0.000 0.000 0.000 datetime.py:46(_days_in_month) + 9 0.000 0.000 0.000 0.000 datetime.py:473(__new__) + 1 0.000 0.000 0.002 0.002 datetime.py:5() + 1 0.000 0.000 0.000 0.000 datetime.py:646(__neg__) + 1 0.000 0.000 0.000 0.000 datetime.py:774(date) + 2 0.000 0.000 0.000 0.000 datetime.py:804(__new__) + 1 0.000 0.000 0.004 0.004 good_perf.py:4() + 1 0.000 0.000 0.000 0.000 good_perf.py:42(main) + 1 0.000 0.000 0.000 0.000 good_perf.py:9(analyze) + 19 0.000 0.000 0.000 0.000 {built-in method __new__ of type object at 0x10e8cd050} + 2 0.000 0.000 0.000 0.000 {built-in method _codecs.utf_8_decode} + 1 0.000 0.000 0.000 0.000 {built-in method _csv.reader} + 3 0.000 0.000 0.000 0.000 {built-in method _csv.register_dialect} + 2 0.000 0.000 0.000 0.000 {built-in method _imp._fix_co_filename} + 25 0.000 0.000 0.000 0.000 {built-in method _imp.acquire_lock} + 3 0.001 0.000 0.001 0.000 {built-in method _imp.create_dynamic} + 3 0.000 0.000 0.000 0.000 {built-in method _imp.exec_dynamic} + 5 0.000 0.000 0.000 0.000 {built-in method _imp.is_builtin} + 5 0.000 0.000 0.000 0.000 {built-in method _imp.is_frozen} + 25 0.000 0.000 0.000 0.000 {built-in method _imp.release_lock} + 1 0.000 0.000 0.000 0.000 {built-in method _locale.nl_langinfo} + 10 0.000 0.000 0.000 0.000 {built-in method _thread.allocate_lock} + 10 0.000 0.000 0.000 0.000 {built-in method _thread.get_ident} + 13 0.000 0.000 0.000 0.000 {built-in method builtins.__build_class__} + 72 0.000 0.000 0.000 0.000 {built-in method builtins.abs} + 5 0.000 0.000 0.000 0.000 {built-in method builtins.any} + 45 0.000 0.000 0.000 0.000 {built-in method builtins.divmod} + 3/1 0.000 0.000 0.004 0.004 {built-in method builtins.exec} + 30 0.000 0.000 0.000 0.000 {built-in method builtins.getattr} + 35 0.000 0.000 0.000 0.000 {built-in method builtins.hasattr} + 184 0.000 0.000 0.000 0.000 {built-in method builtins.isinstance} + 6 0.000 0.000 0.000 0.000 {built-in method builtins.len} + 2 0.000 0.000 0.000 0.000 {built-in method builtins.print} + 9 0.000 0.000 0.000 0.000 {built-in method builtins.round} + 6 0.000 0.000 0.000 0.000 {built-in method from_bytes} + 1 0.000 0.000 0.000 0.000 {built-in method io.open} + 2 0.001 0.000 0.001 0.000 {built-in method marshal.loads} + 2 0.000 0.000 0.000 0.000 {built-in method now} + 9 0.000 0.000 0.000 0.000 {built-in method posix.fspath} + 1 0.000 0.000 0.000 0.000 {built-in method posix.listdir} + 26 0.000 0.000 0.000 0.000 {built-in method posix.stat} + 12 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} + 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} + 8 0.000 0.000 0.000 0.000 {method 'endswith' of 'str' objects} + 3 0.000 0.000 0.000 0.000 {method 'extend' of 'list' objects} + 10 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects} + 84 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects} + 3 0.000 0.000 0.000 0.000 {method 'lower' of 'str' objects} + 2 0.000 0.000 0.000 0.000 {method 'read' of '_io.FileIO' objects} + 36 0.000 0.000 0.000 0.000 {method 'rpartition' of 'str' objects} + 164 0.000 0.000 0.000 0.000 {method 'rstrip' of 'str' objects} + 1 0.000 0.000 0.000 0.000 {method 'setter' of 'property' objects} + 2 0.000 0.000 0.000 0.000 {method 'startswith' of 'str' objects} + + diff --git a/students/aaron/lesson06/assignment/poor_perf.log b/students/aaron/lesson06/assignment/poor_perf.log new file mode 100644 index 0000000..5ceda75 --- /dev/null +++ b/students/aaron/lesson06/assignment/poor_perf.log @@ -0,0 +1,154 @@ +{'2013': 0, '2014': 0, '2015': 1, '2016': 0, '2017': 0, '2018': 0} +'ao' was found 0 times + 1625 function calls (1608 primitive calls) in 0.005 seconds + + Ordered by: standard name + + ncalls tottime percall cumtime percall filename:lineno(function) + 6 0.000 0.000 0.000 0.000 :1009(_handle_fromlist) + 5 0.000 0.000 0.000 0.000 :103(release) + 5 0.000 0.000 0.000 0.000 :143(__init__) + 5 0.000 0.000 0.000 0.000 :147(__enter__) + 5 0.000 0.000 0.000 0.000 :151(__exit__) + 5 0.000 0.000 0.000 0.000 :157(_get_module_lock) + 5 0.000 0.000 0.000 0.000 :176(cb) + 8/2 0.000 0.000 0.003 0.002 :211(_call_with_frames_removed) + 91 0.000 0.000 0.000 0.000 :222(_verbose_message) + 5 0.000 0.000 0.000 0.000 :307(__init__) + 5 0.000 0.000 0.000 0.000 :311(__enter__) + 5 0.000 0.000 0.000 0.000 :318(__exit__) + 20 0.000 0.000 0.000 0.000 :321() + 2 0.000 0.000 0.000 0.000 :35(_new_module) + 5 0.000 0.000 0.000 0.000 :369(__init__) + 7 0.000 0.000 0.000 0.000 :403(cached) + 5 0.000 0.000 0.000 0.000 :416(parent) + 5 0.000 0.000 0.000 0.000 :424(has_location) + 5 0.000 0.000 0.000 0.000 :504(_init_module_attrs) + 5 0.000 0.000 0.002 0.000 :576(module_from_spec) + 5 0.000 0.000 0.000 0.000 :58(__init__) + 5/2 0.000 0.000 0.004 0.002 :663(_load_unlocked) + 5 0.000 0.000 0.000 0.000 :719(find_spec) + 5 0.000 0.000 0.000 0.000 :78(acquire) + 5 0.000 0.000 0.000 0.000 :792(find_spec) + 15 0.000 0.000 0.000 0.000 :855(__enter__) + 15 0.000 0.000 0.000 0.000 :859(__exit__) + 5 0.000 0.000 0.001 0.000 :882(_find_spec) + 5/2 0.000 0.000 0.005 0.002 :948(_find_and_load_unlocked) + 5/2 0.000 0.000 0.005 0.002 :978(_find_and_load) + 3 0.000 0.000 0.000 0.000 :1029(__init__) + 3 0.000 0.000 0.001 0.000 :1040(create_module) + 3 0.000 0.000 0.000 0.000 :1048(exec_module) + 1 0.000 0.000 0.000 0.000 :1190(_path_hooks) + 23 0.000 0.000 0.000 0.000 :1203(_path_importer_cache) + 5 0.000 0.000 0.001 0.000 :1240(_get_spec) + 5 0.000 0.000 0.001 0.000 :1272(find_spec) + 1 0.000 0.000 0.000 0.000 :1319(__init__) + 8 0.000 0.000 0.000 0.000 :1325() + 5 0.000 0.000 0.000 0.000 :1351(_get_spec) + 18 0.000 0.000 0.001 0.000 :1356(find_spec) + 1 0.000 0.000 0.000 0.000 :1404(_fill_cache) + 1 0.000 0.000 0.000 0.000 :1433() + 1 0.000 0.000 0.000 0.000 :1445(path_hook_for_FileFinder) + 4 0.000 0.000 0.000 0.000 :271(cache_from_source) + 18 0.000 0.000 0.000 0.000 :36(_relax_case) + 5 0.000 0.000 0.000 0.000 :369(_get_cached) + 2 0.000 0.000 0.000 0.000 :401(_check_name_wrapper) + 2 0.000 0.000 0.000 0.000 :438(_classify_pyc) + 2 0.000 0.000 0.000 0.000 :471(_validate_timestamp_pyc) + 6 0.000 0.000 0.000 0.000 :51(_r_long) + 2 0.000 0.000 0.001 0.001 :523(_compile_bytecode) + 80 0.000 0.000 0.000 0.000 :56(_path_join) + 5 0.000 0.000 0.000 0.000 :574(spec_from_file_location) + 80 0.000 0.000 0.000 0.000 :58() + 4 0.000 0.000 0.000 0.000 :62(_path_split) + 2 0.000 0.000 0.000 0.000 :719(create_module) + 2 0.000 0.000 0.004 0.002 :722(exec_module) + 26 0.000 0.000 0.000 0.000 :74(_path_stat) + 2 0.000 0.000 0.001 0.001 :793(get_code) + 6 0.000 0.000 0.000 0.000 :84(_path_is_mode_type) + 2 0.000 0.000 0.000 0.000 :884(__init__) + 2 0.000 0.000 0.000 0.000 :909(get_filename) + 2 0.000 0.000 0.000 0.000 :914(get_data) + 5 0.000 0.000 0.000 0.000 :93(_path_isfile) + 2 0.000 0.000 0.000 0.000 :951(path_stats) + 1 0.000 0.000 0.000 0.000 :98(_path_isdir) + 2 0.000 0.000 0.000 0.000 _bootlocale.py:33(getpreferredencoding) + 2 0.000 0.000 0.000 0.000 codecs.py:260(__init__) + 2 0.000 0.000 0.000 0.000 codecs.py:309(__init__) + 4 0.000 0.000 0.000 0.000 codecs.py:319(decode) + 1 0.000 0.000 0.000 0.000 csv.py:131(DictWriter) + 1 0.000 0.000 0.000 0.000 csv.py:166(Sniffer) + 1 0.000 0.000 0.000 0.000 csv.py:24(Dialect) + 1 0.000 0.000 0.001 0.001 csv.py:4() + 1 0.000 0.000 0.000 0.000 csv.py:55(excel) + 1 0.000 0.000 0.000 0.000 csv.py:65(excel_tab) + 1 0.000 0.000 0.000 0.000 csv.py:70(unix_dialect) + 1 0.000 0.000 0.000 0.000 csv.py:81(DictReader) + 1 0.000 0.000 0.000 0.000 datetime.py:1092(tzinfo) + 1 0.000 0.000 0.000 0.000 datetime.py:1162(time) + 2 0.000 0.000 0.000 0.000 datetime.py:1187(__new__) + 1 0.000 0.000 0.000 0.000 datetime.py:1509(datetime) + 3 0.000 0.000 0.000 0.000 datetime.py:1517(__new__) + 1 0.000 0.000 0.000 0.000 datetime.py:2136(timezone) + 3 0.000 0.000 0.000 0.000 datetime.py:2156(_create) + 35 0.000 0.000 0.000 0.000 datetime.py:379(_check_int_field) + 5 0.000 0.000 0.000 0.000 datetime.py:396(_check_date_fields) + 5 0.000 0.000 0.000 0.000 datetime.py:409(_check_time_fields) + 3 0.000 0.000 0.000 0.000 datetime.py:41(_days_before_year) + 5 0.000 0.000 0.000 0.000 datetime.py:426(_check_tzinfo_arg) + 1 0.000 0.000 0.000 0.000 datetime.py:454(timedelta) + 5 0.000 0.000 0.000 0.000 datetime.py:46(_days_in_month) + 9 0.000 0.000 0.000 0.000 datetime.py:473(__new__) + 1 0.000 0.000 0.002 0.002 datetime.py:5() + 1 0.000 0.000 0.000 0.000 datetime.py:646(__neg__) + 1 0.000 0.000 0.000 0.000 datetime.py:774(date) + 2 0.000 0.000 0.000 0.000 datetime.py:804(__new__) + 1 0.000 0.000 0.005 0.005 poor_perf.py:4() + 1 0.000 0.000 0.000 0.000 poor_perf.py:59(main) + 1 0.000 0.000 0.000 0.000 poor_perf.py:9(analyze) + 19 0.000 0.000 0.000 0.000 {built-in method __new__ of type object at 0x10d9ad050} + 4 0.000 0.000 0.000 0.000 {built-in method _codecs.utf_8_decode} + 2 0.000 0.000 0.000 0.000 {built-in method _csv.reader} + 3 0.000 0.000 0.000 0.000 {built-in method _csv.register_dialect} + 2 0.000 0.000 0.000 0.000 {built-in method _imp._fix_co_filename} + 25 0.000 0.000 0.000 0.000 {built-in method _imp.acquire_lock} + 3 0.001 0.000 0.001 0.000 {built-in method _imp.create_dynamic} + 3 0.000 0.000 0.000 0.000 {built-in method _imp.exec_dynamic} + 5 0.000 0.000 0.000 0.000 {built-in method _imp.is_builtin} + 5 0.000 0.000 0.000 0.000 {built-in method _imp.is_frozen} + 25 0.000 0.000 0.000 0.000 {built-in method _imp.release_lock} + 2 0.000 0.000 0.000 0.000 {built-in method _locale.nl_langinfo} + 10 0.000 0.000 0.000 0.000 {built-in method _thread.allocate_lock} + 10 0.000 0.000 0.000 0.000 {built-in method _thread.get_ident} + 13 0.000 0.000 0.000 0.000 {built-in method builtins.__build_class__} + 72 0.000 0.000 0.000 0.000 {built-in method builtins.abs} + 5 0.000 0.000 0.000 0.000 {built-in method builtins.any} + 45 0.000 0.000 0.000 0.000 {built-in method builtins.divmod} + 3/1 0.000 0.000 0.005 0.005 {built-in method builtins.exec} + 30 0.000 0.000 0.000 0.000 {built-in method builtins.getattr} + 35 0.000 0.000 0.000 0.000 {built-in method builtins.hasattr} + 184 0.000 0.000 0.000 0.000 {built-in method builtins.isinstance} + 6 0.000 0.000 0.000 0.000 {built-in method builtins.len} + 2 0.000 0.000 0.000 0.000 {built-in method builtins.print} + 9 0.000 0.000 0.000 0.000 {built-in method builtins.round} + 6 0.000 0.000 0.000 0.000 {built-in method from_bytes} + 2 0.000 0.000 0.000 0.000 {built-in method io.open} + 2 0.001 0.001 0.001 0.001 {built-in method marshal.loads} + 2 0.000 0.000 0.000 0.000 {built-in method now} + 9 0.000 0.000 0.000 0.000 {built-in method posix.fspath} + 1 0.000 0.000 0.000 0.000 {built-in method posix.listdir} + 26 0.000 0.000 0.000 0.000 {built-in method posix.stat} + 21 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} + 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} + 8 0.000 0.000 0.000 0.000 {method 'endswith' of 'str' objects} + 3 0.000 0.000 0.000 0.000 {method 'extend' of 'list' objects} + 10 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects} + 84 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects} + 3 0.000 0.000 0.000 0.000 {method 'lower' of 'str' objects} + 2 0.000 0.000 0.000 0.000 {method 'read' of '_io.FileIO' objects} + 36 0.000 0.000 0.000 0.000 {method 'rpartition' of 'str' objects} + 164 0.000 0.000 0.000 0.000 {method 'rstrip' of 'str' objects} + 1 0.000 0.000 0.000 0.000 {method 'setter' of 'property' objects} + 2 0.000 0.000 0.000 0.000 {method 'startswith' of 'str' objects} + + diff --git a/students/aaron/lesson06/assignment/pylint.log b/students/aaron/lesson06/assignment/pylint.log new file mode 100644 index 0000000..ff8629a --- /dev/null +++ b/students/aaron/lesson06/assignment/pylint.log @@ -0,0 +1,74 @@ + + +Report +====== +27 statements analysed. + +Statistics by type +------------------ + ++---------+-------+-----------+-----------+------------+---------+ +|type |number |old number |difference |%documented |%badname | ++=========+=======+===========+===========+============+=========+ +|module |1 |1 |= |100.00 |0.00 | ++---------+-------+-----------+-----------+------------+---------+ +|class |0 |0 |= |0 |0 | ++---------+-------+-----------+-----------+------------+---------+ +|method |0 |0 |= |0 |0 | ++---------+-------+-----------+-----------+------------+---------+ +|function |2 |2 |= |100.00 |0.00 | ++---------+-------+-----------+-----------+------------+---------+ + + + +Raw metrics +----------- + ++----------+-------+------+---------+-----------+ +|type |number |% |previous |difference | ++==========+=======+======+=========+===========+ +|code |30 |58.82 |30 |= | ++----------+-------+------+---------+-----------+ +|docstring |12 |23.53 |12 |= | ++----------+-------+------+---------+-----------+ +|comment |0 |0.00 |0 |= | ++----------+-------+------+---------+-----------+ +|empty |9 |17.65 |9 |= | ++----------+-------+------+---------+-----------+ + + + +Duplication +----------- + ++-------------------------+------+---------+-----------+ +| |now |previous |difference | ++=========================+======+=========+===========+ +|nb duplicated lines |0 |0 |= | ++-------------------------+------+---------+-----------+ +|percent duplicated lines |0.000 |0.000 |= | ++-------------------------+------+---------+-----------+ + + + +Messages by category +-------------------- + ++-----------+-------+---------+-----------+ +|type |number |previous |difference | ++===========+=======+=========+===========+ +|convention |0 |0 |= | ++-----------+-------+---------+-----------+ +|refactor |0 |0 |= | ++-----------+-------+---------+-----------+ +|warning |0 |0 |= | ++-----------+-------+---------+-----------+ +|error |0 |0 |= | ++-----------+-------+---------+-----------+ + + + + +-------------------------------------------------------------------- +Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00) + diff --git a/students/aaron/lesson06/assignment/pylintrc b/students/aaron/lesson06/assignment/pylintrc new file mode 100644 index 0000000..0d96a23 --- /dev/null +++ b/students/aaron/lesson06/assignment/pylintrc @@ -0,0 +1,236 @@ +[MASTER] + +# Specify a configuration file. +#rcfile= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Profiled execution. +profile=no + +# Add to the black list. It should be a base name, not a +# path. You may set this option multiple times. +ignore=CVS + +# Pickle collected data for later comparisons. +persistent=yes + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + + +[MESSAGES CONTROL] + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time. +#enable= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifier separated by comma (,) or put this option +# multiple time. +disable= too-few-public-methods, too-many-arguments + + +[REPORTS] + +# Set the output format. Available formats are text, parseable, colorized, msvs +# (visual studio) and html +output-format=text + +# Include message's id in output +include-ids=no + +# Put messages in a separate file for each module / package specified on the +# command line instead of printing them on stdout. Reports (if any) will be +# written in a file name "pylint_global.[txt|html]". +files-output=no + +# Tells whether to display a full report or only the messages +reports=yes + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (R0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Add a comment according to your evaluation note. This is used by the global +# evaluation report (R0004). +comment=no + + +[VARIABLES] + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching names used for dummy variables (i.e. not used). +dummy-variables-rgx=_|dummy + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + + +[BASIC] + +# Required attributes for module, separated by a comma +required-attributes= + +# List of builtins function names that should not be used, separated by a comma +bad-functions=map,filter,apply,input + +# Regular expression which should only match correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression which should only match correct module level names +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ + +# Regular expression which should only match correct class names +class-rgx=[A-Z_][a-zA-Z0-9]+$ + +# Regular expression which should only match correct function names +function-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct method names +method-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct instance attribute names +attr-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct argument names +argument-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct variable names +variable-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct list comprehension / +# generator expression variable names +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ + +# Good variable names which should always be accepted, separated by a comma +good-names=i,j,k,ex,Run,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo,bar,baz,toto,tutu,tata + +# Regular expression which should only match functions or classes name which do +# not require a docstring +no-docstring-rgx=__.*__ + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=80 + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + + +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + + +[TYPECHECK] + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# List of classes names for which member attributes should not be checked +# (useful for classes with attributes dynamically set). +ignored-classes=SQLObject + +# When zope mode is activated, add a predefined set of Zope acquired attributes +# to generated-members. +zope=no + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E0201 when accessed. +generated-members=REQUEST,acl_users,aq_parent + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.* + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branchs=12 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + + +[IMPORTS] + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub,string,TERMIOS,Bastion,rexec + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + + +[CLASSES] + +# List of interface methods to ignore, separated by a comma. This is used for +# instance to not check methods defines in Zope's Interface base class. +ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp diff --git a/students/aaron/lesson06/assignment/pytest.log b/students/aaron/lesson06/assignment/pytest.log new file mode 100644 index 0000000..b9cbdf8 --- /dev/null +++ b/students/aaron/lesson06/assignment/pytest.log @@ -0,0 +1,16 @@ +$ python3 -m pytest -svvv tests/test_perf.py > pytest.log +============================= test session starts ============================== +platform darwin -- Python 3.7.2, pytest-4.3.0, py-1.7.0, pluggy-0.8.1 -- /usr/local/opt/python/bin/python3.7 +cachedir: .pytest_cache +rootdir: /Users/adevey/class/Python220A_2019/students/aaron/lesson06/assignment, inifile: +collecting ... collected 1 item + +tests/test_perf.py::test_assess_preformance {'2013': 20360, '2014': 20247, '2015': 20228, '2016': 20367, '2017': 20076, '2018': 20210} +'ao' was found 609102 times +{'2013': 20360, '2014': 20247, '2015': 20228, '2016': 20367, '2017': 20076, '2018': 20210} +'ao' was found 609102 times +Poor elapsed: 0:00:07.883165 +Good elapsed: 0:00:03.833491 +PASSED + +========================== 1 passed in 11.82 seconds =========================== diff --git a/students/aaron/lesson06/assignment/src/good_perf.py b/students/aaron/lesson06/assignment/src/good_perf.py new file mode 100755 index 0000000..ca36a26 --- /dev/null +++ b/students/aaron/lesson06/assignment/src/good_perf.py @@ -0,0 +1,77 @@ +""" +great performing, greatly written module + +""" + +import datetime +import random +from faker import Faker +import csv +import os +from string import ascii_lowercase, digits + +def gen_data(filename, entries, regenerate = False): + ''' Generates a ton of random entries and dumps them into filename ''' + if os.path.isfile(filename) and regenerate == False: + # dont regenerate data if the file exists + return + print("Generating data in %s" % filename) + f = open(filename, 'w+') + f.write("seq,guid,seq,seq,ccnumber,date,sequence\n") + fakerer = Faker() + word_list = ["karaoke", "test", "words", "stuff", "apple", "orange", + "fedora", "list", "canary", "slugs", "snails", "flipper", + "sandals", "shoes", "nails", "hammers", "to", "the", "and", + "asdfsadjf", "asdf", "noise", "random", "letters"] + for row in range(entries): + data = "%s,%s,%s,%s,%s,%s,%s\n" % (row, fakerer.uuid4(), row, row, + fakerer.credit_card_number(), + fakerer.date(pattern="%m/%d/%Y"), + fakerer.text(ext_word_list=word_list).replace('\n', ' ').replace(',', ' ')) + f.write(data) + f.close() + print("Generated data.") + + +def analyze(filename): + ''' checks filename for specific years and 'ao' in column 6 ''' + start = datetime.datetime.now() + with open(filename) as csvfile: + reader = csv.reader(csvfile, delimiter=',', quotechar='"') + + year_count = { + "2013": 0, + "2014": 0, + "2015": 0, + "2016": 0, + "2017": 0, + "2018": 0 + } + found = 0 + + for row in reader: + lrow = list(row) + + try: + year = int(lrow[5][6:]) + except ValueError: + continue + if 2012 < year <= 2018: + year_count[str(year)] += 1 + if "ao" in lrow[6]: + found += 1 + + print(year_count) + print(f"'ao' was found {found} times") + end = datetime.datetime.now() + return (start, end, year_count, found) + +def main(): + ''' the main function automatically loads data/generated_data.csv ''' + ''' if the file doesn't exist already ''' + filename = "data/generated_data.csv" + analyze(filename) + + +if __name__ == "__main__": + main() diff --git a/students/aaron/lesson06/assignment/src/poor_perf.py b/students/aaron/lesson06/assignment/src/poor_perf.py new file mode 100755 index 0000000..4a250ed --- /dev/null +++ b/students/aaron/lesson06/assignment/src/poor_perf.py @@ -0,0 +1,65 @@ +""" +poorly performing, poorly written module + +""" + +import datetime +import csv + +def analyze(filename): + start = datetime.datetime.now() + with open(filename) as csvfile: + reader = csv.reader(csvfile, delimiter=',', quotechar='"') + new_ones = [] + for row in reader: + lrow = list(row) + if lrow[5] > '00/00/2012': + new_ones.append((lrow[5], lrow[0])) + + year_count = { + "2013": 0, + "2014": 0, + "2015": 0, + "2016": 0, + "2017": 0, + "2018": 0 + } + + for new in new_ones: + if new[0][6:] == '2013': + year_count["2013"] += 1 + if new[0][6:] == '2014': + year_count["2014"] += 1 + if new[0][6:] == '2015': + year_count["2015"] += 1 + if new[0][6:] == '2016': + year_count["2016"] += 1 + if new[0][6:] == '2017': + year_count["2017"] += 1 + if new[0][6:] == '2018': + year_count["2018"] += 1 + + print(year_count) + + with open(filename) as csvfile: + reader = csv.reader(csvfile, delimiter=',', quotechar='"') + + found = 0 + + for line in reader: + lrow = list(line) + if "ao" in line[6]: + found += 1 + + print(f"'ao' was found {found} times") + end = datetime.datetime.now() + + return (start, end, year_count, found) + +def main(): + filename = "data/generated_data.csv" + analyze(filename) + + +if __name__ == "__main__": + main() diff --git a/students/aaron/lesson06/assignment/tests/test_good_perf.py b/students/aaron/lesson06/assignment/tests/test_good_perf.py new file mode 100755 index 0000000..5efc0fe --- /dev/null +++ b/students/aaron/lesson06/assignment/tests/test_good_perf.py @@ -0,0 +1,3 @@ +""" +run linting only +""" diff --git a/students/aaron/lesson06/assignment/tests/test_perf.py b/students/aaron/lesson06/assignment/tests/test_perf.py new file mode 100755 index 0000000..110d0bb --- /dev/null +++ b/students/aaron/lesson06/assignment/tests/test_perf.py @@ -0,0 +1,20 @@ +""" +check good works the same, and is faster +""" + +import src.poor_perf as p +import src.good_perf as g + + +def test_assess_preformance(): + """ compare """ + g.gen_data('data/generated_data.csv', 1000000) + poor = p.analyze('data/generated_data.csv') + good = g.analyze('data/generated_data.csv') + poor_elapsed = poor[1] - poor[0] + good_elapsed = good[1] - good[0] + print("Poor elapsed: %s" % poor_elapsed) + print("Good elapsed: %s" % good_elapsed) + assert good_elapsed < poor_elapsed + assert poor[2] == good[2] + assert poor[3] == good[3] diff --git a/students/aaron/lesson07/assignment/pylint.log b/students/aaron/lesson07/assignment/pylint.log new file mode 100644 index 0000000..989169a --- /dev/null +++ b/students/aaron/lesson07/assignment/pylint.log @@ -0,0 +1,82 @@ + + +Report +====== +74 statements analysed. + +Statistics by type +------------------ + ++---------+-------+-----------+-----------+------------+---------+ +|type |number |old number |difference |%documented |%badname | ++=========+=======+===========+===========+============+=========+ +|module |1 |1 |= |100.00 |0.00 | ++---------+-------+-----------+-----------+------------+---------+ +|class |0 |0 |= |0 |0 | ++---------+-------+-----------+-----------+------------+---------+ +|method |0 |0 |= |0 |0 | ++---------+-------+-----------+-----------+------------+---------+ +|function |6 |6 |= |100.00 |0.00 | ++---------+-------+-----------+-----------+------------+---------+ + + + +External dependencies +--------------------- +:: + + pymongo (database) + + + +Raw metrics +----------- + ++----------+-------+------+---------+-----------+ +|type |number |% |previous |difference | ++==========+=======+======+=========+===========+ +|code |76 |70.37 |76 |= | ++----------+-------+------+---------+-----------+ +|docstring |7 |6.48 |7 |= | ++----------+-------+------+---------+-----------+ +|comment |10 |9.26 |10 |= | ++----------+-------+------+---------+-----------+ +|empty |15 |13.89 |15 |= | ++----------+-------+------+---------+-----------+ + + + +Duplication +----------- + ++-------------------------+------+---------+-----------+ +| |now |previous |difference | ++=========================+======+=========+===========+ +|nb duplicated lines |0 |0 |= | ++-------------------------+------+---------+-----------+ +|percent duplicated lines |0.000 |0.000 |= | ++-------------------------+------+---------+-----------+ + + + +Messages by category +-------------------- + ++-----------+-------+---------+-----------+ +|type |number |previous |difference | ++===========+=======+=========+===========+ +|convention |0 |0 |= | ++-----------+-------+---------+-----------+ +|refactor |0 |0 |= | ++-----------+-------+---------+-----------+ +|warning |0 |0 |= | ++-----------+-------+---------+-----------+ +|error |0 |0 |= | ++-----------+-------+---------+-----------+ + + + + +-------------------------------------------------------------------- +Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00) + diff --git a/students/aaron/lesson07/assignment/pytest.log b/students/aaron/lesson07/assignment/pytest.log new file mode 100644 index 0000000..6c5a301 --- /dev/null +++ b/students/aaron/lesson07/assignment/pytest.log @@ -0,0 +1,11 @@ +============================= test session starts ============================== +platform darwin -- Python 3.7.2, pytest-4.3.0, py-1.7.0, pluggy-0.8.1 -- /usr/local/opt/python/bin/python3.7 +cachedir: .pytest_cache +rootdir: /Users/adevey/class/Python220A_2019/students/aaron/lesson07/assignment, inifile: +collecting ... collected 3 items + +tests/test_database.py::test_import_data PASSED [ 33%] +tests/test_database.py::test_show_available_products PASSED [ 66%] +tests/test_database.py::test_show_rentals PASSED [100%] + +=========================== 3 passed in 0.35 seconds =========================== diff --git a/students/aaron/lesson07/assignment/src/database.py b/students/aaron/lesson07/assignment/src/database.py new file mode 100755 index 0000000..e00e663 --- /dev/null +++ b/students/aaron/lesson07/assignment/src/database.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +''' Stores and retrieves data from a rentals db ''' + +import os +import threading +import pymongo + +CLIENT = pymongo.MongoClient('localhost', 27017) +DB = CLIENT.data + +def setup_db(database): + ''' sets up the collections and returns them ''' + products = database.products + products.drop() + products.create_index([('product_id', pymongo.ASCENDING)], unique=True) + customers = database.customers + customers.drop() + customers.create_index([('user_id', pymongo.ASCENDING)], unique=True) + rentals = database.rentals + rentals.drop() + return (products, customers, rentals) + +def import_data(dirname, products, customers, rentals): + ''' Imports data from a bunch of csv files located at dirname ''' + prod_rec_errs = import_csv_data(PRODUCTS, os.path.join(dirname, products)) + cust_rec_errs = import_csv_data(CUSTOMERS, os.path.join(dirname, customers)) + rent_rec_errs = import_csv_data(RENTALS, os.path.join(dirname, rentals)) + zipped = list(zip(prod_rec_errs, cust_rec_errs, rent_rec_errs)) + return zipped + +def insert_row(collection, row, successes): + ''' Inserts a row into DB. Returns True on success, else False ''' + try: + collection.insert_one(row) + except pymongo.errors.PyMongoError as err: + print("Failure to write row to db. %s - %s", row, err) + successes.append(False) + return + successes.append(True) + return + +def import_csv_data(collection, path): + ''' Imports csv data from a file, returns (records, failures) ''' + columns = [] + records = 0 + errors = 0 + try: + with open(path, encoding="ISO-8859-1") as fhand: + # retrieve the csv header + columns = fhand.readline().rstrip().split(',') + + # retrieve each row and populate data + rows = [] + for line in fhand: + fields = line.rstrip().split(',') + row = {} + for field in enumerate(fields): + row[columns[field[0]]] = field[1] + rows.append(row) + except Exception as err: + print('Failure to read data from %s: %s', path, err) + raise err + + # could have used a queue here but ran with a list instead + successes = [] + # a list for the thread objects + threads = [] + + # set up a new thread for each row to insert + # (this may be crazy for large datasets) + for row in rows: + threads.append(threading.Thread(target=insert_row, + args=(collection, row, successes))) + + # start all the threads, then wait until they complete + # tried to use a comprehension here, but pylint didn't like it + for thread in threads: + thread.start() + for thread in threads: + thread.join() + + # count the successes and the errors + records = len([success for success in successes if success]) + errors = len([success for success in successes if not success]) + return (records, errors) + +def show_available_products(): + ''' returns all available products (quantity isn't 0) ''' + prods = {} + for product in PRODUCTS.find({'quantity_available': {'$ne': "0"}}): + product_id = product.pop('product_id') + product.pop('_id') + prods[product_id] = product + return prods + +def show_rentals(product_id): + ''' returns all of the customers who rented a product ''' + rents = {} + for rent in RENTALS.find({'product_id': product_id}): + for customer in CUSTOMERS.find({'user_id': rent['user_id']}): + cust_id = customer.pop('user_id') + customer.pop('_id') + rents[cust_id] = customer + return rents + +PRODUCTS, CUSTOMERS, RENTALS = setup_db(DB) diff --git a/students/aaron/lesson07/assignment/tests/data/customers.csv b/students/aaron/lesson07/assignment/tests/data/customers.csv new file mode 100755 index 0000000..a77e7d6 --- /dev/null +++ b/students/aaron/lesson07/assignment/tests/data/customers.csv @@ -0,0 +1,11 @@ +user_id,name,address,zip_code,phone_number,email +user001,Elisa Miles,4490 Union Street,98109,206-922-0882,elisa.miles@yahoo.com +user002,Maya Data,4936 Elliot Avenue,98115,206-777-1927,mdata@uw.edu +user003,Andy Norris,348 Terra Street,98501,206-309-2533,andy.norris@gmail.com +user004,Flor Matatena,885 Boone Crockett Lane,97209,206-414-2629,matseattle@pge.com +user005,Dan Sounders,861 Honeysuckle Lane,98244,206-279-1723,soundersoccer@mls.com +user006,Leo Dembele,2725 Mutton Town Road,98368,206-203-1294,leo.dembele@comcast.com +user007,Pete Nicholas,668 Elliot Avenue,98115,206-279-8759,nicholasp@amazon.com +user008,Shirlene Harris,4329 Honeysuckle Lane,98055,206-279-5340,harrisfamily@gmail.com +user009,Nick Rather,4679 Goodwin Avenue,98619,206-777-1965,nick.rather@microsoft.com +user010,Jose Garza,2717 Raccoon Run,98116,206-946-8200,joegarza@boeing.com diff --git a/students/aaron/lesson07/assignment/tests/data/products.csv b/students/aaron/lesson07/assignment/tests/data/products.csv new file mode 100755 index 0000000..527ca98 --- /dev/null +++ b/students/aaron/lesson07/assignment/tests/data/products.csv @@ -0,0 +1,11 @@ +product_id,description,product_type,quantity_available +prd001,60-inch TV stand,livingroom,3 +prd002,L-shaped sofa,livingroom,0 +prd003,Acacia kitchen table,kitchen,7 +prd004,Queen bed,bedroom,10 +prd005,Reading lamp,bedroom,20 +prd006,Portable heater,bathroom,14 +prd007,Ballerina painting,livingroom,0 +prd008,Smart microwave,kitchen,30 +prd009,Popcorn machine,kitchen,0 +prd010,60-inch TV,livingroom,3 diff --git a/students/aaron/lesson07/assignment/tests/data/rentals.csv b/students/aaron/lesson07/assignment/tests/data/rentals.csv new file mode 100755 index 0000000..668c845 --- /dev/null +++ b/students/aaron/lesson07/assignment/tests/data/rentals.csv @@ -0,0 +1,10 @@ +product_id,user_id +prd003,user004 +prd002,user008 +prd002,user005 +prd005,user001 +prd010,user002 +prd007,user002 +prd006,user003 +prd005,user003 +prd001,user010 diff --git a/students/aaron/lesson07/assignment/tests/test_database.py b/students/aaron/lesson07/assignment/tests/test_database.py new file mode 100755 index 0000000..76ef806 --- /dev/null +++ b/students/aaron/lesson07/assignment/tests/test_database.py @@ -0,0 +1,49 @@ +""" +grade lesson 5 +""" + +import os +import pytest + +import src.database as l + +@pytest.fixture +def _show_available_products(): + return { + 'prd001': {'description': '60-inch TV stand', 'product_type': 'livingroom', 'quantity_available': '3'}, + 'prd003': {'description': 'Acacia kitchen table', 'product_type': 'kitchen', 'quantity_available': '7'}, + 'prd004': {'description': 'Queen bed', 'product_type': 'bedroom', 'quantity_available': '10'}, + 'prd005': {'description': 'Reading lamp', 'product_type': 'bedroom', 'quantity_available': '20'}, + 'prd006': {'description': 'Portable heater', 'product_type': 'bathroom', 'quantity_available': '14'}, + 'prd008': {'description': 'Smart microwave', 'product_type': 'kitchen', 'quantity_available': '30'}, + 'prd010': {'description': '60-inch TV', 'product_type': 'livingroom', 'quantity_available': '3'}} + +@pytest.fixture +def _show_rentals(): + return { + 'user001': {'name': 'Elisa Miles', 'address': '4490 Union Street', 'zip_code': '98109', 'phone_number': '206-922-0882', 'email': 'elisa.miles@yahoo.com'}, + 'user003': {'name': 'Andy Norris', 'address': '348 Terra Street', 'zip_code': '98501', 'phone_number': '206-309-2533', 'email': 'andy.norris@gmail.com'}} + +def test_import_data(): + """ import """ + data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data') + added, errors = l.import_data(data_dir, "products.csv", "customers.csv", "rentals.csv") + + for add in added: + assert isinstance(add, int) + + for error in errors: + assert isinstance(error, int) + + assert added == (10, 10, 9) + assert errors == (0, 0, 0) + +def test_show_available_products(_show_available_products): + """ available products """ + students_response = l.show_available_products() + assert students_response == _show_available_products + +def test_show_rentals(_show_rentals): + """ rentals """ + students_response = l.show_rentals("prd005") + assert students_response == _show_rentals