Esempio n. 1
0
    def test_should_calculate_the_amount_for_every_day_in_the_week_no_matter_the_order(self):
        question = Question(
            'JUAN=MO10:00-12:00,TU10:00-12:00,WE01:00-02:00,TH01:00-03:00,SA14:00-18:00,SU20:00-21:00,FR18:00-00:00')
        answer = Answer(self.payment_configuration, question)

        self.assertEqual('JUAN', answer.name)
        self.assertEqual(360, answer.amount)
Esempio n. 2
0
 def setUpClass(cls, mock_open):
     file_pointer = MagicMock()
     file_pointer.readlines.return_value = ['Monday - Friday\n', '00:01 - 09:00 25 USD\n', '09:01 - 18:00 15 USD\n',
                                            '18:01 - 00:00 20 USD\n', 'Saturday and Sunday\n',
                                            '00:01 - 09:00 30 USD\n', '09:01 - 18:00 20 USD\n',
                                            '18:01 - 00:00 25 USD\n']
     mock_open.return_value = file_pointer
     cls.payment_configuration = ConfigurationFactory.build()
     cls.default_question = Question('ASTRID=MO10:00-12:00,TH12:00-14:00,SU20:00-21:00')
    def test_should_provide_an_answer_for_every_question(self):
        questions = [
            Question('ASTRID=MO10:00-12:00,TH12:00-14:00,SU20:00-21:00')
        ]
        payment_configuration = MagicMock()

        answers_service = AnswersService(payment_configuration, questions)
        answers = answers_service.answer()

        self.assertEqual(len(questions), len(answers))
        self.assertIsInstance(answers[0], Answer)
Esempio n. 4
0
    def _load_questionnaire_data(self, questionnaire_data):
        self.survey_id = questionnaire_data['survey_id']
        self.questionnaire_id = questionnaire_data['questionnaire_id']
        self.title = questionnaire_data['title']
        self.overview = questionnaire_data['overview']
        for index, schema in enumerate(questionnaire_data['questions']):
            question = Question.factory(schema)

            # TODO: Remove this as it breaks encapsulation.  References should be set in the schema instead
            # all questions need references - should really be set by the author
            # but if not lets set them
            if not question._reference:
                question._reference = 'q' + str(index)

            self._add_question(question)
from game import Game
from player.player import Player
from questions import Questions
from questions.question import Question
from gui.gui import Gui


q1 = Question("What sort of animal is Walt Disney's Dumbo?",
              ['Deer', 'Rabbit', 'Elephant', 'Donkey'],
              3)
q2 = Question("In children’s stories, how many wishes are granted by a genie or fairy?",
              ['One', 'Two', 'Three', 'Four'],
              3)
q3 = Question("Which of these is a type of hat?",
              ['Sausage roll', 'Pork pie', 'Scotch egg', 'Potato crisp'],
              2)
q4 = Question("Which of these is not one of the American Triple Crown horse races?",
              [ 'Arlington Million', 'Belmont Stakes', 'Kentucky Derby', 'Preakness Stakes'],
              1)
q5 = Question("Who is the patron saint of Spain?",
              ['St James', 'St John', 'St Benedict', 'St Peter'],
              1)
q6 = Question("The young of which creature is known as a squab?",
              ['Salmon', 'Horse', 'Pigeon', 'Octopus'],
              3)
q7 = Question("In Welsh, what does ‘afon’ mean?",
              ['Fort', 'Meadow', 'Pool', 'River'],
              4)
q8 = Question("Where does a cowboy wear chaps?",
              ['On his head', 'On his arms', 'On his legs', 'On his hands'],
              3)
 def build(input_file=DEFAULT_SOURCE):
     input_file = input_file if input_file else DEFAULT_SOURCE
     my_file = open(input_file, "r")
     questions = [Question(item) for item in my_file.readlines()]
     my_file.close()
     return questions
Esempio n. 7
0
 def test_should_create_a_question_given_a_raw_info(self):
     raw_info = 'RENE=MO10:00-12:00,TU10:00-12:00'
     question = Question(raw_info)
     self.assertEqual(question.name, 'RENE')
     self.assertEqual(len(question.items), 2)
     self.assertIsInstance(question.items[0], QuestionHourItem)
 def _load_children(self, children_schema):
     for index, child in enumerate(children_schema):
         question = Question.factory(child, self)
         if not question._reference:
             question._reference = 'q' + str(index)
         self.children.append(question)
Esempio n. 9
0
    def test_should_calculate_the_amount_to_be_paid_for_time_spans_ending_at_midnight(self):
        question = Question('PEPE=FR18:00-00:00')
        answer = Answer(self.payment_configuration, question)

        self.assertEqual('PEPE', answer.name)
        self.assertEqual(120, answer.amount)
Esempio n. 10
0
    def test_should_calculate_the_amount_to_be_paid_for_time_spans_starting_at_midnight(self):
        question = Question('DIANA=MO08:00-10:00,SA00:00-09:00')
        answer = Answer(self.payment_configuration, question)

        self.assertEqual('DIANA', answer.name)
        self.assertEqual(310.0, answer.amount)
Esempio n. 11
0
    def test_should_calculate_the_amount_to_be_paid(self):
        question = Question('RENE=MO10:00-12:00,TU10:00-12:00,TH01:00-03:00,SA14:00-18:00,SU20:00-21:00')
        answer = Answer(self.payment_configuration, question)

        self.assertEqual('RENE', answer.name)
        self.assertEqual(215.0, answer.amount)