コード例 #1
0
 def fpl_test(self, input_name, expected_name, start_date=None, end_date=None):
     self.fixture_test(
         transformer=UrjanetGridiumTransformer(),
         input_path=os.path.join(DATA_DIR, input_name),
         expected_path=os.path.join(DATA_DIR, expected_name),
         start_date=start_date,
         end_date=end_date,
     )
コード例 #2
0
def datafeed(
    account: SnapmeterAccount,
    meter: Meter,
    datasource: MeterDataSource,
    params: dict,
    task_id: Optional[str] = None,
) -> Status:
    return run_urjanet_datafeed(
        account,
        meter,
        datasource,
        params,
        FPLDatasource(
            meter.utility_service.utility,
            meter.utility_account_id,
            meter.utility_service.service_id,
        ),
        UrjanetGridiumTransformer(),
        task_id=task_id,
    )
コード例 #3
0
    def verify_transform(self, transformer: UrjanetGridiumTransformer,
                         utility: str):
        """Verify a transformer by comparing against a csv fixture.

        csv data should be datafeeds/urjanet/tests/data/utility-id.csv
        with fields utility,utility_account_id,service_id,start,end,cost,used,peak
        """
        fixture = self.load_fixture(utility)
        for key in fixture:
            # read data from data/utility_id/key.json
            input_data_source = FixtureDataSource(
                "%s/%s/%s.json" %
                (self.data_directory, utility.replace("-", "_"), key))
            input_data = input_data_source.load()
            # run transformer
            output = transformer.urja_to_gridium(input_data)
            log.debug("created %s bills" % len(output.periods))
            for period in output.periods:
                log.debug(
                    "%s - %s\t%.2f\t%.2f",
                    period.start,
                    period.end,
                    period.total_charge,
                    period.total_usage,
                )
            for bill in fixture[key]:
                log.debug(
                    "looking for bill %s - %s\t%s\t%s",
                    bill.start,
                    bill.end,
                    bill.cost,
                    bill.used,
                )
                self.match_bill(
                    output.periods,
                    bill,
                    "%s %s" % (bill.utility_account_id, bill.service_id),
                )
コード例 #4
0
ファイル: cli_hooks.py プロジェクト: gnoose/datafeeds-shared
 def make_transformer(self):
     return UrjanetGridiumTransformer()