예제 #1
0
    def test_survey_participant_list_type(self):
        payload = {
            'token': 'foobar',
            'content': 'participantList',
            'format': 'json',
            'instrument': 'bar',
        }
        url = 'https://foobarbat.com'
        typee = 'exp_survey_participant_list'
        # This should not raise
        RCRequest(url, payload, typee)

        # This should raise because of a different content
        payload['content'] = 'foobar'
        with self.assertRaises(RCAPIError):
            RCRequest(url, payload, typee)
예제 #2
0
    def test_survey_participant_list_type(self):
        """Test that partcipant list checks for proper content"""
        payload = {
            "token": "foobar",
            "content": "participantList",
            "format": "json",
            "instrument": "bar",
        }
        url = "https://foobarbat.com"
        typee = "exp_survey_participant_list"
        # This should not raise
        RCRequest(url, payload, typee)

        # This should raise because of a different content
        payload["content"] = "foobar"
        with self.assertRaises(RCAPIError):
            RCRequest(url, payload, typee)
예제 #3
0
    def test_bad_md(self):
        """Test that newlines are appropriately dealt with"""

        responses.add(responses.POST, "https://redcap.vanderbilt.edu/api/")

        args = ["https://redcap.vanderbilt.edu/api/", self.badmd, "metadata"]
        res = RCRequest(*args).execute()
        self.assertTrue(res is not None)
        self.assertTrue(len(res) > 0)
예제 #4
0
 def test_md_content(self):
     """Test that RCRequest throws correctly for malformed payloads"""
     payload = self.base
     ags = [self.url, payload, "metadata"]
     #  no 'content' key
     self.assertRaises(RCAPIError, RCRequest, *ags)
     #  wrong content
     payload["content"] = "blahblah"
     self.assertRaises(RCAPIError, RCRequest, *ags)
     #  good content
     payload["content"] = "metadata"
     res = RCRequest(*ags)
     self.assertIsInstance(res, RCRequest)
예제 #5
0
 def test_md_content(self):
     """Test that RCRequest throws correctly for malformed payloads"""
     pl = self.base
     ags = [self.url, pl, 'metadata']
     #  no 'content' key
     self.assertRaises(RCAPIError, RCRequest, *ags)
     #  wrong content
     pl['content'] = 'blahblah'
     self.assertRaises(RCAPIError, RCRequest, *ags)
     #  good content
     pl['content'] = 'metadata'
     r = RCRequest(*ags)
     self.assertIsInstance(r, RCRequest)
예제 #6
0
 def test_bad_md(self):
     """Test that newlines are appropriately dealt with"""
     args = ['https://redcap.vanderbilt.edu/api/', self.badmd, 'metadata']
     r = RCRequest(*args).execute()
     self.assertTrue(r is not None)
     self.assertTrue(len(r) > 0)