How to use set_done method in autotest

Best Python code snippet using autotest_python

test_models.py

Source:test_models.py Github

copy

Full Screen

...36 def test_done_reminder_in_done_query_set(self, mock_schedule_archival):37 """Marks a reminder done and checks that it's in the query sets of done and current but not later tasks."""38 self.assertFalse(self.reminder in Task.objects.done())39 self.assertTrue(self.reminder in Task.objects.later())40 self.reminder.set_done(True)41 mock_schedule_archival.assert_called_once()42 self.assertTrue(self.reminder in Task.objects.done())43 self.assertFalse(self.reminder in Task.objects.later())44 @patch('tasks.models.schedule_archival')45 def test_done_routine_in_done_query_set(self, mock_schedule_archival):46 """Marks a routine done and checks that it's in the query sets of done and current but not later tasks."""47 self.assertFalse(self.routine in Task.objects.done())48 self.assertTrue(self.routine in Task.objects.later())49 self.routine.set_done(True)50 mock_schedule_archival.assert_called_once()51 self.assertTrue(self.routine in Task.objects.done())52 # Note that archival has not happened as this point, so task should still be current.53 self.assertFalse(self.routine in Task.objects.later())54 @patch('tasks.models.schedule_archival')55 def test_done_reminder_and_routine_in_done_query_set(self, mock_schedule_archival):56 """Marks a reminder and a routine done and checks that both are in the query set of done tasks."""57 self.assertFalse(self.reminder in Task.objects.done())58 self.assertFalse(self.routine in Task.objects.done())59 self.reminder.set_done(True)60 mock_schedule_archival.assert_called_once()61 self.routine.set_done(True)62 mock_schedule_archival.assert_called_once()63 self.assertTrue(self.reminder in Task.objects.done())64 self.assertFalse(self.reminder in Task.objects.later())65 self.assertTrue(self.routine in Task.objects.done())66 self.assertFalse(self.routine in Task.objects.later())67 @patch('tasks.models.schedule_archival')68 def test_done_reminder_in_done_query_set_before_and_after_archival(self, mock_schedule_archival):69 """Checks that a done reminder is in the query set of done tasks before and after archival."""70 self.assertFalse(self.reminder in Task.objects.done())71 self.reminder.set_done(True)72 mock_schedule_archival.assert_called_once()73 self.assertTrue(self.reminder in Task.objects.done())74 archive_tasks.apply(args=[self.user.pk])75 self.assertTrue(self.reminder in Task.objects.done())76 @patch('tasks.models.schedule_archival')77 def test_done_routine_not_in_done_query_set_after_archival(self, mock_schedule_archival):78 """Checks that a done routine is in the query set of done tasks before archival and not after."""79 self.assertFalse(self.routine in Task.objects.done())80 self.routine.set_done(True)81 mock_schedule_archival.assert_called_once()82 self.assertTrue(self.routine in Task.objects.done())83 archive_tasks.apply(args=[self.user.pk])84 self.assertFalse(self.routine in Task.objects.done())85 @patch('tasks.models.schedule_archival')86 def test_done_reminder_not_in_later_query_set_before_or_after_archival(self, mock_schedule_archival):87 """Checks that a done reminder is not in the query set of later tasks before or after archival."""88 self.assertTrue(self.reminder in Task.objects.later())89 self.reminder.set_done(True)90 mock_schedule_archival.assert_called_once()91 self.assertFalse(self.reminder in Task.objects.later())92 archive_tasks.apply(args=[self.user.pk])93 self.assertFalse(self.reminder in Task.objects.later())94 @patch('tasks.models.schedule_archival')95 def test_done_routine_in_later_query_set_after_archival(self, mock_schedule_archival):96 """Checks that a done routine is in the query set of later tasks after archival and not before."""97 self.assertTrue(self.routine in Task.objects.later())98 self.routine.set_done(True)99 mock_schedule_archival.assert_called_once()100 self.assertFalse(self.routine in Task.objects.later())101 archive_tasks.apply(args=[self.user.pk])102 self.assertTrue(self.routine in Task.objects.later())103 @patch('tasks.models.schedule_archival')104 def test_done_reminder_never_in_done_query_set_after_archival(self, mock_schedule_archival):105 """Checks that a reminder can never return to the set of current done tasks after archival."""106 self.assertFalse(self.reminder.id in Task.objects.done_task_ids())107 self.reminder.set_done(True)108 mock_schedule_archival.assert_called_once()109 self.assertTrue(str(self.reminder.id) in Task.objects.done_task_ids())110 archive_tasks.apply(args=[self.user.pk])111 self.assertFalse(str(self.reminder.id) in Task.objects.done_task_ids())112 self.reminder.set_done(True)113 self.assertFalse(str(self.reminder.id) in Task.objects.current_task_ids())114 self.assertFalse(str(self.reminder.id) in Task.objects.done_task_ids())115@override_settings(116 REDIS_POOL = redis.ConnectionPool(**settings.TEST_REDIS_CONF)117)118class TaskTest(TestCase):119 def setUp(self):120 self.user = get_user_model().objects.create_user(email='test@test.com', name='test', password='test')121 self.reminder = self.user.tasks.create(title='Reminder')122 self.routine = self.user.tasks.create(title='Routine', is_routine=True)123 def tearDown(self):124 redis.StrictRedis(connection_pool=settings.REDIS_POOL).flushdb()125 def test_set_task_current(self):126 """Marks a task as current and checks that it's current."""127 self.assertFalse(self.reminder.is_current())128 self.reminder.set_current(True)129 self.assertTrue(self.reminder.is_current())130 def test_set_current_task_not_current(self):131 """Marks a current task as not current and checks that it's not current."""132 self.reminder.set_current(True)133 self.assertTrue(self.reminder.is_current())134 self.reminder.set_current(False)135 self.assertFalse(self.reminder.is_current())136 @patch('tasks.models.schedule_archival')137 def test_set_task_done(self, mock_schedule_archival):138 """Marks a task as done and checks that it's done and current."""139 self.assertFalse(self.reminder.is_done())140 self.reminder.set_done(True)141 mock_schedule_archival.assert_called_once()142 self.assertTrue(self.reminder.is_done())143 self.assertTrue(self.reminder.is_current())144 @patch('tasks.models.schedule_archival')145 def test_set_done_task_not_done(self, mock_schedule_archival):146 """Marks a done task as not done and checks that it's not done and still current."""147 self.reminder.set_done(True)148 mock_schedule_archival.assert_called_once()149 self.assertTrue(self.reminder.is_done())150 self.assertTrue(self.reminder.is_current())151 self.reminder.set_done(False)152 self.assertFalse(self.reminder.is_done())153 self.assertTrue(self.reminder.is_current())154 @patch('tasks.models.schedule_archival')155 def test_get_task_done_time(self, mock_schedule_archival):156 """Checks that the done time of the task is the current time, both in UTC and accurate to the minute."""157 self.assertFalse(self.reminder.is_done())158 self.reminder.set_done(True)159 mock_schedule_archival.assert_called_once()160 self.assertTrue(self.reminder.is_done())161 self.assertEqual(162 self.reminder.done_time().replace(second=0, microsecond=0),163 timezone.utc.localize(datetime.utcnow()).replace(second=0, microsecond=0)164 )165 @patch('tasks.models.schedule_archival')166 def test_task_is_current_before_and_not_after_archival(self, mock_schedule_archival):167 """Checks that a done task is current before archival and not after."""168 self.assertFalse(self.reminder.is_current())169 self.reminder.set_done(True)170 mock_schedule_archival.assert_called_once()171 self.assertTrue(self.reminder.is_current())172 archive_tasks.apply(args=[self.user.pk])173 print redis.StrictRedis(connection_pool=settings.REDIS_POOL).hvals('user#{user_id}'.format(user_id=self.user.pk))174 self.assertFalse(self.reminder.is_current())175 @patch('tasks.models.schedule_archival')176 def test_reminder_is_done_before_and_after_archival(self, mock_schedule_archival):177 """Checks that a done reminder is done before and after archival."""178 self.assertFalse(self.reminder.is_done())179 self.reminder.set_done(True)180 mock_schedule_archival.assert_called_once()181 self.assertTrue(self.reminder.is_done())182 archive_tasks.apply(args=[self.user.pk])183 self.assertTrue(self.reminder.is_done())184 @patch('tasks.models.schedule_archival')185 def test_routine_is_done_before_and_not_after_archival(self, mock_schedule_archival):186 """Checks that a done routine is done before archival and not after."""187 self.assertFalse(self.routine.is_done())188 self.routine.set_done(True)189 mock_schedule_archival.assert_called_once()190 self.assertTrue(self.routine.is_done())191 archive_tasks.apply(args=[self.user.pk])192 self.assertFalse(self.routine.is_done())193 @patch('tasks.models.schedule_archival')194 def test_reminder_is_never_current_after_archival(self, mock_schedule_archival):195 """Checks that a reminder can never be set current after archival."""196 self.assertFalse(self.reminder.is_done())197 self.reminder.set_done(True)198 mock_schedule_archival.assert_called_once()199 self.assertTrue(self.reminder.is_done())200 archive_tasks.apply(args=[self.user.pk])201 self.assertTrue(self.reminder.is_done())202 self.reminder.set_current(True)203 self.assertFalse(self.reminder.is_current())204 self.reminder.set_done(True)205 self.assertFalse(self.reminder.is_current())206 @patch('tasks.models.schedule_archival')207 def test_set_reminder_not_done_after_archival(self, mock_schedule_archival):208 """Marks an archived reminder not done and checks that it reverts to a not current, not done task."""209 self.assertFalse(self.reminder.is_done())210 self.reminder.set_done(True)211 mock_schedule_archival.assert_called_once()212 self.assertTrue(self.reminder.is_done())213 archive_tasks.apply(args=[self.user.pk])214 self.assertTrue(self.reminder.is_done())215 self.reminder.set_done(False)216 self.assertFalse(self.reminder.is_current())217 self.assertFalse(self.reminder.is_done())218 @patch('tasks.models.schedule_archival')219 def test_set_routine_current_after_archival(self, mock_schedule_archival):220 """Checks that a routine can be marked current after archival."""221 self.assertFalse(self.routine.is_done())222 self.routine.set_done(True)223 mock_schedule_archival.assert_called_once()224 self.assertTrue(self.routine.is_done())225 archive_tasks.apply(args=[self.user.pk])226 self.assertFalse(self.routine.is_done())227 self.routine.set_current(True)228 self.assertTrue(self.routine.is_current())229 @patch('tasks.models.schedule_archival')230 def test_set_routine_done_after_archival(self, mock_schedule_archival):231 """Checks that a routine can be marked done after archival."""232 self.assertFalse(self.routine.is_done())233 self.routine.set_done(True)234 mock_schedule_archival.assert_called_once()235 self.assertTrue(self.routine.is_done())236 archive_tasks.apply(args=[self.user.pk])237 self.assertFalse(self.routine.is_done())238 self.routine.set_done(True)239 self.assertTrue(self.routine.is_current())240 self.assertTrue(self.routine.is_done())241@override_settings(242 REDIS_POOL = redis.ConnectionPool(**settings.TEST_REDIS_CONF)243)244class HistoryTest(TestCase):245 def setUp(self):246 self.user = get_user_model().objects.create_user(email='test@test.com', name='test', password='test')247 self.reminder = self.user.tasks.create(title='Reminder')248 self.routine = self.user.tasks.create(title='Routine', is_routine=True)249 @patch('tasks.models.schedule_archival')250 def test_history_exists_after_task_archival(self, mock_schedule_archival):251 """Checks that a history entry is created when a task is archived."""252 self.reminder.set_done(True)253 mock_schedule_archival.assert_called_once()254 archive_tasks.apply(args=[self.user.pk])255 self.assertEqual(self.reminder.history.count(), 1)256 @patch('tasks.models.schedule_archival')257 def test_reminder_done_time_is_history_done_time(self, mock_schedule_archival):258 """Checks that the done time for a reminder returns the done time of its history."""259 self.reminder.set_done(True)260 mock_schedule_archival.assert_called_once()261 archive_tasks.apply(args=[self.user.pk])262 self.assertEqual(self.reminder.done_time(), self.reminder.history.all()[0].done_time)263 @patch('tasks.models.schedule_archival')264 def test_routine_done_time_is_latest_history_done_time(self, mock_schedule_archival):265 """Checks that the done time for a routine returns the done time of its latest history."""266 self.routine.set_done(True)267 mock_schedule_archival.assert_called_once()268 archive_tasks.apply(args=[self.user.pk])269 self.assertEqual(self.routine.done_time(), self.routine.history.all()[0].done_time)270 @patch('tasks.models.schedule_archival')271 def test_set_done_reminder_not_done_removes_history(self, mock_schedule_archival):272 """Marks a reminder as done and then not done and checks that it no longer has a history."""273 self.reminder.set_done(True)274 mock_schedule_archival.assert_called_once()275 archive_tasks.apply(args=[self.user.pk])276 self.reminder.set_done(False)277 self.assertEqual(self.reminder.history.count(), 0)278 @patch('tasks.models.schedule_archival')279 def test_single_history_entry_for_reminder(self, mock_schedule_archival):280 """Archives a reminder and checks that marking it done and archiving again does not create new history.281 282 Marks the other task done as well to ensure the archival occurs. Assuming correct behavior, marking \283 the reminder done after archival will not schedule another archival.284 """285 self.reminder.set_done(True)286 mock_schedule_archival.assert_called_once()287 archive_tasks.apply(args=[self.user.pk])288 self.reminder.set_done(True)289 self.routine.set_done(True)290 mock_schedule_archival.assert_called_once()291 archive_tasks.apply(args=[self.user.pk])292 self.assertEqual(self.reminder.history.count(), 1)293 @patch('tasks.models.schedule_archival')294 def test_multiple_history_entries_for_routine(self, mock_schedule_archival):295 """Archives a routine and checks that marking it done and archiving it again creates a new history entry."""296 self.routine.set_done(True)297 mock_schedule_archival.assert_called_once()298 archive_tasks.apply(args=[self.user.pk])299 self.assertEqual(self.routine.history.count(), 1)300 self.routine.set_done(True)301 mock_schedule_archival.assert_called_once()302 archive_tasks.apply(args=[self.user.pk])...

Full Screen

Full Screen

plukrgballigngoal_0.py

Source:plukrgballigngoal_0.py Github

copy

Full Screen

...9 def implementation_init(self):10 self.nao = self.body.nao(0)11 self.seen_angle = -99912 self.start_time = time.time()13 def set_done(self):14 self.m.add_item('last_done',time.time(),{})15 def implementation_update(self):16 print("We zijn bij alligngoal aangekomen")17 print(time.time())18 print(self.start_time)19 if (time.time() > self.start_time + 5):20 print("TimeTimeTime")21 #self.set_done()22 #return23 # als we hier aankomen, dan is er de volgende situatie:24 # het doel is in ons blikveld: waar we naar kijken25 # de bal ligt (vlak?) voor ons26 # we moeten de bal tussen ons en het doel krijgen27 seen = self.nao.waar_goal()28 if (seen != None and self.seen_angle == -999):29 print("Ja, hij is hier gekomen")30 (yaw,pitch) = self.nao.get_yaw_pitch() # yaw is horizontaal draaien, van 120 (links) tot -120 (rechts)31 self.seen_angle = yaw32 else:33 if (abs(self.seen_angle) < 20): # dit is nog ongeveer binnen het huidige blikveld34 print("allign goal: I am now alligned to the goal")35 self.set_done()36 elif (self.seen_angle > 0):37 # toen ik de bal zag, was die links van mij38 print("allign goal: The goal is to my left.")39 self.nao.walk(0,0.15,0)40 self.nao.walk(0.15,0,0)41 self.nao.walk(0,0,math.radians(-90))42 self.set_done()43 elif (self.seen_angle < 0):44 # toen ik de bal zag, was die rechts van mij45 print("allign goal: The goal is to my right.")46 self.nao.walk(0,-0.15,0)47 self.nao.walk(0.15,0,0)48 self.nao.walk(0,0,math.radians(90))49 self.set_done()50 else:...

Full Screen

Full Screen

joint_position_manual.py

Source:joint_position_manual.py Github

copy

Full Screen

...12 if c in ['\x1b', '\x03']:13 done = True14 rospy.signal_shutdown("Finished.")15 16 def set_done(angles):17 _done = True18 cur_angles = limb.joint_angles()19 if abs(cur_angles[joints[6]] - angles[joints[6]]) > 0.1:20 _done = False21 return _done22 angles = limb.joint_angles()23 angles[joints[6]] = 0 24 while not set_done(angles):25 limb.set_joint_positions(angles)26 angles[joints[6]] = 3.1427 while not set_done(angles):28 limb.set_joint_positions(angles)29 angles[joints[6]] = 030 while not set_done(angles):31 limb.set_joint_positions(angles)32 done = True33 34if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful