Skip to content

Commit

Permalink
fix: all tests working. Error in pysat
Browse files Browse the repository at this point in the history
  • Loading branch information
jagalindo committed Jun 5, 2023
1 parent 9e43c56 commit 847ea04
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 11 deletions.
25 changes: 18 additions & 7 deletions flamapy/interfaces/python/FLAMAFeatureModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,18 @@ def error_detection(self):
Errors can include things like dead features, false optional features, or
contradictions in the constraints.
"""
try:
self._transform_to_sat()
errors = self.dm.use_operation(self.sat_model,'Glucose3ErrorDetection').get_result()
return errors
except:
return False
#try:
self._transform_to_sat()
#errors = self.dm.use_operation(self.sat_model,'Glucose3ErrorDetection').get_result()

operation = self.dm.get_operation(self.sat_model,'Glucose3ErrorDetection')
operation.feature_model=self.fm_model
operation.execute(self.sat_model)
result = operation.get_result()

return result
#except:
# return False

def false_optional_features(self):
"""
Expand All @@ -230,7 +236,12 @@ def false_optional_features(self):
"""
try:
self._transform_to_sat()
features = self.dm.use_operation(self.sat_model,'Glucose3FalseOptionalFeatures').get_result()

operation = self.dm.get_operation(self.sat_model,'Glucose3FalseOptionalFeatures')
operation.feature_model=self.fm_model
operation.execute(self.sat_model)
features = operation.get_result()

false_optional_features = []
for feature in features:
false_optional_features.append(feature.name)
Expand Down
11 changes: 11 additions & 0 deletions resources/configurations/invalid_configuration.csvconf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eCommerce,False
Server,False
PHP,False
v74,True
Storage,False
Catalog,True
Shopping,False
Cart,False
Payment,False
Security,False
HIGH,False
16 changes: 16 additions & 0 deletions resources/configurations/valid_configuration.csvconf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
eCommerce,True
Server,True
PHP,True
v74,True
Storage,True
LOW,True
Web,True
Catalog,True
Search,True
BASIC,True
Shopping,True
Cart,True
Payment,True
PayPal,True
Security,True
HIGH,True
46 changes: 46 additions & 0 deletions resources/models/invalid_model.uvl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
features
eCommerce { abstract }
mandatory
Server { abstract }
mandatory
PHP
mandatory
v74
Storage
alternative
LOW
ENOUGH
Web { abstract }
mandatory
Catalog
Search
alternative
BASIC
ADVANCED
Shopping
mandatory
Cart
Payment
or
PayPal
CreditCard
Mobile
Security
alternative
HIGH
STANDARD
optional
Backup
Marketing
optional
SEO
Socials
or
Twitter
Facebook
YouTube
constraints
CreditCard => HIGH
Mobile => HIGH
LOW => !Backup
eCommerce excludes Server
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name="flamapy-fm-dist",
version="1.0.0.dev3",
version="1.0.0.dev4",
author="Flamapy",
author_email="flamapy@us.es",
description="Flamapy feature model is a distribution of the flama framework containing all plugins required to analyze feature models. It also offers a richier API and a complete command line interface and documentation.",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_units.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sys
import warnings
import pytest
from operations.FLAMAFeatureModel import FLAMAFeatureModel
from flamapy.interfaces.python.FLAMAFeatureModel import FLAMAFeatureModel
sys.path.append(".")

VALID_MODEL = "./resources/models/valid_model.uvl"
NON_VALID_MODEL = "./resources/models/non_valid_model.uvl"
NON_VALID_MODEL = "./resources/models/invalid_model.uvl"

VALID_CONFIG = "./resources/configurations/valid_configuration.csvconf"
def test_atomic_sets():
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_dead_features():

def test_error_detection():
# Prepare
flamafm=FLAMAFeatureModel(VALID_MODEL)
flamafm=FLAMAFeatureModel(NON_VALID_MODEL)

# Act
result = flamafm.error_detection()
Expand Down

0 comments on commit 847ea04

Please sign in to comment.