Skip to content

Commit

Permalink
Complete initial reports implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
davewalker5 committed Feb 4, 2022
1 parent 752d434 commit 9a8f83a
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/naturerec_model/logic/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ The logic Package
status_schemes
status_ratings
species_status_ratings
reports
job_statuses
5 changes: 5 additions & 0 deletions docs/source/naturerec_model/logic/reports.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
reports.py
==========

.. automodule:: naturerec_model.logic.reports
:members:
1 change: 1 addition & 0 deletions docs/source/naturerec_web/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ The naturerec_web Package
species_ratings_blueprint
export_blueprint
jobs_blueprint
reports_blueprint
request_utils
5 changes: 5 additions & 0 deletions docs/source/naturerec_web/reports_blueprint.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
reports_blueprint.py
====================

.. automodule:: naturerec_web.reports.reports_blueprint
:members:
30 changes: 30 additions & 0 deletions features/reports.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Feature: Reporting
Scenario: Report on numbers of individuals by location
Given A set of sightings
| Date | Location | Category | Species | Number | Gender | WithYoung |
| TODAY | Test Location | Birds | Woodpigeon | 1 | Unknown | No |
| TODAY | Test Location | Birds | Blackbird | 1 | Male | No |
| TODAY | Test Location | Birds | Robin | 1 | Unknown | No |
| TODAY | Test Location | Mammals | Grey Squirrel | 1 | Unknown | No |

When I navigate to the individuals by location report page
And I fill in the individuals by location report details
| Location | Category | From |
| Test Location | Birds | TODAY |

And I click on the "Generate Report" button
Then There will be 3 results in the report table

Scenario: Report on numbers of individuals by location
Given A set of sightings
| Date | Location | Category | Species | Number | Gender | WithYoung |
| TODAY | Test Location | Birds | Woodpigeon | 1 | Unknown | No |
| TODAY | Test Location | Mammals | Grey Squirrel | 1 | Unknown | No |

When I navigate to the sightings by location report page
And I fill in the sightings by location report details
| Location | Category | From |
| Test Location | Birds | TODAY |

And I click on the "Generate Report" button
Then There will be 1 result in the report table
35 changes: 35 additions & 0 deletions features/steps/reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from behave import when, then
from selenium.webdriver.common.by import By

from features.steps.helpers import select_option, get_date_from_string, confirm_table_row_count
from naturerec_model.model import Sighting


@when("I navigate to the individuals by location report page")
def _(context):
url = context.flask_runner.make_url("reports/location/individuals")
context.browser.get(url)
assert "Individuals by Species & Location" in context.browser.title


@when("I navigate to the sightings by location report page")
def _(context):
url = context.flask_runner.make_url("reports/location/sightings")
context.browser.get(url)
assert "Sightings by Species & Location" in context.browser.title


@when("I fill in the individuals by location report details")
@when("I fill in the sightings by location report details")
def _(context):
row = context.table.rows[0]
select_option(context, "location", row["Location"], None)
select_option(context, "category", row["Category"], None)
from_date = get_date_from_string(row["From"]).strftime(Sighting.DATE_DISPLAY_FORMAT)
context.browser.find_element(By.NAME, "from_date").send_keys(from_date)


@then("There will be {number} results in the report table")
@then("There will be {number} result in the report table")
def _(context, number):
confirm_table_row_count(context, number, 1)

0 comments on commit 9a8f83a

Please sign in to comment.