Ejemplo n.º 1
0
 def test_use_model(self):
     include_models = [
         'NoWildcardInclude', 'Wildcard*InsideInclude',
         '*WildcardPrefixInclude', 'WildcardSuffixInclude*',
         '*WildcardBothInclude*'
     ]
     exclude_models = [
         'NoWildcardExclude', 'Wildcard*InsideExclude',
         '*WildcardPrefixExclude', 'WildcardSuffixExclude*',
         '*WildcardBothExclude*'
     ]
     # Any model name should be used if neither include or exclude
     # are defined.
     self.assertTrue(use_model('SomeModel', None, None))
     # Any model name should be allowed if `*` is in `include_models`.
     self.assertTrue(
         use_model('SomeModel', ['OtherModel', '*', 'Wildcard*Model'],
                   None))
     # No model name should be allowed if `*` is in `exclude_models`.
     self.assertFalse(
         use_model('SomeModel', None,
                   ['OtherModel', '*', 'Wildcard*Model']))
     # Some tests with the `include_models` defined above.
     self.assertFalse(use_model('SomeModel', include_models, None))
     self.assertTrue(use_model('NoWildcardInclude', include_models, None))
     self.assertTrue(
         use_model('WildcardSomewhereInsideInclude', include_models, None))
     self.assertTrue(
         use_model('MyWildcardPrefixInclude', include_models, None))
     self.assertTrue(
         use_model('WildcardSuffixIncludeModel', include_models, None))
     self.assertTrue(
         use_model('MyWildcardBothIncludeModel', include_models, None))
     # Some tests with the `exclude_models` defined above.
     self.assertTrue(use_model('SomeModel', None, exclude_models))
     self.assertFalse(use_model('NoWildcardExclude', None, exclude_models))
     self.assertFalse(
         use_model('WildcardSomewhereInsideExclude', None, exclude_models))
     self.assertFalse(
         use_model('MyWildcardPrefixExclude', None, exclude_models))
     self.assertFalse(
         use_model('WildcardSuffixExcludeModel', None, exclude_models))
     self.assertFalse(
         use_model('MyWildcardBothExcludeModel', None, exclude_models))
 def test_use_model(self):
     include_models = [
         'NoWildcardInclude',
         'Wildcard*InsideInclude',
         '*WildcardPrefixInclude',
         'WildcardSuffixInclude*',
         '*WildcardBothInclude*'
     ]
     exclude_models = [
         'NoWildcardExclude',
         'Wildcard*InsideExclude',
         '*WildcardPrefixExclude',
         'WildcardSuffixExclude*',
         '*WildcardBothExclude*'
     ]
     # Any model name should be used if neither include or exclude
     # are defined.
     self.assertTrue(use_model(
         'SomeModel',
         None,
         None
     ))
     # Any model name should be allowed if `*` is in `include_models`.
     self.assertTrue(use_model(
         'SomeModel',
         ['OtherModel', '*', 'Wildcard*Model'],
         None
     ))
     # No model name should be allowed if `*` is in `exclude_models`.
     self.assertFalse(use_model(
         'SomeModel',
         None,
         ['OtherModel', '*', 'Wildcard*Model']
     ))
     # Some tests with the `include_models` defined above.
     self.assertFalse(use_model(
         'SomeModel',
         include_models,
         None
     ))
     self.assertTrue(use_model(
         'NoWildcardInclude',
         include_models,
         None
     ))
     self.assertTrue(use_model(
         'WildcardSomewhereInsideInclude',
         include_models,
         None
     ))
     self.assertTrue(use_model(
         'MyWildcardPrefixInclude',
         include_models,
         None
     ))
     self.assertTrue(use_model(
         'WildcardSuffixIncludeModel',
         include_models,
         None
     ))
     self.assertTrue(use_model(
         'MyWildcardBothIncludeModel',
         include_models,
         None
     ))
     # Some tests with the `exclude_models` defined above.
     self.assertTrue(use_model(
         'SomeModel',
         None,
         exclude_models
     ))
     self.assertFalse(use_model(
         'NoWildcardExclude',
         None,
         exclude_models
     ))
     self.assertFalse(use_model(
         'WildcardSomewhereInsideExclude',
         None,
         exclude_models
     ))
     self.assertFalse(use_model(
         'MyWildcardPrefixExclude',
         None,
         exclude_models
     ))
     self.assertFalse(use_model(
         'WildcardSuffixExcludeModel',
         None,
         exclude_models
     ))
     self.assertFalse(use_model(
         'MyWildcardBothExcludeModel',
         None,
         exclude_models
     ))
 def test_use_model(self):
     include_models = [
         'NoWildcardInclude',
         'Wildcard*InsideInclude',
         '*WildcardPrefixInclude',
         'WildcardSuffixInclude*',
         '*WildcardBothInclude*',
     ]
     exclude_models = [
         'NoWildcardExclude',
         'Wildcard*InsideExclude',
         '*WildcardPrefixExclude',
         'WildcardSuffixExclude*',
         '*WildcardBothExclude*',
         '*Include',
     ]
     # Any model name should be used if neither include or exclude
     # are defined.
     self.assertTrue(use_model(
         'SomeModel',
         None,
         None,
     ))
     # Any model name should be allowed if `*` is in `include_models`.
     self.assertTrue(use_model(
         'SomeModel',
         ['OtherModel', '*', 'Wildcard*Model'],
         None,
     ))
     # No model name should be allowed if `*` is in `exclude_models`.
     self.assertFalse(use_model(
         'SomeModel',
         None,
         ['OtherModel', '*', 'Wildcard*Model'],
     ))
     # Some tests with the `include_models` defined above.
     self.assertFalse(use_model(
         'SomeModel',
         include_models,
         None,
     ))
     self.assertTrue(use_model(
         'NoWildcardInclude',
         include_models,
         None,
     ))
     self.assertTrue(use_model(
         'WildcardSomewhereInsideInclude',
         include_models,
         None,
     ))
     self.assertTrue(use_model(
         'MyWildcardPrefixInclude',
         include_models,
         None,
     ))
     self.assertTrue(use_model(
         'WildcardSuffixIncludeModel',
         include_models,
         None,
     ))
     self.assertTrue(use_model(
         'MyWildcardBothIncludeModel',
         include_models,
         None,
     ))
     # Some tests with the `exclude_models` defined above.
     self.assertTrue(use_model(
         'SomeModel',
         None,
         exclude_models,
     ))
     self.assertFalse(use_model(
         'NoWildcardExclude',
         None,
         exclude_models,
     ))
     self.assertFalse(use_model(
         'WildcardSomewhereInsideExclude',
         None,
         exclude_models,
     ))
     self.assertFalse(use_model(
         'MyWildcardPrefixExclude',
         None,
         exclude_models,
     ))
     self.assertFalse(use_model(
         'WildcardSuffixExcludeModel',
         None,
         exclude_models,
     ))
     self.assertFalse(use_model(
         'MyWildcardBothExcludeModel',
         None,
         exclude_models,
     ))
     # Test with `exclude_models` and `include_models` combined
     # where the user wants to exclude some models through a wildcard
     # while still being able to include given models
     self.assertTrue(use_model(
         'MyWildcardPrefixInclude',
         include_models,
         exclude_models
     ))
     self.assertFalse(use_model(
         'MyInclude',
         include_models,
         exclude_models
     ))