Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test which really does add a database #16

Open
adamtheturtle opened this issue Apr 19, 2021 · 0 comments
Open

Add a test which really does add a database #16

adamtheturtle opened this issue Apr 19, 2021 · 0 comments

Comments

@adamtheturtle
Copy link
Member

adamtheturtle commented Apr 19, 2021

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant