Example #1
0
 def test_nested_tour(self):
     """
     Verifies that records get created properly for nested tours
     """
     MockTour.create()
     MockTour2.create()
     self.assertEqual(4, Step.objects.all().count())
     steps = list(Step.objects.all().order_by("id"))
     self.assertEqual(steps[0].parent_step, None)
     self.assertEqual(steps[1].parent_step, None)
     self.assertEqual(steps[2].parent_step, steps[0])
     self.assertEqual(steps[3].parent_step, steps[0])
Example #2
0
    def test_delete(self):
        """
        Verifies that a tour and its steps get deleted
        """
        MockTour.create()
        MockTour2.create()
        self.assertEqual(1, Tour.objects.count())
        self.assertEqual(4, Step.objects.count())

        MockTour2.delete()
        self.assertEqual(1, Tour.objects.count())
        self.assertEqual(2, Step.objects.count())

        MockTour.delete()
        self.assertEqual(0, Tour.objects.count())
        self.assertEqual(0, Step.objects.count())
Example #3
0
    def test_url_list(self):
        """
        Verifies that the tour builds the url list correctly
        """
        # Create the tours
        MockTour.create()
        MockTour2.create()

        # Add a user
        MockTour.add_user(self.test_user)

        # Fetch the tour
        tour_class = Tour.objects.get_for_user(self.test_user)

        urls = tour_class.get_url_list()
        expected_urls = ["mock1", "mock3", "mock4", "mock2"]
        self.assertEqual(expected_urls, urls)
Example #4
0
    def test_url(self):
        """
        Verifies that the tour returns the correct next url
        """
        # Create the tours
        MockTour.create()
        MockTour2.create()

        # Add a user
        MockTour.add_user(self.test_user)

        # Fetch the tour
        tour_class = Tour.objects.get_for_user(self.test_user)

        # Get the url
        url = tour_class.get_next_url()
        self.assertEqual("mock1", url)

        MockStep1.complete = True
        tour_class = Tour.objects.get_for_user(self.test_user)
        url = tour_class.get_next_url()
        self.assertEqual("mock3", url)

        MockStep3.complete = True
        tour_class = Tour.objects.get_for_user(self.test_user)
        url = tour_class.get_next_url()
        self.assertEqual("mock4", url)

        MockStep4.complete = True
        tour_class = Tour.objects.get_for_user(self.test_user)
        url = tour_class.get_next_url()
        self.assertEqual("mock2", url)

        MockStep2.complete = True
        tour_class = Tour.objects.get_for_user(self.test_user)
        self.assertIsNone(tour_class)

        # Check that no url is returned for a complete tour
        Tour.objects.all().delete()
        Step.objects.all().delete()
        CompleteTour.add_user(self.test_user)
        tour_class = Tour.objects.get().load_tour_class()
        self.assertTrue(tour_class.is_complete())
        url = tour_class.get_next_url()
        self.assertIsNone(url)
Example #5
0
    def test_create(self):
        """
        Verifies that the tour gets created only once
        """
        # Create a single tour
        MockTour.create()
        self.assertEqual(1, Tour.objects.all().count())
        self.assertEqual(len(MockTour.steps), Step.objects.all().count())

        # Try to create a duplicate
        MockTour.create()
        self.assertEqual(1, Tour.objects.all().count())
        self.assertEqual(len(MockTour.steps), Step.objects.all().count())

        # Create a tour with a parent and make sure only the steps get added to the parent tour
        MockTour2.create()
        self.assertEqual(1, Tour.objects.count())
        self.assertEqual(4, Step.objects.count())