Beispiel #1
0
def addCase(caseName, caseDescription):
    conn = sqlite3.connect(DATABASE)
    conn.execute('pragma foreign_keys=ON')
    q = conn.execute('SELECT ID FROM CASES WHERE NAME == ?',(caseName,))
    exists = q.fetchone()
    conn.close()
    if exists:
        return ("<strong>Error!</strong> Case with this name already exists.", "danger")
    Case.addCase(caseName, caseDescription)
    return ("<strong>Success!</strong> Case was successfully added.", "success")
Beispiel #2
0
def loadCase(caseName):
    cases = Case.loadFromDB(DATABASE, mode = 'dic')
    if(caseName in cases):
        case = cases[caseName]
        return case
Beispiel #3
0
def loadCases():
    return Case.loadFromDB(DATABASE)
Beispiel #4
0
 def __init__(self, x, y):
     """
         Creates an empty world with primitive cases
     """
     self.world = [[Case(0) for a in range(x)] for b in range(y)]
Beispiel #5
0
 def to_openfoam_case(self, make2d_parameters=None):
     """Return a BF case for this wind tunnel."""
     return Case.from_wind_tunnel(self, make2d_parameters)
Beispiel #6
0
def __init__(self, protocol):
    Case.__init__(self, protocol)
Beispiel #7
0
        'conc_NO'  : conc_NO * np.ones([xdim, ydim, zdim]),
        'conc_O3'  : conc_O3 * np.ones([xdim, ydim, zdim]),
        'conc_HNO3': conc_HNO3 * np.ones([xdim, ydim, zdim]),
        'conc_HO'  : conc_HO * np.ones([xdim, ydim, zdim])}

init['conc_NO2'][xdim//2][ydim//2][zdim//2] = 30 * 2.5e19/1e9
init['conc_NO'][xdim//2][ydim//2][zdim//2] = 30 * 2.5e19/1e9

emis = {'conc_NO2' : 0 * np.ones([xdim, ydim, zdim]),
        'conc_NO'  : 0 * np.ones([xdim, ydim, zdim]),
        'conc_O3'  : 0 * np.ones([xdim, ydim, zdim]),
        'conc_HNO3': 0 * np.ones([xdim, ydim, zdim]),
        'conc_HO'  : 0 * np.ones([xdim, ydim, zdim])}

simple_bc = {   'conc_NO2' : make_uniform_bc(conc_NO2),
                'conc_NO'  : make_uniform_bc(conc_NO),
                'conc_O3'  : make_uniform_bc(conc_O3),
                'conc_HNO3': make_uniform_bc(conc_HNO3),
                'conc_HO'  : make_uniform_bc(conc_HO)}

no_vd = {   'conc_NO2' : 0,
            'conc_NO'  : 0,
            'conc_O3'  : 0,
            'conc_HNO3': 0,
            'conc_HO'  : 0}

case = Case( bc = simple_bc, initial = init,
            emis = emis, depVel = no_vd, ss_bool = steady_state_bool, ss_func = steady_state_func, fx = fixed )

GLOB_case_dict['NOxTest'] = case;
Beispiel #8
0
 def toOpenFOAMCase(self):
     """Return a BF case for this wind tunnel."""
     return Case.fromWindTunnel(self)
Beispiel #9
0
 def case(self):
     return Case(self.url, self.user_name, self.password)
Beispiel #10
0
from json.decoder import JSONDecodeError
from case import Case
import unittest


class TestParseSteps(unittest.TestCase):

    def test_valid_steps(self):
        case = Case()
        steps = ["{'type': 'ACTION', 'description': 'navigate to /auth'}",
                 "{'type': 'ASSERTION', 'description': 'username and password fields exist'}",
                 "{'type': 'ACTION', 'description': 'type correct username into username field and correct password into password field'}",
                 "{'type': 'ACTION', 'description': 'Press Login button'}",
                 "{'type': 'ASSERTION', 'description': 'should be successfully logged in'}"]
        steps_dict = case.parse_steps(steps)
        self.assertIsInstance(steps_dict[0], dict, f"Expected {type(steps_dict[0])} to be type dict")

    def test_invalid_steps(self):
        case = Case()
        invalid_steps = ["{'type':: 'ACTION', 'description': 'navigate to /auth'}",
                 "{'type': 'ASSERTION', 'description': 'username and password fields exist'}",
                 "{'type': 'ACTION', 'description': 'type correct username into username field and correct password into password field'}",
                 "{'type': 'ACTION', 'description': 'Press Login button'}",
                 "{'type': 'ASSERTION', 'description': 'should be successfully logged in'}"]
        self.assertRaises(JSONDecodeError, case.parse_steps, invalid_steps)
from .case import Case
from .operator import Operator
from .switch import Switch

__all__ = ("switch", "case", "default", "_")
__version__ = "1.5"

switch = Switch()
case = lambda x: Case(x)  # noqa: E731
default = Case(lambda x: True)
_ = Operator()
from contextlib import contextmanager
from datetime import datetime, timedelta
from pickle import dumps, loads

from case import Case, Mock, skip

from celery.five import items
from celery.schedules import (
    ParseException,
    crontab,
    crontab_parser,
    schedule,
    solar,
)

assertions = Case('__init__')


@contextmanager
def patch_crontab_nowfun(cls, retval):
    prev_nowfun = cls.nowfun
    cls.nowfun = lambda: retval
    try:
        yield
    finally:
        cls.nowfun = prev_nowfun


@skip.unless_module('ephem')
class test_solar:
    def setup(self):
Beispiel #13
0
length = len(legal_relas) - 1

distances = []

for i in range(0, length):
    relation = legal_relas[i]
    decision = decisions[i]

    corr_legal = re.search(r'\d', relation)
    corr_decis = re.search(r'\d', decision)

    legal_relas[i] = int(corr_legal.group())
    decisions[i] = int(corr_decis.group())

# MARK:- create list objects

cases = []

for i in range(0, length):
    case = Case(ids[i], legal_relas[i], plaintiff_ages[i], defendant_ages[i],
                decisions[i])
    cases.append(case)

# MARK:- write to file
file = open("cases.arff", "w")

for case in cases:
    file.write(case.toString())

file.close()
Beispiel #14
0
def loadCases():
    return Case.loadFromDB(DATABASE)