a Eg7 @sddlZddlmmZddlZddlZddlZddl m Z ddl m Z ddl mZe jZddddd dd d d dd dd d ddd dd gediZe dedZddZddZddZddZddZddZdd Zd!d"Zd#d$ZdS)%N)Config) MonthlyStats) assert_truez0000-0002-3722-6351zTest dataset 1ZSPARC) datasetIdnameversionorigin downloadszTest dataset 2zTest dataset 3)datasetsemailT) debug_mode debug_emailcCs:t}tjtjddd|id}t|jdkdS)Nz /datasets AuthorizationzBearer )headers)mspennsieve_loginrequestsgetrPENNSIEVE_API_HOSTr status_code)keyrrC/home/cmiss/Jenkins/workspace/SPARC-API/tests/test_monthly_stats.pytest_pennsieve_login-s  r cCst}tt|dkdSNr)rget_download_metrics_one_monthrlenstatsrrrtest_metrics_endpoint4sr&cCs t}tt|dkdSr!)r get_statsrr#keysr$rrrtest_stats_generation9sr)cCs$tt}tddd|DvdS)NFcSsg|]}|jdkqSr.0rrrr Cztest_email..)r send_stats test_datar responsesrrr test_emailAs r5cCs>g}tjdurt}n tdd}tddd|DvdS)NFcSsg|]}|jdkqSr*r,r-rrrr/Or0z!test_full_run..)r DATABASE_URLrrunmonthly_stats_required_checkrr3rrr test_full_runEs    r9cCsNtjdurtdn4tddd}t|d}tddd|DvdS)NDATABASE not set for this runirFcSsg|]}|jdkqSr*r,r-rrrr/Zr0z&test_next_year_run..) rr6pytestskipdatetimedaterr8rtimeNowr4rrrtest_next_year_runQs    rAcCsHtjdurtdn.tddd}t|d}tt |dkdS)Nr:Fr rr6r;r<r=r>rr8rr#r?rrrtest_same_month_run\s    rFcCsHtjdurtdn.tddd}t|d}tt |dkdS)Nr:rBrFrrEr?rrrtest_earlier_month_runfs    rHcCstd}t|jdkdS)Nztesting log emailr+)rsend_logging_emailrr)responserrrtest_log_emailps rK)builtins @py_builtins_pytest.assertion.rewrite assertionrewrite @pytest_arr=r;r app.configrscripts.monthly_statsr nose.toolsrTESTING_EMAIL_ADDRESSZtest_email_recipientr2rr r&r)r5r9rArFrHrKrrrrsN"