def run_tests(): # Old Django versions requires Django initialisation before we can get the # test runner. setup_django() from django.conf import settings from django.test.utils import get_runner TestRunner = get_runner(settings) test_runner = TestRunner(verbosity=1, interactive=True) failures = test_runner.run_tests(['mail_templated']) sys.exit(bool(failures))
import gspread from django_setup import setup_django import pandas as pd from dateutil.parser import parse from django.core.exceptions import ObjectDoesNotExist setup_django() from envdata.models import Sample, Population def get_data(user, password): gc = gspread.login(user, password) wks = gc.open("pine_sampling").sheet1 data = wks.get_all_records() return pd.DataFrame(data) def get_float(val): try: return float(val) except ValueError as e: return None def get_population(pop_name): try: return Population.objects.get(name=pop_name) except ObjectDoesNotExist as e: p = Population(name=pop_name) p.save() return p def run_import(data):