Пример #1
0
    def test_acquire_hut(self):
        """Unittest to verify the hut occupant after it is acquired.

        Unit test ensure that when hut is 'acquired', the `hut.occupant` the
        `hut.occupant` is updated to the `Knight` instance.
        """
        hut = Hut(4, None)
        hut.acquire(self.knight)
        self.assertIs(hut.occupant, self.knight)
Пример #2
0
    def test_acquire_hut(self):
        """Unit test to ensure that when hut is 'acquired'

        The test asserts if the hut.occupant is updated to the Knight instance.
        """
        print("\nCalling test_wargame.test_acquire_hut..")
        hut = Hut(4, None)
        hut.acquire(self.knight)
        self.assertIs(hut.occupant, self.knight)
Пример #3
0
    def test_acquire_hut(self):
        """Unittest to verify hut occupant after it is acquired

        Unit test to ensure that when hut is 'acquired', the
        `hut.occupant` is updated to the `Knight` instance.
        """
        print("\nCalling test_hut.test_acquire_hut..")
        hut = Hut(4, None)
        hut.acquire(self.knight)
        self.assertIs(hut.occupant, self.knight)
Пример #4
0
    def test_acquire_hut(self):
        """
        Unittest to veryfie hut occupant after it is acquired

        Unit test to ensure that when hut is acquired, the
        hut.occupant is updated to the Knight instance
        """
        print("\n Calling test_hut.test_acquire_hut")
        hut = Hut(4, None)
        hut.acquire(self.knight)
        self.assertIs(hut.occupant, self.knight)
Пример #5
0
    def test_acquired_hut(self):
        """Jedinični test za provjeru okupanta kućice nakon što je osvojena.

        Jedinični test koji osigurava da u slučaju kada je kućica `acquired`, instanca `htu.occupant`
        jest instanca od `Knight`
        """

        print('\nPozivamo test za kućicu ...')
        hut = Hut(4, None)
        hut.acquire(self.knight)
        self.assertIs(hut.occupant, self.knight)
Пример #6
0
 def _occupy_huts(self, n=5):
     occupants = ['friend', 'enemy', None]
     for i in range(n):
         computer_choose = random.choice(occupants)
         if computer_choose == 'friend':
             name = 'friend' + str(i + 1)
             self.huts.append(Hut(i + 1, Knight(name)))
         elif computer_choose == 'enemy':
             name = 'enemy' + str(i + 1)
             self.huts.append(Hut(i + 1, OrcRider(name)))
         else:
             self.huts.append(Hut(i + 1, computer_choose))
Пример #7
0
 def _occupy_huts(self):
     """Randomly occupy the huts with one of: friend, enemy or 'None'"""
     for i in range(5):
         choice_lst = ['enemy', 'friend', None]
         computer_choice = random.choice(choice_lst)
         if computer_choice == 'enemy':
             name = 'enemy-' + str(i + 1)
             self.huts.append(Hut(i + 1, OrcRider(name)))
         elif computer_choice == 'friend':
             name = 'knight-' + str(i + 1)
             self.huts.append(Hut(i + 1, Knight(name)))
         else:
             self.huts.append(Hut(i + 1, computer_choice))
Пример #8
0
 def occupy_huts(self):
     occupants = ['enemy', 'friend', None]  # 木屋占有人的类型
     # Randomly append 'enemy' or 'friend' or None to the huts list
     for i in range(5):
         computer_choice  = random.choice(occupants)
         if computer_choice == 'enemy':
             name  = 'enemy-' + str(i+1)
             self.huts.append(Hut(i+1, OrcRider(name)))
         elif computer_choice == 'friend':
             name = 'friend-' + str(i+1)
             self.huts.append(Hut(i+1, Knight(name)))
         else:
             self.huts.append(Hut(i+1, computer_choice))
Пример #9
0
 def _occupy_huts(self):
     """Metoda koja koristi random funkciju za nastambu kucica s prijatelj, neprijatelj ili 'None'"""
     for i in range(5):
         choice_lst = ['neprijatelj', 'prijatelj', None]
         computer_choice = random.choice(choice_lst)
         if computer_choice == 'neprijatelj':
             name = 'neprijatelj-' + str(i + 1)
             self.huts.append(Hut(i + 1, OrcRider(name)))
         elif computer_choice == 'prijatelj':
             name = 'vitez-' + str(i + 1)
             self.huts.append(Hut(i + 1, Knight(name)))
         else:
             self.huts.append(Hut(i + 1, computer_choice))
Пример #10
0
    def _occupy_huts(self):
        print_bold('发现{}座木屋!'.format(self.hut_number))
        """Randomly occupy the hut with one of : friend, enemy or None"""
        for i in range(self.hut_number):
            choice_list = ['敌人', '朋友', None]
            computer_choice = random.choice(choice_list)

            # 根据计算机随机选择木屋里是敌人、队友或是空的
            if computer_choice == '敌人':
                name = '敌人-' + str(i + 1)
                self.huts.append(Hut(i + 1, OrcRider(name)))
            elif computer_choice == '朋友':
                name = '骑士-' + str(i + 1)
                self.huts.append(Hut(i + 1, Knight(name)))
            else:
                self.huts.append(Hut(i + 1, computer_choice))
Пример #11
0
    def _occupy_huts(self):
        """Randomly occupy the huts with one of the options (friend, enemy or 'None')

        .. todo::
            Here we assume there are exactly 5 huts. As an exercise, make it a user
            input. Note that after such change, the unit test is expected to fail!
        """
        choice_lst = ['friend', 'enemy', None]
        for i in range(5):
            computer_choice = random.choice(choice_lst)
            if computer_choice == 'enemy':
                name = 'enemy-' + str(i + 1)
                self.huts.append(Hut(i + 1, OrcRider(name)))
            elif computer_choice == 'friend':
                name = 'knight-' + str(i + 1)
                self.huts.append(Hut(i + 1, Knight(name)))
            else:
                self.huts.append(Hut(i + 1, computer_choice))
Пример #12
0
def main(myhut_info, smtp_info, plan):
    global HUT, CRAWLER_SMTP, SCHEDULER

    HUT = Hut(myhut_info['username'], myhut_info['password'])
    CRAWLER_SMTP = smtp.Server(smtp_info['server'], smtp_info['port'],
                               smtp_info['username'], smtp_info['password'],
                               smtp_info['name'], smtp_info['email'])

    member_info_update()

    # job = {
    #   "club": "Braga",
    #   "class": "V-CLASS CYCLING",
    #   "day_of_week": "wed",
    #   "time": "10:30"
    # }
    # book_class(job)
    # return

    SCHEDULER = BlockingScheduler()
    SCHEDULER.add_job(member_info_update, trigger='cron', hour=0, minute=0)

    for job in plan:
        start_date = dates.parse(job['time'], TIME_FORMAT)
        book_date = dates.sub(start_date, hours=10)
        if book_date < MIDNIGHT:
            book_date = dates.dup(MIDNIGHT)

        # day_of_week = mon,tue,wed,thu,fri,sat,sun
        SCHEDULER.add_job(book_class,
                          args=[job],
                          trigger='cron',
                          day_of_week=job['day_of_week'],
                          hour=book_date.hour,
                          minute=book_date.minute)

    SCHEDULER.start()
Пример #13
0
 def test_acquire_hut(self):
     """Unittest to veryfy hut occupation after it is acquired"""
     print("\n Calling test_hut.test_acquire_hut..")
     hut = Hut(4, None)
     hut.acquire(self.knight)
     self.assertIs(hut.occupant, self.knight)
Пример #14
0
 def test_acquire_hut(self):
     """ unit test to verify the hut occupant after it is acquired """
     # verify that when hut is acquired by a Knight, the 'hut.occupant' is updated to the Knight instance.
     hut = Hut(2, None)
     hut.acquire(self.knight)
     self.assertIs(self.knight, hut.occupant)