-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from justjasongreen/seed
Implement Seed Command (closes #25)
- Loading branch information
Showing
9 changed files
with
73 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import sys | ||
|
||
from . import Command | ||
|
||
|
||
class SeedCommand(Command): | ||
"""Command line utility to pre-seed query data for all active runners in a specified date range""" | ||
|
||
def process_runner(self, runner): | ||
"""Extend the process_runner method to generate a sample if necessary""" | ||
|
||
super().process_runner(runner) | ||
|
||
if runner['is_scratched'] == False: | ||
runner.sample.normalized_query_data | ||
|
||
|
||
def main(): | ||
"""Main entry point for seed console script""" | ||
|
||
ScrapeCommand.main(sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import predictive_punter | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def seed_command(database_uri): | ||
|
||
predictive_punter.SeedCommand.main(['-d', database_uri, '2016-2-1', '2016-2-2']) | ||
|
||
|
||
def test_samples(database, seed_command): | ||
"""The seed command should populate the database with the expected number of samples""" | ||
|
||
assert database['samples'].count() == database['runners'].count({'is_scratched': False}) | ||
|
||
|
||
def test_values(database, seed_command): | ||
"""The seed command should set normalized query data values for all samples""" | ||
|
||
for sample in database['samples'].find(): | ||
assert sample['normalized_query_data'] is not None |