Beispiel #1
0
    def test_post_revision(self, expected, updates):
        self.client.login(username="******", password="******")

        post_data = {"location": 1, "time_block": 1, "time_slot": 1}

        game = Game()
        modify_game(game)
        game.user = User.objects.get(username="******")
        game.location = Location.objects.get(id=post_data["location"])
        game.time_block = TimeBlock.objects.get(id=post_data["time_block"])
        game.time_slot = TimeSlot.objects.get(id=post_data["time_slot"])
        game.last_modified = timezone.now()
        game.save()

        post_data["id"] = game.id

        self.assertEquals(len(reversion.get_for_object(game)), 0)

        post_data.update(updates)
        self.client.post(self.url, post_data)

        versions = reversion.get_for_object(game)
        self.assertEquals(len(versions), 1)
        self.assertEquals(versions[0].revision.comment,
                          "AJAX Schedule Submission - %s Changed" % expected)
Beispiel #2
0
    def run_post_test(self,
                      username,
                      location=Location.objects.all()[0],
                      time_block=TimeBlock.objects.all()[0],
                      time_slot=TimeSlot.objects.all()[0]):
        self.client.login(username=username, password="******")

        game = Game()
        modify_game(game)
        game.user = User.objects.get(username=username)
        game.last_modified = timezone.now() - timedelta(days=-1)
        game.save()
        modified_date = timezone.now()

        game = Game.objects.get(title="Unit Test Title")
        post_data = {"id": game.id}
        if location:
            post_data["location"] = location.id
        if time_block:
            post_data["time_block"] = time_block.id
        if time_slot:
            post_data["time_slot"] = time_slot.id
        self.client.post(self.url, post_data)

        game = Game.objects.get(title="Unit Test Title")
        self.assertGreater(game.last_scheduled, modified_date)
        self.assertEquals(game.time_block, time_block)
        self.assertEquals(game.time_slot, time_slot)
        self.assertEquals(game.location, location)