Example #1
0
def yield_cases():
    """Generate cases from YAML file.
    """
    cases = read_yaml(__file__, 'test_us_state_index.yml')

    for group in cases:

        queries = group['query']

        if type(queries) is str:
            queries = [queries]

        for query in queries:
            yield query, group['matches']
def yield_cases():
    """Generate cases from YAML file.
    """
    cases = read_yaml(__file__, 'test_us_city_index.yml')

    for group in cases:

        queries = group['query']

        xfail = group.get('xfail', False)

        if type(queries) is str:
            queries = [queries]

        for query in queries:
            yield query, group['matches'], xfail
Example #3
0
import pytest
import os

from litecoder.models import WOFLocality

from tests.utils import read_yaml

pytestmark = pytest.mark.usefixtures('load_db')

cases = read_yaml(__file__, 'test_ingest_locality.yml')


@pytest.mark.parametrize('wof_id,fields', cases.items())
def test_test(wof_id, fields):

    row = WOFLocality.query.get(wof_id)

    for col, val in fields.items():

        if type(val) is float:
            val = pytest.approx(val, 0.001)

        assert getattr(row, col) == val
Example #4
0
        self.tweeted_messages = []

    def update_status(self, text: str):
        if parse_tweet(text).valid:
            self.tweeted_messages.append(text)
        else:
            raise ValueError(f'The tweet text is invalid: {text}')


def get_table(test_cases: dict) -> Tuple[str, List[list]]:
    header = ",".join(test_cases[0].keys())
    values = [list(case.values()) for case in test_cases]
    return header, values


test_cases = read_yaml('tests/cases/notifier.yml')


@pytest.mark.parametrize(*get_table(test_cases))
@mock_dynamodb2
def test_notifier(description: str, event: List[dict], channels: List[dict],
                  expected: List[dict]):
    twitter = MockTwitter()

    db = boto3.resource('dynamodb', region_name='us-east-2')
    db.create_table(TableName='Channels',
                    KeySchema=[{
                        'AttributeName': 'url',
                        'KeyType': 'HASH'
                    }],
                    AttributeDefinitions=[
Example #5
0
import pytest
import os

from litecoder.models import WOFRegion

from tests.utils import read_yaml

pytestmark = pytest.mark.usefixtures('load_db')

cases = read_yaml(__file__, 'test_ingest_region.yml')


@pytest.mark.parametrize('wof_id,fields', cases.items())
def test_test(wof_id, fields):

    row = WOFRegion.query.get(wof_id)

    for col, val in fields.items():

        if type(val) is float:
            val = pytest.approx(val, 0.001)

        assert getattr(row, col) == val
import pytest
import os

from litecoder.models import WOFCounty

from tests.utils import read_yaml

pytestmark = pytest.mark.usefixtures('load_db')

cases = read_yaml(__file__, 'test_ingest_county.yml')


@pytest.mark.parametrize('wof_id,fields', cases.items())
def test_test(wof_id, fields):

    row = WOFCounty.query.get(wof_id)

    for col, val in fields.items():

        if type(val) is float:
            val = pytest.approx(val, 0.001)

        assert getattr(row, col) == val