diff --git a/docs/source/naturerec_model/logic/index.rst b/docs/source/naturerec_model/logic/index.rst index 79ef7f0..298a2d9 100644 --- a/docs/source/naturerec_model/logic/index.rst +++ b/docs/source/naturerec_model/logic/index.rst @@ -12,4 +12,5 @@ The logic Package status_schemes status_ratings species_status_ratings + reports job_statuses diff --git a/docs/source/naturerec_model/logic/reports.rst b/docs/source/naturerec_model/logic/reports.rst new file mode 100644 index 0000000..9dfd806 --- /dev/null +++ b/docs/source/naturerec_model/logic/reports.rst @@ -0,0 +1,5 @@ +reports.py +========== + +.. automodule:: naturerec_model.logic.reports + :members: diff --git a/docs/source/naturerec_web/index.rst b/docs/source/naturerec_web/index.rst index 03d7c39..004edd1 100644 --- a/docs/source/naturerec_web/index.rst +++ b/docs/source/naturerec_web/index.rst @@ -14,4 +14,5 @@ The naturerec_web Package species_ratings_blueprint export_blueprint jobs_blueprint + reports_blueprint request_utils diff --git a/docs/source/naturerec_web/reports_blueprint.rst b/docs/source/naturerec_web/reports_blueprint.rst new file mode 100644 index 0000000..97bd74e --- /dev/null +++ b/docs/source/naturerec_web/reports_blueprint.rst @@ -0,0 +1,5 @@ +reports_blueprint.py +==================== + +.. automodule:: naturerec_web.reports.reports_blueprint + :members: diff --git a/features/reports.feature b/features/reports.feature new file mode 100644 index 0000000..0ee7d00 --- /dev/null +++ b/features/reports.feature @@ -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 diff --git a/features/steps/reports.py b/features/steps/reports.py new file mode 100644 index 0000000..f282ebf --- /dev/null +++ b/features/steps/reports.py @@ -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)