Ejemplo n.º 1
0
    def test_run_in_thread(self, glancesync):
        """
        Check run_in_thread method works properly

        :param glancesync: Request mock decorator.
        :return: Nothing
        """
        user1 = User(region='Spain',  name='*****@*****.**', task_id='1234', role='fake role', status=Task.SYNCING)
        db.session.add(user1)
        db.session.commit()

        controller.run_in_thread("Spain", user1)

        us = User.query.filter(User.task_id == user1.task_id).one()
        self.assertEquals(us.status, Task.SYNCED)
Ejemplo n.º 2
0
    def test_run_in_threadFail(self, glancesync, sync_region):
        """
        Check run_in_thread method when there is a section synchronizing the region.

        :param m: Request mock decorator.
        :return: Nothing
        """
        sync_region.side_effect = Exception('Boom!')

        user1 = User(region='Spain',  name='*****@*****.**', task_id='1234', role='fake role', status=Task.SYNCING)
        db.session.add(user1)
        db.session.commit()

        controller.run_in_thread("Spain", user1)

        us = User.query.filter(User.task_id == user1.task_id).one()
        self.assertEquals(us.status, Task.FAILED)
Ejemplo n.º 3
0
    def test_run_in_thread(self, glancesync):
        """
        Check run_in_thread method works properly

        :param glancesync: Request mock decorator.
        :return: Nothing
        """
        user1 = User(region='Spain',
                     name='*****@*****.**',
                     task_id='1234',
                     role='fake role',
                     status=Task.SYNCING)
        db.session.add(user1)
        db.session.commit()

        controller.run_in_thread("Spain", user1)

        us = User.query.filter(User.task_id == user1.task_id).one()
        self.assertEquals(us.status, Task.SYNCED)
Ejemplo n.º 4
0
    def test_run_in_threadFail(self, glancesync, sync_region):
        """
        Check run_in_thread method when there is a section synchronizing the region.

        :param m: Request mock decorator.
        :return: Nothing
        """
        sync_region.side_effect = Exception('Boom!')

        user1 = User(region='Spain',
                     name='*****@*****.**',
                     task_id='1234',
                     role='fake role',
                     status=Task.SYNCING)
        db.session.add(user1)
        db.session.commit()

        controller.run_in_thread("Spain", user1)

        us = User.query.filter(User.task_id == user1.task_id).one()
        self.assertEquals(us.status, Task.FAILED)