Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lyriccoder committed Jul 8, 2020
1 parent 0cb70be commit c7e5029
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aibolit/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@
from os import scandir
from pathlib import Path
from sys import stdout
<<<<<<< Updated upstream
from typing import List, Any, Dict, Tuple

import javalang
=======
from typing import List, Dict, Any, Tuple
>>>>>>> Stashed changes
import numpy as np # type: ignore
import requests
from lxml import etree # type: ignore
Expand Down
20 changes: 20 additions & 0 deletions test/recommend/test_recommend_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,23 @@ def test_find_annotation_by_field_declaration(self):
fields_with_annotations = find_annotation_by_node_type(tree, javalang.tree.FieldDeclaration)
patterns_found_with_fields = list(fields_with_annotations.values())
self.assertEqual(patterns_found_with_fields, [['P23'], ['P23', 'P22']])

def test_pattern_ignore(self):
pattern_item = {'code_lines': [20],
'pattern_code': 'P13',
'pattern_name': 'Null check',
'importance': 30.95612931128819}
results = []
pattern_ignored = {'P13': [[10, 20]]}
add_pattern_if_ignored(pattern_ignored, pattern_item, results)
self.assertEqual(results, [])

def test_pattern_not_ignore(self):
pattern_item = {'code_lines': [20, 30],
'pattern_code': 'P14',
'pattern_name': 'Null check',
'importance': 30.95612931128819}
results = []
pattern_ignored = {'P14': [[60, 100]]}
add_pattern_if_ignored(pattern_ignored, pattern_item, results)
self.assertEqual(results[0]['code_lines'], pattern_item['code_lines'])

0 comments on commit c7e5029

Please sign in to comment.