Skip to content

Add a test which really does add a database #16

@adamtheturtle

Description

@adamtheturtle

Initial test:

"""
This creates 100 licenses and databases.

If this passes around ~20 times we can be confident that at least most of our
tool works.
"""

import os
import uuid
import json
from datetime import date
from pathlib import Path

import vws_web_tools

from selenium import webdriver

def main():
    # TODO use GitHub secrets for this.
    email_address = os.environ['VWS_EMAIL_ADDRESS']
    password = os.environ['VWS_PASSWORD']
    # Short to not hit the max length of the license.
    random = uuid.uuid4().hex[:5]
    today_date = str(date.today())
    output_file_path = Path(f'databases_details_{random}.txt')
    license_name_start = f'license-ci-{today_date}-{random}-'
    database_name_start = f'database-ci-{today_date}-{random}-'
    # We need chromedriver.
    # On macOS: brew install chromedriver
    driver = webdriver.Chrome()

    vws_web_tools.log_in(
        driver=driver,
        email_address=email_address,
        password=password,
    )

    for index in range(100):
        license_name = license_name_start + str(index)
        database_name = database_name_start + str(index)
        vws_web_tools.create_license(driver=driver, license_name=license_name)
        vws_web_tools.create_database(
            driver=driver,
            database_name=database_name,
            license_name=license_name,
        )

        details = vws_web_tools.get_database_details(
            driver=driver,
            database_name=database_name,
        )

       # TODO verify that none of the database details are empty

        with output_file_path.open('a') as output_file:
            output_file.write(json.dumps(details))
            output_file.write('\n')

    driver.close()

if __name__ == '__main__':
    main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions