Beispiel #1
0
    def test_post_data_bad_data(self):
    	data1 = [{
    		"md5checksum":"jsossssn",
    		"uid":"snarf",
    		"name":"snarf",
    		"date":"2015-05-12T14:36:00.451765"
    	}]
    	resp1 = self.app.post('/data/batch', data=json.dumps(data1), content_type='application/json')
    	helpers.assert_error(resp1, 400, 1004)

        # Once correct checksum one invalid one
    	data2 = [
    		{
	    	    'uid': '1',
	            'name': 'John Doe',
	            'date': '2015-05-12T14:36:00.451765',
	            'md5checksum': 'e8c83e232b64ce94fdd0e4539ad0d44f'
	        },
	        {
	    		"md5checksum":"jsossssn",
	    		"uid":"snarf",
	    		"name":"snarf",
	    		"date":"2015-05-12T14:36:00.451765"
	    	}
	    ]
    	resp2 = self.app.post('/data/batch', data=json.dumps(data2), content_type='application/json')
    	helpers.assert_error(resp2, 400, 1004)
Beispiel #2
0
    def test_post_data_bad_request(self):
        resp1 = self.app.post('/data/batch', content_type='application/json')
        helpers.assert_error(resp1, 400, 1000)

        resp2 = self.app.post('/data/batch', data=json.dumps({"json":"json"}))
        helpers.assert_error(resp2, 400, 1000)

        resp3 = self.app.post('/data/batch', data=json.dumps([{"jsosssn":"jsossssn"}]), content_type='application/json')
    	helpers.assert_error(resp3, 400, 1000)

    	resp1 = self.app.post('/data/batch', data=json.dumps([{"md5checksum":"jsossssn"}]), content_type='application/json')
    	helpers.assert_error(resp1, 400, 1000)

        data = [{
            "md5checksum":"jsossssn",
            "uid":"snarf",
            "name":"snarf",
            "date":"not a date"
        }]
        resp4 = self.app.post('/data/batch', data=json.dumps(data), content_type='application/json')
        helpers.assert_error(resp4, 400, 1000)
Beispiel #3
0
    def test_get_data_count_bad_params(self):
    	resp1 = self.app.get('/data/count')
        helpers.assert_error(resp1, 400, 1003)

        resp2 = self.app.get('/data/count?date=2011-09-09')
        helpers.assert_error(resp2, 400, 1003)

        resp3 = self.app.get('/data/count?uid=4')
        helpers.assert_error(resp3, 400, 1003)