示例#1
0
def test_repository_hasnt_properties_without_matchers(mock_modules):
    # this is meant to ensure that all the previous tests are valid.
    gatherer_mock = MagicMock(spec=aop_gatherer.ModuleGatherer)
    gatherer_mock.load_modules.return_value = mock_modules
    rep = aop_gatherer.Repository()
    rep.gatherer = gatherer_mock
    assert not rep.properties(True)
示例#2
0
def test_repository_property_name_matcher_decorator_adds_to_list():
    rep = aop_gatherer.Repository()
    m = MagicMock()
    rep.prop_name_matcher(m)
    a = list(i('x', 'y') for i in rep.prop_matchers)
    print(a)
    m.assert_called_once_with('x')
示例#3
0
def test_repository_properties_incremental_with_matchers(mock_modules):
    # this is meant to ensure that all the previous tests are valid.
    gatherer_mock = MagicMock(spec=aop_gatherer.ModuleGatherer)
    gatherer_mock.load_modules.return_value = mock_modules
    rep = aop_gatherer.Repository(paths=(MagicMock(),)) # adding a single 'path' so that modules are 'loaded'
    rep.gatherer = gatherer_mock
    rep.prop_name_ends_with('Tester')
    assert all([i.endswith('Tester') if isinstance(i, str) else i == 1 for i in rep.properties()])
    rep.prop_name_starts_with('test_')
    print(list(rep.modules()))
    assert all( [i in rep.properties() for i in [1, 0, 'ThingTester', 'test_thing1']]) and len(rep.properties() ) == 4
示例#4
0
def test_repository_property_name_regex_adds_regex_string_to_list():
        rep = aop_gatherer.Repository()
        rep.prop_name_matches("test_prop.*")
        assert any(i('test_propabcdersggsdfhg', None) for i in rep.prop_matchers)
示例#5
0
def test_repository_module_filter_decorator_adds_to_gatherer():
    rep = aop_gatherer.Repository()
    @rep.module_filter
    def thing(y):
        pass
    assert thing in rep.gatherer.module_filters
示例#6
0
def test_repository_property_matcher_decorator_adds_to_list():
    rep = aop_gatherer.Repository()
    @rep.add_prop_matcher
    def matcher(x, y):
        pass
    assert matcher in rep.prop_matchers #  this is the only one that could work this way