diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 7e42feaf..b82a0f32 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -16,10 +16,10 @@ on: branches: [master, testing] jobs: - build: + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v1 with: node-version: '16' diff --git a/.github/workflows/flask.yml b/.github/workflows/flask.yml index ec42536f..43fbe8e7 100644 --- a/.github/workflows/flask.yml +++ b/.github/workflows/flask.yml @@ -32,12 +32,12 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.7] + python-version: [3.9] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} cache: 'pip' @@ -49,10 +49,6 @@ jobs: python -m pip install --upgrade pip pip install flake8 pytest coverage pip install -r requirements.txt - pip install -e . - mkdir bin - wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz - tar xf geckodriver-v0.30.0-linux64.tar.gz -C bin/ - name: Prepare database env: @@ -66,17 +62,6 @@ jobs: psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION citext SCHEMA public;" psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pg_trgm SCHEMA public;" - - name: Selenium tests - env: - SECRET_KEY: 'f00046306835001b55c230092e3a7990485beda0bc3bf732088d1ba1b5b74110e22e3f9ec3a24890272554b37d4' - DB_DATABASE: dh_test - FLASK_APP: examples/app.py - dhi: dbtest - run: | - alembic -x inventory=dbtest upgrade head - dh dummy --yes - flask run & pytest tests/test_selenium.py - - name: Lint with flake8 run: | # stop the build if: diff --git a/.github/workflows/selenium.yml b/.github/workflows/selenium.yml new file mode 100644 index 00000000..f9209484 --- /dev/null +++ b/.github/workflows/selenium.yml @@ -0,0 +1,78 @@ +name: Selenium + +on: + push: + branches: [master, testing] + pull_request: + branches: [master, testing] + +jobs: + build: + runs-on: ubuntu-latest + + # Service containers to run with `container-job` + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres:11 + ports: + - 5432:5432 + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_DB: dh_test + POSTGRES_USER: dhub + POSTGRES_PASSWORD: ereuse + + strategy: + max-parallel: 4 + matrix: + python-version: [3.9] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install dependencies + run: | + sudo apt-get update -qy + sudo apt-get -y install postgresql-client --no-install-recommends + python -m pip install --upgrade pip + pip install flake8 pytest coverage + pip install -r requirements.txt + pip install -e . + mkdir bin + wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz + tar xf geckodriver-v0.30.0-linux64.tar.gz -C bin/ + + - name: Prepare database + env: + POSTGRES_DB: dh_test + POSTGRES_USER: dhub + POSTGRES_PASSWORD: ereuse + run: | + export PGPASSWORD=$POSTGRES_PASSWORD + psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pgcrypto SCHEMA public;" + psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION ltree SCHEMA public;" + psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION citext SCHEMA public;" + psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pg_trgm SCHEMA public;" + + - name: Selenium tests + env: + SECRET_KEY: 'f00046306835001b55c230092e3a7990485beda0bc3bf732088d1ba1b5b74110e22e3f9ec3a24890272554b37d4' + DB_DATABASE: dh_test + FLASK_APP: examples/app.py + dhi: dbtest + run: | + alembic -x inventory=dbtest upgrade head + dh dummy --yes + flask run & pytest tests/test_selenium.py diff --git a/CHANGELOG.md b/CHANGELOG.md index e4f819c9..218a97ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,21 +5,33 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.ht ml). -## master - ## testing -- [add] #281 add selenium test. -- [add] #305 add button download iso Workbench. -- [add] #306 add link for download json snapshot. -- [add] #308 add sentry. -- [changed] #302 add system uuid for check the identity of one device. -- [fixed] #309 column lifecycle status is always empty. +- [added] #312 Placeholder: new, edit, update. (manually and with excel). + +## [2.3.0] - 2022-07-12 +- [added] #281 Add selenium test. +- [added] #305 Add button to download ISO Workbench. +- [added] #306 Add link to download JSON snapshot. +- [added] #308 Add sentry. +- [changed] #302 Add system uuid to check the identity of one device. +- [fixed] #309 Column lifecycle status is always empty. + +**IMPORTANT**: PR #302 involves some changes in the deployment process: +```bash +# First, run script `extract_uuids.sh` before applying alembic migrations (e.g. with schema `dbtest`) +sh scripts/extract_uuids.sh + +# Then, apply alembic migrations +alembic -x inventory=dbtest upgrade head +``` + +**NOTE**: If you forget (or don't need) to run this script before applying new migration it will work but any device will be updated. ## [2.2.0] - 2022-06-24 - [changed] #304 change anchor of link devices lots. ## [2.2.0 rc2] - 2022-06-22 -- [added] #299 Multy select with Shift. +- [added] #299 Multiselect with Shift. - [added] #300 Add Sid in label. - [added] #301 Add logo in label. - [added] #303 Add export Lots. @@ -160,17 +172,3 @@ First server render HTML version. Completely rewrites views of angular JS client - [added] #83 add owner_id in all kind of device - [fixed] #89 save json on disk only for shapshots - [fixed] #91 The most old time allow is 1970-01-01 - - -# Release notes - -## [2.2.1] -The pr #302 involves some changes in the deployment process -For to do the deployment you need to do run the script extract_uuids.sh before to run alembic. -This is the correct secuence if the schema of you proyect is *dbtest* -``` -git pull -sh examples/extract_uuids.sh -alembic -x inventory=dbtest upgrade head -``` -If you forget to run this script the migration is do it but not modify any device data. diff --git a/ereuse_devicehub/__init__.py b/ereuse_devicehub/__init__.py index 8a124bf6..55e47090 100644 --- a/ereuse_devicehub/__init__.py +++ b/ereuse_devicehub/__init__.py @@ -1 +1 @@ -__version__ = "2.2.0" +__version__ = "2.3.0" diff --git a/ereuse_devicehub/parser/computer.py b/ereuse_devicehub/parser/computer.py index a6993c04..afd2e17d 100644 --- a/ereuse_devicehub/parser/computer.py +++ b/ereuse_devicehub/parser/computer.py @@ -94,7 +94,7 @@ class Processor(Component): assert not hasattr(self, 'cores') or 1 <= self.cores <= 16 @staticmethod # noqa: C901 - def processor_brand_generation(model: str): + def processor_brand_generation(model: str): # noqa: C901 """Generates the ``brand`` and ``generation`` fields for the given model. This returns a tuple with: diff --git a/examples/app.py b/examples/app.py index 690ff9f9..3a6a25a6 100644 --- a/examples/app.py +++ b/examples/app.py @@ -5,9 +5,9 @@ Use this as a starting point. """ import sentry_sdk from decouple import config -from flask_wtf.csrf import CSRFProtect + +# from flask_wtf.csrf import CSRFProtect from sentry_sdk.integrations.flask import FlaskIntegration -from werkzeug.contrib.profiler import ProfilerMiddleware from ereuse_devicehub.api.views import api from ereuse_devicehub.config import DevicehubConfig @@ -17,6 +17,9 @@ from ereuse_devicehub.labels.views import labels from ereuse_devicehub.views import core from ereuse_devicehub.workbench.views import workbench +# from werkzeug.contrib.profiler import ProfilerMiddleware + + SENTRY_DSN = config('SENTRY_DSN', None) if SENTRY_DSN: sentry_sdk.init( @@ -41,10 +44,10 @@ app.register_blueprint(workbench) # configure & enable CSRF of Flask-WTF # NOTE: enable by blueprint to exclude API views # TODO(@slamora: enable by default & exclude API views when decouple of Teal is completed -csrf = CSRFProtect(app) +# csrf = CSRFProtect(app) # csrf.protect(core) # csrf.protect(devices) -app.config["SQLALCHEMY_RECORD_QUERIES"] = True -app.config['PROFILE'] = True -app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30]) -app.run(debug=True) +# app.config["SQLALCHEMY_RECORD_QUERIES"] = True +# app.config['PROFILE'] = True +# app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30]) +# app.run(debug=True) diff --git a/examples/extract_uuid.py b/scripts/extract_uuid.py similarity index 100% rename from examples/extract_uuid.py rename to scripts/extract_uuid.py diff --git a/examples/extract_uuids.sh b/scripts/extract_uuids.sh similarity index 100% rename from examples/extract_uuids.sh rename to scripts/extract_uuids.sh diff --git a/tests/test_basic.py b/tests/test_basic.py index bb9196a2..4e81a709 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -72,6 +72,10 @@ def test_api_docs(client: Client): '/inventory/tag/devices/add/', '/inventory/tag/devices/{id}/del/', '/inventory/upload-snapshot/', + '/inventory/device/edit/{id}/', + '/inventory/upload-placeholder/', + '/inventory/lot/{lot_id}/upload-placeholder/', + '/inventory/placeholder-logs/', '/labels/', '/labels/add/', '/labels/print', diff --git a/tests/test_selenium.py b/tests/test_selenium.py index 33cd8c79..948e947e 100644 --- a/tests/test_selenium.py +++ b/tests/test_selenium.py @@ -42,10 +42,12 @@ class TestSelenium: lot_id = self.driver.current_url.split("/")[5] # go to unassigned - self.driver.find_element(By.CSS_SELECTOR, ".nav-item:nth-child(5) span").click() + # self.driver.find_element(By.CSS_SELECTOR, ".nav-item:nth-child(5) span").click() + self.driver.find_element(By.CSS_SELECTOR, ".nav-item:nth-child(7) span").click() self.driver.implicitly_wait(3) # select the first device + self.driver.find_element( By.CSS_SELECTOR, "tr:nth-child(1) .deviceSelect" ).click() @@ -95,10 +97,14 @@ class TestSelenium: self.driver.find_element(By.ID, "SaveAllActions").click() time.sleep(3) - self.driver.find_element(By.CSS_SELECTOR, ".nav-item:nth-child(5) span").click() + # self.driver.find_element(By.CSS_SELECTOR, ".nav-item:nth-child(5) span").click() + self.driver.find_element(By.CSS_SELECTOR, ".nav-item:nth-child(7) span").click() self.driver.implicitly_wait(3) # logout + # self.driver.find_element(By.CSS_SELECTOR, ".d-md-block:nth-child(2)").click() self.driver.find_element(By.CSS_SELECTOR, ".d-md-block:nth-child(2)").click() - self.driver.implicitly_wait(3) - self.driver.find_element(By.LINK_TEXT, "Sign Out").click() + self.driver.find_element(By.CSS_SELECTOR, "li:nth-child(9) > .dropdown-item > span").click() + # self.driver.find_element(By.CSS_SELECTOR, ".d-md-block").click() + # self.driver.implicitly_wait(3) + # self.driver.find_element(By.LINK_TEXT, "Sign Out").click()