-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_parser_test.py
34 lines (25 loc) · 1.2 KB
/
request_parser_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest
from mock import Mock
from sample_payload import *
from request_parser import RequestParser
class RequestParserTest(unittest.TestCase):
def setUp(self):
self.env = {}
self.env['wsgi.input'] = Mock()
def test_ignores_requests_without_json_payload(self):
self.env = 'some_text'
self.request_parser = RequestParser(self.env)
self.request = self.request_parser.parse()
self.assertEquals(self.request, None)
def test_detects_modified_files_in_single_commit(self):
self.env['wsgi.input'].read.return_value = simple_payload
self.request_parser = RequestParser(self.env)
self.request = self.request_parser.parse()
modified_files = set(['file4.py', 'file3.py'])
self.assertEquals(self.request.modified_files, modified_files)
def test_same_modified_file_is_detected_only_once_in_multiple_commits(self):
self.env['wsgi.input'].read.return_value = complex_payload
self.request_parser = RequestParser(self.env)
self.request = self.request_parser.parse()
modified_files = set(['file4.py', 'file3.py', 'file5.py'])
self.assertEquals(self.request.modified_files, modified_files)