Ejemplo n.º 1
0
class AnalyticsApiRouterTests(TestCase):
    def setUp(self):
        self.router = AnalyticsApiRouter()

    def test_allow_relation(self):
        """
        Relations should only be allowed for objects contained within the same database.
        """
        self.assertFalse(self.router.allow_relation(CourseEnrollmentDaily, User))
        self.assertTrue(self.router.allow_relation(CourseEnrollmentDaily, CourseEnrollmentByBirthYear))
Ejemplo n.º 2
0
class AnalyticsApiRouterTests(TestCase):
    def setUp(self):
        self.router = AnalyticsApiRouter()

    def test_allow_relation(self):
        """
        Relations should only be allowed for objects contained within the same database.
        """
        self.assertFalse(
            self.router.allow_relation(CourseEnrollmentDaily, User))
        self.assertTrue(
            self.router.allow_relation(CourseEnrollmentDaily,
                                       CourseEnrollmentByBirthYear))
class AnalyticsApiRouterTests(TestCase):
    def setUp(self):
        self.router = AnalyticsApiRouter()

    def test_allow_relation(self):
        """
        Relations should only be allowed for objects contained within the same database.
        """
        self.assertFalse(
            self.router.allow_relation(CourseEnrollmentDaily, User))
        self.assertTrue(
            self.router.allow_relation(CourseEnrollmentDaily,
                                       CourseEnrollmentByBirthYear))

    @mock.patch.dict('analytics_data_api.middleware.thread_data.__dict__',
                     {'analyticsapi_database': 'test'})
    def test_db_for_read_thread_data_with_data(self):
        self.assertEqual(self.router.db_for_read(CourseEnrollmentDaily),
                         'test')

    def test_db_for_read_thread_data_without_data(self):
        self.assertEqual(self.router.db_for_read(CourseEnrollmentDaily),
                         'default')