Esempio n. 1
0
def daterange(start_date=None, end_date=None):
    if not start_date:
        start_date = v.default_date()
    if not end_date:
        end_date = v.today()
    for n in range(int((end_date - start_date).days)):
        yield start_date + datetime.timedelta(n)
Esempio n. 2
0
def test_utils():
    assert '2019-03-01 00:00:00' == dtvals.date_types_to_str(v.today())
    assert datetime.datetime(2019, 1, 1, 0, 0) == dtvals.date_to_datetime(
        datetime.date(2019, 1, 1))
Esempio n. 3
0
from birgitta.schema.fixtures import Fixture, RowConf
from birgitta.schema.fixtures import values as v
from birgitta.schema.fixtures.values import dtvals
from birgitta.schema.fixtures.variants import RowConfsVariant

from ...datasets.daily_contract_states import dataset as daily_contract_states

row_confs = []
for dt in dtvals.daterange():
    row_confs.append(RowConf().set_field('datestamp',
                                         dt).set_field('end_date', v.today()))

fixture = Fixture(daily_contract_states)
fixture.set_default_variant(RowConfsVariant(row_confs))
Esempio n. 4
0
from birgitta.schema.fixtures import ExampleVal
from birgitta.schema.fixtures import values as v
from birgitta.schema.schema import Schema

from .....shared.schema.catalog.tribune import catalog

FIELDS = [["sequence_no", "bigint"], ["customer_id", "bigint"],
          ["phone", "string"], ["group_account_id", "bigint"],
          ["product_code", "string"], ["product", "string"],
          ["segment", "string"], ["product_payment_type", "string"],
          ["product_name", "string"], ["brand_name", "string"],
          ["start_date", "date"], ["end_date", "date",
                                   ExampleVal(v.today())],
          ["shop_code", "string"], ["product_category", "string"]]

schema = Schema(FIELDS, catalog)
Esempio n. 5
0
def enddate_yyyymmdd():
    """We have no data before 2019-01-07"""
    return dtvals.datestr(v.today())
Esempio n. 6
0
"""Helpers and imports for pyspark unit tests
"""
import pytest
from birgitta import context
from birgitta import spark
from birgitta.schema.fixtures import values

# We must import these fixtures explicitly to make them available
# in localtest fixtures at run time.
from birgitta.recipetest.coverage.report import cov_report  # noqa 401
from birgitta.recipetest.coverage.report import cov_report_path  # noqa 401
from birgitta.recipetest.coverage.report import cov_results  # noqa 401


@pytest.fixture(scope="session")
def spark_session():
    return spark.local_session()  # duration: about 3secs


context.set("TODAY", values.today())
Esempio n. 7
0
from birgitta.schema.fixtures import Fixture, RowConf
from birgitta.schema.fixtures import values as v
from birgitta.schema.fixtures.variants import RowConfsVariant

from ...datasets.filtered_contracts import dataset as filtered_contracts

fixture = Fixture(filtered_contracts)
default_row_confs = [RowConf().set_field('end_date', v.today())]
fixture.set_default_variant(RowConfsVariant(default_row_confs))
fixture.add_variant('brand_code_44', RowConfsVariant([]))
Esempio n. 8
0
 def get_default_date_and_today(date=None, today=None):
     if today is None:
         today = v.today()
     if date is None:
         date = v.default_date()
     return func(date, today)