Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
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.
Exemplo n.º 10
0
 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()
Exemplo n.º 11
0
 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')
Exemplo n.º 12
0
 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')
Exemplo n.º 13
0
 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()
Exemplo n.º 14
0
 def test_exisitng(self, id):
     '''
     Test that an exisitng license can be found
     '''
     assert license.find(id).id == id
Exemplo n.º 15
0
 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')
Exemplo n.º 16
0
 def from_dict(cls, d):
     return cls(
         DataProvider.from_dict(d['sharedby']),
         datetime.date.fromisoformat(d['accessdate']),
         license.find(d['license'])
     )
Exemplo n.º 17
0
 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')
Exemplo n.º 18
0
 def test_exisitng(self, id):
     '''
     Test that an exisitng license can be found
     '''
     assert license.find(id).id == id