Ejemplo n.º 1
0
def test_dockerfile_os_selection(browser):
    """
    | Tests the content of the dockerfile based on OS selections

    :param webdriver browser: The browser instance from the webdriver
    :raises AssertionError: If the content of the dockerfile is not as expected
    :return: None
    """
    browser.refresh()
    # selecting CentOS
    system_select = Select(explicit_wait_visibility(browser, locators.SYSTEM_DROPDOWN))
    system_select.select_by_visible_text('CentOS')
    # try with CentOS
    download_button = explicit_wait_visibility(browser, locators.DOWNLOAD_BUTTON)
    download_button.click()
    content = read_dockerfile_content()
    assert 'FROM educloud:centOS' in content, 'The selected OS was not found in the Dockerfile!'
    clean_download()
    # try with Ubuntu
    system_select.select_by_visible_text('Ubuntu')
    download_button.click()
    content = read_dockerfile_content()
    assert 'FROM educloud:ubuntu' in content, 'The selected OS was not found in the Dockerfile!'
    assert 'FROM educloud:centOS' not in content, 'An OS which was not selected was found in the Dockerfile!'
    clean_download()
Ejemplo n.º 2
0
def test_dockerfile_port(browser):
    """
    | Tests the content of the dockerfile based on the exposed port

    :param webdriver browser: The browser instance from the webdriver
    :raises AssertionError: If the content of the dockerfile is not as expected
    :return: None
    """
    browser.refresh()
    port_input = explicit_wait_visibility(browser, locators.PORT_INPUT)
    download_button = explicit_wait_visibility(browser, locators.DOWNLOAD_BUTTON)
    # change the port number to 8329
    port_input.clear()
    port_input.send_keys(8329)
    download_button.click()
    content = read_dockerfile_content()
    assert 'EXPOSE 8329' in content, 'The set port was not found in the Dockerfile!'
    assert 'EXPOSE 8080' not in content, 'The default port was found in the Dockerfile!'
    clean_download()
    # try with port 1234
    port_input.clear()
    port_input.send_keys(1234)
    download_button.click()
    content = read_dockerfile_content()
    assert 'EXPOSE 1234' in content, 'The set port was not found in the Dockerfile!'
    assert 'EXPOSE 8080' not in content, 'The default port was found in the Dockerfile!'
    clean_download()
    # check now with default port 8080
    port_input.clear()
    download_button.click()
    content = read_dockerfile_content()
    assert 'EXPOSE 8080' in content, 'The default port was not found in the Dockerfile!'
    clean_download()
Ejemplo n.º 3
0
def test_dockerfile_module_selection(browser):
    """
    | Tests the content of the dockerfile based on module selections

    :param webdriver browser: The browser instance from the webdriver
    :raises AssertionError: If the content of the dockerfile is not as expected
    :return: None
    """
    browser.refresh()
    # define the expected of each module set
    standard_expected = ('RUN pip3 install requests scrapy wxpython pillow sqlalchemy beautifulsoup '
                         'twisted numpy scipy matplotlib pygame pyglet pyqt pygtk scapy pywin32 '
                         'nltk nose sympy ipython')
    data_science_expected = ('RUN pip3 install numpy thano keras pytorch scipy pandas pybrain '
                             'scikit-learn matplotlib tensorflow seaborn bokeh plotly nltk '
                             'gensim scrapy3 statsmodels kivy pyqt opencv')
    machine_learning_expected = ('RUN pip3 install tensorflow scikit-learn numpy Keras pytorch '
                                 'torchvision lightgbm eli5 scipy Theano pandas')
    mathematics_expected = ('RUN pip3 install numpy pandas scipy matplotlib patsy sympy plotly '
                            'statsmodels adipy matalg27 mlpstyler')
    module_select = Select(explicit_wait_visibility(browser, locators.MODULE_SET_DROPDOWN))
    # try with Data Science module set
    module_select.select_by_visible_text('Data Science')
    download_button = explicit_wait_visibility(browser, locators.DOWNLOAD_BUTTON)
    download_button.click()
    first_content = read_dockerfile_content()  # get the dockerfile content
    assert data_science_expected in first_content, 'The Data Science module set was not found in the Dockerfile!'
    assert standard_expected not in first_content
    assert machine_learning_expected not in first_content
    assert mathematics_expected not in first_content
    clean_download()
    # try the same with Standard module set
    module_select.select_by_visible_text('Standard')
    download_button.click()
    second_content = read_dockerfile_content()
    assert standard_expected in second_content, 'The Standard module set was not found in the Dockerfile!'
    assert data_science_expected not in second_content
    assert machine_learning_expected not in second_content
    assert mathematics_expected not in second_content
    clean_download()
    # try the same with Mathematics module set
    module_select.select_by_visible_text('Mathematics')
    download_button.click()
    third_content = read_dockerfile_content()
    assert mathematics_expected in third_content, 'The Mathematics module set was not found in the Dockerfile!'
    assert data_science_expected not in third_content
    assert standard_expected not in third_content
    assert machine_learning_expected not in third_content
    clean_download()
    # try the same with Machine Learning module set
    module_select.select_by_visible_text('Machine Learning')
    download_button.click()
    fourth_content = read_dockerfile_content()
    assert machine_learning_expected in fourth_content, ('The Machine Learning module set was not found '
                                                         'in the Dockerfile!')
    assert data_science_expected not in fourth_content
    assert standard_expected not in fourth_content
    assert mathematics_expected not in fourth_content
    clean_download()
Ejemplo n.º 4
0
def test_dockerfile_sudo_access(browser):
    """
    | Tests the content of the dockerfile based on the Sudo Access selection

    :param webdriver browser: The browser instance from the webdriver
    :raises AssertionError: If the content of the dockerfile is not as expected
    :return: None
    """
    browser.refresh()
    sudo_input = explicit_wait_visibility(browser, locators.pass_checkbox('User has Sudo Access'))
    download_button = explicit_wait_visibility(browser, locators.DOWNLOAD_BUTTON)
    download_button.click()
    first_content = read_dockerfile_content()
    assert 'sudo usermod' not in first_content, 'Sudo could be found in the Dockerfile!'
    clean_download()
    sudo_input.click()  # tick the checkbox of Sudo Access on
    download_button.click()
    second_content = read_dockerfile_content()
    assert 'sudo usermod' in second_content, 'Sudo could not be found in the Dockerfile!'
    clean_download()
Ejemplo n.º 5
0
def test_dockerfile_packages(browser):
    """
    | Tests the content of the dockerfile based on Debian/Ubuntu package selections

    :param webdriver browser: The browser instance from the webdriver
    :raises AssertionError: If the content of the dockerfile is not as expected
    :return: None
    """
    browser.refresh()
    # find required elements
    libbz_input = explicit_wait_visibility(browser, locators.pass_checkbox('libbz2'))
    automake_input = explicit_wait_visibility(browser, locators.pass_checkbox('automake'))
    download_button = explicit_wait_visibility(browser, locators.DOWNLOAD_BUTTON)
    new_package_input = explicit_wait_visibility(browser, locators.NEW_PACKAGE_INPUT)
    plus_button = explicit_wait_visibility(browser, locators.NEW_PACKAGE_PLUS_BUTTON)
    # make selections
    libbz_input.click()
    automake_input.click()
    download_button.click()
    content = read_dockerfile_content()
    assert 'libbz2' in content, 'Libbz2 was not found in the Dockerfile!'
    assert 'automake' in content, 'Automake was not found in the Dockerfile!'
    clean_download()
    # undo selections
    libbz_input.click()
    automake_input.click()
    download_button.click()
    content = read_dockerfile_content()
    assert 'libbz2' not in content, 'Libbz2 was found in the Dockerfile!'
    assert 'automake' not in content, 'Automake was found in the Dockerfile!'
    clean_download()
    # create new input field
    new_package_input.send_keys('abcdefg')
    plus_button.click()
    new_package_input.send_keys('donotreadthis')
    plus_button.click()
    download_button.click()
    content = read_dockerfile_content()
    assert 'abcdefg' in content, 'The new package abcdefg was not found in the Dockerfile!'
    assert 'donotreadthis' in content, 'The new package donotreadthis was not found in the Dockerfile!'
    clean_download()
Ejemplo n.º 6
0
def test_advanced_mode_dockerfile(browser):
    """
    | Tests the content of the dockerfile based on the advanced mode manual changes

    :param webdriver browser: The browser instance from the webdriver
    :raises AssertionError: If the content of the dockerfile is not as expected
    :return: None
    """
    browser.refresh()
    advanced_button = explicit_wait_visibility(browser, locators.ADVANCED_BUTTON)
    download_button = explicit_wait_visibility(browser, locators.DOWNLOAD_BUTTON)
    download_button.click()  # download dockerfile
    content = read_dockerfile_content()
    assert 'I can see you' not in content, 'Content of the Dockerfile was not as expected!'
    clean_download()
    advanced_button.click()  # open the advanced mode
    preview_input = explicit_wait_visibility(browser, locators.PREVIEW_INPUT)
    preview_input.send_keys('\nI can see you')  # change the preview content
    download_button.click()
    content = read_dockerfile_content()  # new content expected now
    assert 'I can see you' in content, 'Content of the Dockerfile after advanced changes was not as expected!'