Exemplo n.º 1
0
 def setUp(self):
     activity_repository = repository(ActivityValidator)
     self.__activity_service = ActivityService(activity_repository)
     person_repository = repository(PersonValidator)
     self.__person_service = PersonService(person_repository,
                                           activity_repository)
     statistics = Statistics(activity_repository, person_repository,
                             self.__activity_service, self.__person_service)
     self.__stats = statistics
Exemplo n.º 2
0
def appstart():
    '''
        The brains of the application
        Creating a repository and controller and launching the application
    '''

    tests().testEverything()

    new_repository = repository()
    new_controller = controller(new_repository)

    new_quiz_repository = quizrepository()
    new_quiz_controller = quizcontroller(new_quiz_repository)

    user_interface = ui(new_controller, new_quiz_controller)

    user_interface.launch()
Exemplo n.º 3
0
 def test_repo(self):
     repo = repository(PersonValidator)
     prs = Person(0, "n1", "0747191247", "a1")
     repo.save(prs)
     all = repo.find_all()
     self.assertEqual(len(all), 1)
     prs1 = repo.find_by_id(0)
     self.assertEqual(prs1.name, "n1")
     repo.delete_by_id(0)
     all = repo.find_all()
     self.assertEqual(len(all), 0)
     id = repo.current_id()
     self.assertEqual(id, 0)
     prs = Person(0, "n1", "0747191247", "b1")
     repo.update(prs)
     all = repo.find_all()
     self.assertEqual(all[0].address, "b1")
Exemplo n.º 4
0
    def testAdd(self):

        new_repository = repository()
        new_controller = controller(new_repository)

        new_quiz_repository = quizrepository()
        new_quiz_controller = quizcontroller(new_quiz_repository)

        user_interface = ui(new_controller, new_quiz_controller)

        assert user_interface.add(
            [], 'command') == "Please insert valid 'command' attributes!"
        assert user_interface.add(['1', 'a;2;1;2;1;2;1'],
                                  'command') == "Invalid 'a' id!"
        assert user_interface.add(['1', '1;2;1;2;3;4;1'],
                                  'command') == "Invalid correct answer!"
        assert user_interface.add(['1', '1;2;1;2;3;3;1'],
                                  'command') == "Invalid difficulty!"
Exemplo n.º 5
0
    def testCreate(self):

        new_repository = repository()
        new_controller = controller(new_repository)

        new_quiz_repository = quizrepository()
        new_quiz_controller = quizcontroller(new_quiz_repository)

        user_interface = ui(new_controller, new_quiz_controller)

        assert user_interface.create(
            [], 'command') == "Please insert valid 'command' attributes!"
        assert user_interface.create(['1', '2', '3', '4'],
                                     'command') == "Invalid difficulty!"
        assert user_interface.create(
            ['1', 'easy', 'asdf', '4'],
            'command') == "Invalid 'asdf' number of questions!"
        assert user_interface.create(
            ['1', 'easy', '3', '4'],
            'command') == "Invalid file name or structure!"
 def updateLocation(self, serialId, coordinates, datetime):
     rep = repository(self.endpoint, self.key, self.containerid,
                      self.databasename)
     rep.updateLocation(serialId, coordinates, datetime)
Exemplo n.º 7
0
import traceback
import datetime
import unittest

from Domain.validators import ActivityValidator, PersonValidator
from Repository.Pickle import ActivityPickleRepo, PersonPickleRepo
from Repository.repository import repository, Statistics, prs_file_repo, acts_file_repo
from Service.activity_service import ActivityService
from Service.person_service import PersonService
from UI.Console import Console
try:
    file = open("settings.properties.txt", "r")
    line = file.readline().strip().split("=")
    okay = 0
    if line[1].strip() == "inmemory":
        person_repository = repository(PersonValidator)
        activity_repository = repository(ActivityValidator)
        okay = 1
    elif line[1].strip() == "textfiles":
        #okay = 1
        line1 = file.readline().strip().split("=")
        line1[1] = line1[1].strip()[1:len(line1[1]) - 2]
        person_repository = prs_file_repo(line1[1].strip(), PersonValidator)
        line2 = file.readline().strip().split("=")
        line2[1] = line2[1].strip()[1:len(line2[1]) - 2]
        activity_repository = acts_file_repo(line2[1].strip(),
                                             ActivityValidator)
    else:
        #okay = 1
        line1 = file.readline().strip().split("=")
        line1[1] = line1[1].strip()[1:len(line1[1]) - 2]