Ejemplo n.º 1
0
    def test_after_creating_map_a_created_map_action_is_triggered(self):
        a_user = UserFactory.create()
        a_map = MapFactory.create(creator=a_user)

        am = ActivityManager()
        created = am.created_map(a_user)

        self.assertTrue(len(created))
        action = list(created)[0]

        self.assertEqual(action.actor, a_user)
        self.assertEqual(action.target, a_map)
        self.assertEqual(action.verb, CREATED_MAP)
Ejemplo n.º 2
0
    def test_after_deleting_map_a_delete_action_is_triggered(self):
        a_user = UserFactory.create()
        a_map = MapFactory.create(creator=a_user)
        a_map.delete()

        am = ActivityManager()
        deleted = am.deleted_map(a_user)

        self.assertTrue(len(deleted))
        action = deleted[0]

        self.assertEqual(action.actor, a_user)
        # TODO: test that the name of the map is saved in the action
        self.assertEqual(action.verb, DELETED_MAP)
Ejemplo n.º 3
0
    def test_after_deleting_note_a_deleted_note_action_is_triggered(self):
        a_user = UserFactory.create()
        a_map = MapFactory.create(creator=a_user)
        a_note = NoteFactory.create(map=a_map, creator=a_user)
        a_note.delete()

        am = ActivityManager()
        deleted = am.deleted_note(a_user)

        self.assertTrue(len(deleted))
        action = deleted[0]

        self.assertEqual(action.actor, a_user)
        self.assertEqual(action.target, a_map)
        self.assertEqual(action.verb, DELETED_NOTE)
Ejemplo n.º 4
0
    def test_when_changing_a_map_visibility_to_public_a_made_public_action_is_triggered(self):
        a_user = UserFactory.create()
        a_map = MapFactory.create(creator=a_user, visibility=Map.PRIVATE)
        a_map.visibility = Map.PUBLIC
        a_map.save()

        am = ActivityManager()
        made_public = am.made_map_public(a_user)

        self.assertTrue(len(made_public))
        action = made_public[0]

        self.assertEqual(action.actor, a_user)
        self.assertEqual(action.target, a_map)
        self.assertEqual(action.verb, MADE_MAP_PUBLIC)
Ejemplo n.º 5
0
    def test_after_adding_a_editor_to_a_map_a_editor_added_action_is_triggered(self):
        a_user = UserFactory.create()
        a_map = MapFactory.create(creator=a_user)
        another_user = UserFactory.create()
        a_map.editors.add(another_user)

        am = ActivityManager()
        added_to_editors = am.added_to_editors(a_user)

        self.assertTrue(len(added_to_editors))
        action = added_to_editors[0]

        self.assertEqual(action.actor, a_user)
        self.assertEqual(action.action_object, another_user)
        self.assertEqual(action.target, a_map)
        self.assertEqual(action.verb, ADDED_TO_EDITORS)
Ejemplo n.º 6
0
    def test_after_removing_a_editor_from_a_map_a_editor_removed_action_is_triggered(self):
        a_user = UserFactory.create()
        a_map = MapFactory.create(creator=a_user)
        another_user = UserFactory.create()
        a_map.editors.add(another_user)
        a_map.editors.remove(another_user)

        am = ActivityManager()
        removed_from_editors = am.removed_from_editors(a_user)

        self.assertTrue(len(removed_from_editors))
        action = removed_from_editors[0]

        self.assertEqual(action.actor, a_user)
        self.assertEqual(action.action_object, another_user)
        self.assertEqual(action.target, a_map)
        self.assertEqual(action.verb, REMOVED_FROM_EDITORS)