def setUp(self): User = self.user_model self.user0 = User.objects.create(username='******') self.project = Project.objects.create() self.task1 = Task.objects.create(project=self.project) self.task2 = Task.objects.create(project=self.project) self.task3 = Task.objects.create(project=self.project) actrack.track(self.user0, self.project, actor_only=False) self.log(self.user0, 'created', targets=self.project) self.log(self.user0, 'created', targets=self.task1, related=self.project) self.log(self.user0, 'created', targets=self.task2, related=self.project) self.log(self.user0, 'created', targets=self.task3, related=self.project) self.save_queue()
def test_track(self): # tracking all verbs on project actrack.track(self.user, self.project) trackers = Tracker.objects.all() self.assertEqual(len(trackers), 1) tracker = trackers[0] self.assertEqual(tracker.user, self.user) self.assertEqual(tracker.tracked, self.project) self.assertSetEqual(tracker.verbs, set())
def setUp(self): self.user = self.user_model.objects.create() self.project = Project.objects.create() actrack.track(self.user, Project, verbs='created', actor_only=False, using=self.user._state.db) self.log(self.user, 'created', targets=self.project, commit=True)
def test_track_log(self): # tracking all verbs on project, logging the tracking event actrack.track(self.user, self.project, log=True) self.save_queue() actions = Action.objects.all() self.assertEqual(len(actions), 1) action = actions[0] self.assertEqual(action.actor, self.user) self.assertSetEqual(set(action.targets.all()), {self.project}) self.assertEqual(action.verb, 'started tracking')
def setUp(self): self.user0 = self.user_model.objects.create(username='******') self.user1 = self.user_model.objects.create(username='******') self.project = Project.objects.create() track(self.user0, self.user1, actor_only=True) self.log(self.user1, 'created', targets=self.project) self.log(self.user1, 'validated', targets=self.project) self.save_queue() # wait a little bit before retrieving actions time.sleep(0.01)
def setUp(self): self.user0 = self.user_model.objects.create(username='******') self.user1 = self.user_model.objects.create(username='******') self.project = Project.objects.create(name='project') self.task = Task.objects.create(project=self.project, name='task') track(self.user1, self.project, actor_only=False) track(self.user1, self.task, actor_only=False) self.log(self.user0, 'created', targets=self.task, related=self.project, commit=True) # wait a little bit before retrieving actions time.sleep(0.01)
def test_track_model(self): with warnings.catch_warnings(): warnings.simplefilter("ignore") actrack.track(self.user, Project, verbs='created') tracker = Tracker.objects.all()[0] self.assertEqual(tracker.tracked, Project)
def test_track_verbs(self): # tracking verb 'modified' on project actrack.track(self.user, self.project, verbs='modified') self.assertSetEqual(Tracker.objects.all()[0].verbs, {'modified'})