Ejemplo n.º 1
0
    def test_claim(self):
        dlist = DiningList.get_latest()
        dlist.save()

        self.client.login(username="******", password="******")

        # We test claiming the dining list without participation

        r = self.client.get(self.view_url)

        dlist = DiningList.get_latest()

        self.assertIsNone(dlist.owner)

        # We test claiming the dining list with a participation

        dpart = DiningParticipation(user=self.testUser, dining_list=dlist)
        dpart.save()

        self.assertIsNone(dlist.owner)

        r = self.client.get(self.view_url)

        self.assertEqual(r.status_code, 302)

        dlist = DiningList.get_latest()

        self.assertIsNotNone(dlist.owner)
        self.assertEqual(dlist.owner, self.testUser)

        # Test that you cannot claim a dining list over someone else

        dpart = DiningParticipation(user=self.testUser2, dining_list=dlist)

        dpart.save()

        self.client.login(username=self.testUser2.username, password="******")

        r = self.client.get(self.view_url)

        self.assertEqual(r.status_code, 302)

        dlist = DiningList.get_latest()

        self.assertNotEqual(dlist.owner, self.testUser2)
        self.assertEqual(dlist.owner, self.testUser)

        dpart.delete()
        dlist.delete()
Ejemplo n.º 2
0
    def test_claim(self):
        dlist = DiningList.get_latest()
        dlist.save()

        self.client.login(username="******", password="******")

        # We test claiming the dining list without participation

        r = self.client.get(self.view_url)

        dlist = DiningList.get_latest()

        self.assertIsNone(dlist.owner)

        # We test claiming the dining list with a participation

        dpart = DiningParticipation(user=self.testUser, dining_list=dlist)
        dpart.save()

        self.assertIsNone(dlist.owner)

        r = self.client.get(self.view_url)

        self.assertEqual(r.status_code, 302)

        dlist = DiningList.get_latest()

        self.assertIsNotNone(dlist.owner)
        self.assertEqual(dlist.owner, self.testUser)

        # Test that you cannot claim a dining list over someone else

        dpart = DiningParticipation(user=self.testUser2, dining_list=dlist)

        dpart.save()

        self.client.login(username=self.testUser2.username, password="******")

        r = self.client.get(self.view_url)

        self.assertEqual(r.status_code, 302)

        dlist = DiningList.get_latest()

        self.assertNotEqual(dlist.owner, self.testUser2)
        self.assertEqual(dlist.owner, self.testUser)

        dpart.delete()
        dlist.delete()
Ejemplo n.º 3
0
    def test_get_registered_user(self):
        dlist = DiningList().get_latest()

        dlist.save()

        dpart = DiningParticipation(user=self.testUser, dining_list=dlist)

        dpart.save()

        # Tests

        self.assertEqual(len(dlist.get_participants()), 1)

        dpart.delete()
        dlist.delete()
Ejemplo n.º 4
0
    def test_get_registered_user(self):
        dlist = DiningList().get_latest()

        dlist.save()

        dpart = DiningParticipation(user=self.testUser, dining_list=dlist)

        dpart.save()

        # Tests

        self.assertEqual(len(dlist.get_participants()), 1)

        dpart.delete()
        dlist.delete()