|
40 | 40 | from .conf import test_xandikos |
41 | 41 | from .conf import xandikos_host |
42 | 42 | from .conf import xandikos_port |
43 | | -from caldav import compatibility_hints |
| 43 | +from caldav.compatibility_hints import FeatureSet |
| 44 | +from caldav.compatibility_hints import incompatibility_description ## TEMP - should be removed in the future |
44 | 45 | from caldav.davclient import DAVClient |
45 | 46 | from caldav.davclient import DAVResponse |
46 | 47 | from caldav.davclient import get_davclient |
@@ -666,49 +667,38 @@ def check_support(self, feature, return_type=bool): |
666 | 667 |
|
667 | 668 | TODO: write a better docstring |
668 | 669 | """ |
669 | | - feature_info = compatibility_hints.FEATURES.find_feature(feature) |
670 | | - support = self.features.get(feature, {'support': 'full'}) |
671 | | - if return_type == str: |
672 | | - ## TODO: consider type, be smarter about it |
673 | | - return support.get('support', support.get('enable', support.get('behaviour'))) |
674 | | - elif return_type == dict: |
675 | | - return support |
676 | | - elif return_type == bool: |
677 | | - ## TODO: consider type, be smarter about it |
678 | | - return support.get('support', 'full') == 'full' and not support.get('enable') and not support.get('behaviour') |
679 | | - |
| 670 | + return self.features.check_support(feature, return_type) |
| 671 | + |
680 | 672 | def check_compatibility_flag(self, flag): |
681 | 673 | ## yield an assertion error if checking for the wrong thig |
682 | | - assert flag in compatibility_hints.incompatibility_description |
683 | | - return flag in self.features['old_flags'] |
| 674 | + assert flag in incompatibility_description |
| 675 | + return flag in self.old_features |
684 | 676 |
|
685 | 677 | def skip_on_compatibility_flag(self, flag): |
686 | 678 | if self.check_compatibility_flag(flag): |
687 | | - msg = compatibility_hints.incompatibility_description[flag] |
| 679 | + msg = incompatibility_description[flag] |
688 | 680 | pytest.skip("Test skipped due to server incompatibility issue: " + msg) |
689 | 681 |
|
690 | 682 | def skip_unless_support(self, feature): |
691 | 683 | if self.check_support(feature): |
692 | | - msg = compatibility_hints.FEATURES.find_feature(feature).get('description', feature) |
| 684 | + msg = self.features.find_feature(feature).get('description', feature) |
693 | 685 | pytest.skip("Test skipped due to server incompatibility issue: " + msg) |
694 | 686 |
|
695 | 687 | def setup_method(self): |
696 | 688 | logging.debug("############## test setup") |
697 | | - self.features = {} |
698 | 689 | self.cleanup_regime = self.server_params.get("cleanup", "light") |
699 | 690 | self.calendars_used = [] |
700 | 691 |
|
701 | | - self.features = self.server_params.get("features", {}) |
| 692 | + features = self.server_params.get("features", {}) |
| 693 | + |
| 694 | + ## Temp thing |
| 695 | + self.old_features = features.get('old_flags', []) |
| 696 | + |
| 697 | + self.features = FeatureSet(self.server_params.get("features", {})) |
702 | 698 |
|
703 | 699 | ## verify that all old flags are valid |
704 | | - for flag in self.features.get('old_flags'): |
705 | | - assert flag in compatibility_hints.incompatibility_description |
706 | | - |
707 | | - ## verify that all new compatibility info is valid (TODO: should validate better) |
708 | | - for feature in self.server_params.get('features', []): |
709 | | - if feature == 'old_flags': |
710 | | - continue |
711 | | - compatibility_hints.FEATURES.find_feature(feature) |
| 700 | + for flag in self.old_features: |
| 701 | + assert flag in incompatibility_description |
712 | 702 |
|
713 | 703 | if self.check_compatibility_flag("unique_calendar_ids"): |
714 | 704 | self.testcal_id = "testcalendar-" + str(uuid.uuid4()) |
|
0 commit comments