Git Product home page Git Product logo

sbr-ui's Introduction

sbr-ui

phase license

A proof of concept of the Statistical Business Register User Interface using Flask.

Previous repository: https://github.com/ONSdigital/sbr-react-ui

Table of Contents

1. Environment Setup
2. Running Instructions
3. Environment Variables
4. Testing
5. Dependencies
6. Troubleshooting
7. Contributing
8. License

Environment Setup

Firstly, install Python 3:

brew install python

Create a virtual environment (from inside the cloned repository):

python3 -m venv venv

Running Instructions

Activate the virtual environment:

source venv/bin/activate

Install dependencies from the requirements.txt file:

pip install -r requirements.txt

Run the server in development mode, with hot-reloading:

FLASK_APP=run.py FLASK_DEBUG=1 ENVIRONMENT=DEV python3 -m flask run

Note: USE_FAKE_DATA=True can be passed in to allow the application to run without sbr-api. The test data is held here.

The user interface can be accessed on http://localhost:5000. With the default ENVIRONMENT (DEV), login with admin/admin

Environment Variables

Environment Variable Default Value
ENVIRONMENT DEV
USE_FAKE_DATA False
LOG_LEVEL INFO
API_TIMEOUT 2 (seconds)
AUTH_TIMEOUT 2 (seconds)
AUTH_URL http://localhost:3002/auth
API_URL http://localhost:9000
SECRET_KEY change_me

The server will not start unless you have set ENVIRONMENT to one of DEV/TEST/PROD.

In PROD mode, the server will only start if you have set AUTH_URL, API_URL and SECRET_KEY.

Testing

Server Tests

To run the pytest tests, use the following command:

ENVIRONMENT=TEST pytest --ignore=tests/selenium

User Interface Selenium Tests

To run the Selenium tests, use the following command:

pytest tests/selenium/

For the Selenium user interface tests to work, you will need to do the following:

  • Install Firefox
  • Install the geckodriver used by Selenium: brew install geckodriver
  • Run sbr-ui, making sure to pass in USE_FAKE_DATA=True

If you want to run the Selenium tests in headless mode, pass in SELENIUM_HEADLESS=True.

Test Coverage

To generate test coverage using pytest-cov, use the following command:

ENVIRONMENT=TEST pytest --cov-report html --cov=sbr_ui --ignore=tests/selenium

Coverage reports are saved to ./htmlcov. Open ./htmlcov/index.html in a browser to inspect the results.

Dependencies

Troubleshooting

If your updates to static files aren't registering, reset the cache (shift + press refresh in Chrome).

Contributing

See CONTRIBUTING for details.

License

Copyright ยฉโ€Ž 2018, Office for National Statistics (https://www.ons.gov.uk)

Released under MIT license, see LICENSE for details.

sbr-ui's People

Contributors

ons-tom avatar

Stargazers

Paul Wetherill avatar Tom Cooling avatar

Watchers

James Cloos avatar Ameen avatar Steven Thorne avatar Karen (Gask) Walker avatar Richard Smith avatar George Rushton avatar Paul Joel avatar Tom Cooling avatar  avatar Andy Urquhart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.