diff --git a/src/test/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSettersTest.java b/src/test/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSettersTest.java index c68228e..91b124d 100644 --- a/src/test/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSettersTest.java +++ b/src/test/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSettersTest.java @@ -24,6 +24,7 @@ public class AvoidGettersAndSettersTest { @Test public void test() { - PythonCheckVerifier.verify("src/test/resources/checks/avoidGettersAndSetters.py", new AvoidGettersAndSetters()); + PythonCheckVerifier.verifyNoIssue("src/test/resources/checks/avoidGettersAndSettersCompliant.py", new AvoidGettersAndSetters()); + PythonCheckVerifier.verify("src/test/resources/checks/avoidGettersAndSettersNonCompliant.py", new AvoidGettersAndSetters()); } } diff --git a/src/test/resources/checks/avoidGettersAndSettersCompliant.py b/src/test/resources/checks/avoidGettersAndSettersCompliant.py new file mode 100644 index 0000000..13fa802 --- /dev/null +++ b/src/test/resources/checks/avoidGettersAndSettersCompliant.py @@ -0,0 +1,20 @@ +from datetime import date + +class Client(): + + def __init__(self, age, weight): + self.age = age + self.weight = weight + + def get_age_in_five_years(self): + a = Client() + return a.age + + def is_major(self): + return self.age >= 18 + +client = Client(25) +client.age +client.age = 25 +client.weight +client.weight(5) \ No newline at end of file diff --git a/src/test/resources/checks/avoidGettersAndSetters.py b/src/test/resources/checks/avoidGettersAndSettersNonCompliant.py similarity index 88% rename from src/test/resources/checks/avoidGettersAndSetters.py rename to src/test/resources/checks/avoidGettersAndSettersNonCompliant.py index 538e79a..4506eb2 100644 --- a/src/test/resources/checks/avoidGettersAndSetters.py +++ b/src/test/resources/checks/avoidGettersAndSettersNonCompliant.py @@ -24,3 +24,9 @@ def is_major(self): def get_weight(self): # Noncompliant {{Avoid creating getter and setter methods in classes}} return self.weight + +client = Client(25) +client.get_age() +client.set_age(25) +client.get_weight() +client.set_weight(5) \ No newline at end of file