Exemple #1
0
def test_fetch_value():
    config = Config(config_file=get_fixtures_directory() + '/config.yaml')

    metric = Metric(spec={
        'name': 'foo/bar',
        'source': 'common/const',
    }, feature_name='foo', config=config)

    print(metric)
    assert metric.get_source_name() == ConstSource.NAME
    assert metric.fetch_value() == 1
    assert metric.value == 1, 'We should not need to connect to database to get this'
Exemple #2
0
def test_metric():
    config = get_config(
        env={
            'JIRA_URL': 'https://foo.atlasian.net',
            'JIRA_USER': '******',
            'JIRA_PASSWORD': '******',
        })
    metric = Metric(spec={
        'name': 'jira/p2-tickets',
        'source': 'wikia/jira',
        'template': {
            'project': 'DynamicPageList',
            'tag': 'dpl'
        }
    },
                    feature_name='foo',
                    config=config)

    print(metric)

    assert metric.get_name() == 'jira/p2-tickets'
    assert metric.get_source_name() == 'wikia/jira'
    assert metric.get_spec() == {
        'name': 'jira/p2-tickets',
        'source': 'wikia/jira',
        'template': {
            'project': 'DynamicPageList',
            'tag': 'dpl'
        }
    }

    source = SourceBase.new_for_metric(metric=metric, config=config)

    print(source)

    assert isinstance(
        source, JiraSource
    ), 'get_source_from_metric should return an instance of JiraSource'
    assert source._server == 'https://foo.atlasian.net'
    assert source._basic_auth == ('MrFoo',
                                  '9bec73487c01653ad7830c25e4b1dc926d17e518')