def test_can_read_json_from_collection_file(self): parser = Parser() parser.openFile(self.collectionfile) examples = parser.getExamples() urls = [] for example in examples: self.assertIsInstance(example['request'], pmrequest) urls.append(example['request'].getUri()) self.assertCountEqual([ 'http://localhost/memcache/get', 'http://localhost/memcache/get', 'http://localhost/memcache/get_or_set' ], urls)
def test_code_generation_3(self): self.maxDiff = None scanner = Scanner(self.valid_input_3) Parser(scanner, DEBUG=False, OUTPUT=False) with open('output/output.txt', 'r') as output_file: output = output_file.read() self.assertEqual(output, self.expected_output_3)
def test_openfile_can_get_content(self): parser = Parser() parser.openFile(self.collectionfile) self.assertEqual(self.collectionfile, parser.getFile()) with open(self.collectionfile, 'r') as f: mockcontent = json.loads(f.read()) self.assertEqual( json.dumps(mockcontent), parser.getContent() ) f.close()
def test_parse_tree(self, mocked_analyzer): self.maxDiff = None scanner = Scanner(self.valid_input, OUTPUT=False) parser = Parser(scanner, OUTPUT=False) parse_tree = parser.get_parse_tree() self.assertEqual(parse_tree, expected_parse_tree)
def test_exception_thrown_on_file_not_found(self, mock_os_path): mock_os_path.isfile.return_value = False parser = Parser() self.assertRaises(Exception, parser.openFile, self.collectionfile)
def test_openfile_can_get_content(self, mock_os_path): mock_os_path.isfile.return_value = True parser = Parser() parser.openFile(self.collectionfile) self.assertEqual(self.collectionfile, parser.getFile()) self.assertIsNotNone(parser.getContent())