Пример #1
0
 def test_009_retrieve_taskcollection_from_server(self):
     challenge = MapRouletteChallenge.from_server(
         self.server,
         self.test_challenge_slug)
     task_collection = MapRouletteTaskCollection.from_server(
         self.server,
         challenge)
     self.assertTrue(len(task_collection.tasks) == self.A_TON + 1)
Пример #2
0
    def test_010_reconcile_task_collections(self):
        """
        In this test case, we will reconcile a task collection with an
        existing one on the server (created in 008).
        Compared to the existing task collection, we will remove one task,
        add one task, and change one task.
        """

        # get the challenge from server
        challenge = MapRouletteChallenge.from_server(
            self.server,
            self.test_challenge_slug)
        # get the task collection to reconcile, start out with the
        # existing one on the server
        task_collection = MapRouletteTaskCollection.from_server(
            self.server,
            challenge)
        # remove the last task, so it appears 'deleted'
        task_collection.tasks.pop()
        # append a different task in place, so it appears 'new'
        task_collection.tasks.append(
            MapRouletteTask(
                challenge=challenge,
                identifier='task-{}'.format(uuid.uuid4()),
                geometries=self.__random_point()))
        # and finally change one task so it appears 'updated'
        task_collection.tasks[0].geometries = self.__random_point()
        task_collection.tasks[0].status = 'changed'

        # reconcile the two collections
        result = task_collection.reconcile(self.server)

        # assert that we indeed have one new, one changed and one deleted task.
        self.assertTrue(len(result['new']) == 1)
        self.assertTrue(len(result['changed']) == 1)
        self.assertTrue(len(result['deleted']) == 1)