• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uw-it-aca / canvas-analytics / 11896126332

18 Nov 2024 03:54PM UTC coverage: 93.756% (-0.1%) from 93.887%
11896126332

Pull #265

github

web-flow
Merge 673d8dd23 into 152ce9ce7
Pull Request #265: set up secrets for aws access

12 of 14 new or added lines in 4 files covered. (85.71%)

5 existing lines in 2 files now uncovered.

3799 of 4052 relevant lines covered (93.76%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/data_aggregator/tests/test_cache.py
1
# Copyright 2024 UW-IT, University of Washington
2
# SPDX-License-Identifier: Apache-2.0
3

4

5
import unittest
1✔
6
from django.test import TestCase
1✔
7
from data_aggregator.cache import DataAggregatorGCSCache
1✔
8

9

10
class TestDataAggregatorGCSCache(TestCase):
1✔
11

12
    def test_get_cache_expiration_time(self):
1✔
13
        cache = DataAggregatorGCSCache()
1✔
14
        # valid analytics urls
15
        self.assertEqual(
1✔
16
            cache.get_cache_expiration_time(
17
                "canvas",
18
                "/api/v1/courses/1392640/analytics/student_summaries.json",
19
                status=200),
20
            0)
21
        self.assertEqual(
1✔
22
            cache.get_cache_expiration_time(
23
                "canvas",
24
                "/api/v1/courses/1452786/analytics/student_summaries.json"
25
                "?per_page=100",
26
                status=200),
27
            0)
28
        self.assertEqual(
1✔
29
            cache.get_cache_expiration_time(
30
                "canvas",
31
                "/api/v1/courses/1399587/analytics/users/3562797/"
32
                "assignments.json",
33
                status=200),
34
            0)
35
        # bad status
36
        self.assertEqual(
1✔
37
            cache.get_cache_expiration_time(
38
                "canvas",
39
                "/api/v1/courses/1399587/analytics/users/3562797/"
40
                "assignments.json",
41
                status=500),
42
            None)
43
        # valid subaccount report urls
44
        self.assertEqual(
1✔
45
            cache.get_cache_expiration_time(
46
                "canvas",
47
                "/api/v1/accounts/sis_account_id:account_103831/analytics/"
48
                "terms/sis_term_id:2021-spring/activity.json",
49
                status=200),
50
            0)
51
        self.assertEqual(
1✔
52
            cache.get_cache_expiration_time(
53
                "canvas",
54
                "/api/v1/accounts/sis_account_id:uwcourse:seattle:"
55
                "information-school:inform:ita:future/analytics/"
56
                "terms/sis_term_id:2021-spring/statistics.json",
57
                status=200),
58
            0)
59
        # bad status
60
        self.assertEqual(
1✔
61
            cache.get_cache_expiration_time(
62
                "canvas",
63
                "/api/v1/accounts/sis_account_id:uwcourse:seattle:"
64
                "information-school:inform:ita:future/analytics/"
65
                "terms/sis_term_id:2021-spring/statistics.json",
66
                status=500),
67
            None)
68
        # unknown service
69
        self.assertEqual(
1✔
70
            cache.get_cache_expiration_time(
71
                "foobar",
72
                "/api/v1/courses/1392640/analytics/",
73
                status=200),
74
            None)
75
        # bad url
76
        self.assertEqual(
1✔
77
            cache.get_cache_expiration_time(
78
                "canvas",
79
                "/api/v2/courses/1392640/analytics/",
80
                status=200),
81
            None)
82
        # subaccount urls to ignore
83
        self.assertEqual(
1✔
84
            cache.get_cache_expiration_time(
85
                "canvas",
86
                "/api/v1/accounts/sis_account_id:uwcourse/sub_accounts"
87
                "?recursive=true&page=2&per_page=100",
88
                status=200),
89
            None)
90

91

92
if __name__ == "__main__":
1✔
93
    unittest.main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc