Example #1
0
    def test_check_for_results_done(self):
        """Test kicking off a request."""
        file_reply = {
            "course_id": "123",
            "module_medata": [
                {
                    "module_id": "1",
                    "xa_nr_views": "3",
                    "xa_nr_attempts": "25"
                },
                {
                    "module_id": "2",
                    "xa_nr_views": "7",
                    "xa_nr_attempts": "99"

                }
            ]
        }
        responses.add(
            responses.GET,
            'http://example.com/foo.json',
            body=json.dumps(file_reply),
            content_type="application/json"
        )

        reply = {"status": "complete", "url": "http://example.com/foo.json"}
        responses.add(
            responses.POST,
            'http://example.com/status',
            body=json.dumps(reply),
            content_type="application/json"
        )
        check_for_results("abcde", 10, 1)
Example #2
0
 def test_check_for_results_waiting(self):
     """Test kicking off a request."""
     reply = {"status": "still busy"}
     responses.add(
         responses.POST,
         'http://example.com/status',
         body=json.dumps(reply),
         content_type="application/json"
     )
     check_for_results("abcde", 10, 1)
Example #3
0
 def test_check_for_results_bad(self):
     """Test kicking off a request."""
     responses.add(
         responses.GET,
         'http://example.com/foo.json',
         body='{"invalid": "JSON", "because": "developer comma",}',
         content_type="application/json"
     )
     reply = {"status": "complete", "url": "http://example.com/foo.json"}
     responses.add(
         responses.POST,
         'http://example.com/status',
         body=json.dumps(reply),
         content_type="application/json"
     )
     self.assertRaises(
         ValueError,
         check_for_results("abcde", 10, 1)
     )