def test_register_and_find(self): ''' Test that License classes can be registered with id ''' class FooLicense(base.License): id = 'FOO' license.register(FooLicense) assert license.find('FOO') == FooLicense
def test_header(self, id): ''' Test that License classes with header render it ''' email = '*****@*****.**' header = license.find(id).header(name='Petr Foo', email=email) assert email in header assert str(date.today().year) in header assert 'This program is free software' in header
def test_render(self, name): ''' Test that License classes can render it's files ''' email = '*****@*****.**' text = license.find('MIT').render(name=name, email=email) assert name in text assert email in text assert str(date.today().year) in text assert 'Permission is hereby granted' in text
def test_register_find_custom_license(self): ''' Test that custom license can be registered and found ''' try: license.register(self.custom_cls) assert license.find('CUSTOM') == self.custom_cls finally: # unregister, just in case try: del license.core._db['CUSTOM'] except: pass
import os import threading import logging import sched import time import flask from flask import Flask, render_template, request, redirect, url_for import pyttsx3 import license mit = license.find("MIT") from functions import create_alarm, bbc_news, announcements_alarm, notifications_covid app = Flask(__name__) logging.basicConfig(filename="alarm.log", filemode="w", format="%(name)s - %(levelname)s - %(message)s") # The global variables that we need, returning lists of values. covid_list = [] list_of_alarms = [] @app.route("/create", methods=["GET", "POST"]) def handle_data(): """ Upon submitting a alarm form request, this function applies and validates the necessary data in order to create an adequate alarm with conditions specified by user.
def test_header_no_template(self): ''' Test that License classes without header templates raise AttributeError during .header() ''' with pytest.raises(AttributeError): header = license.find('MIT').header()
def test_render_undefined(self): ''' Test that License classes will fail to render without all variables defined ''' with pytest.raises(jinja2.UndefinedError): license.find('MIT').render(name='xx')
def test_exisitng(self, id): ''' Test that an exisitng license can be found ''' assert license.find(id).id == id
def test_nonexisting(self): ''' Test that non-existing license cannot be found ''' with pytest.raises(KeyError): license.find('This is not an existing SPDX identifier')
def from_dict(cls, d): return cls( DataProvider.from_dict(d['sharedby']), datetime.date.fromisoformat(d['accessdate']), license.find(d['license']) )