def two_analyses_two_publications():
    surface1 = SurfaceFactory()
    Topography1DFactory(surface=surface1)
    surface2 = SurfaceFactory()
    Topography1DFactory(surface=surface2)
    pub1 = surface1.publish('cc0-1.0', surface1.creator.name)
    pub2 = surface2.publish('cc0-1.0', surface1.creator.name + ", " + surface2.creator.name)
    pub_topo1 = pub1.surface.topography_set.first()
    pub_topo2 = pub2.surface.topography_set.first()

    func = AnalysisFunctionFactory()
    AnalysisFunctionImplementationFactory(function=func)
    analysis1 = TopographyAnalysisFactory(subject=pub_topo1, function=func)
    analysis2 = TopographyAnalysisFactory(subject=pub_topo2, function=func)

    return analysis1, analysis2, pub1, pub2
Esempio n. 2
0
def test_how_to_cite(user_alice_logged_in, handle_usage_statistics):
    browser, user_alice = user_alice_logged_in

    #
    # Alice has a surface and publishes it
    #
    surface_name = "Diamond Structure"
    topo_name = "Diamond Cut"
    topo_description = "My nice measurement"

    surface = SurfaceFactory(creator=user_alice, name=surface_name)
    topo = Topography2DFactory(surface=surface,
                               name=topo_name,
                               description=topo_description)
    publication = surface.publish('cc0-1.0', 'Famous Scientist')

    # Alice filters for published surfaces - enters
    # "Select" tab and chooses "Only published surfaces"
    #
    base_url = browser.url
    goto_select_page(browser)

    assert num_items_in_result_table(
        browser) == 2  # both surfaces are visible by default

    select_sharing_status(browser, 'published')
    assert num_items_in_result_table(browser) == 1  # only published is visible

    data = data_of_item_by_name(browser, surface_name)
    assert data['version'] == "1 (2021-07-12)"
    assert data['authors'] == 'Famous Scientist'

    double_click_on_item_by_name(browser, surface_name)
    data = data_of_item_by_name(browser, topo_name)
    assert data['version'] == ""
    assert data['authors'] == ''
    assert data['description'] == topo_description

    # Alice opens the properties and sees
    # the "published by yo" badge.
    press_view_for_item_by_name(browser, surface_name)
    assert browser.is_text_present('published by you')

    #
    # Alice sees "How to cite" tab an chooses it
    #
    assert browser.is_text_present("How to cite")
    browser.links.find_by_partial_text("How to cite").click()

    # Now the page shows a citation in text format
    exp_pub_url = base_url.rstrip('/') + publication.get_absolute_url()
    exp_citation = f"Famous Scientist. ({publication.datetime.year}). contact.engineering. {surface_name} (Version 1). " + \
                   f"{exp_pub_url}"
    assert browser.is_text_present(exp_citation)
Esempio n. 3
0
def example_pub():
    """Fixture returning a publication which can be used as test example"""

    user = UserFactory()

    authors = "Alice, Bob"
    publication_date = datetime.date(2020, 1, 1)
    description = "This is a nice surface for testing."
    name = "Diamond Structure"

    surface = SurfaceFactory(name=name, creator=user, description=description)
    surface.tags = ['diamond']

    with freeze_time(publication_date):
        pub = surface.publish('cc0-1.0', authors)

    return pub
Esempio n. 4
0
def test_switch_between_wip_and_version(user_alice_logged_in,
                                        handle_usage_statistics):
    browser, user_alice = user_alice_logged_in

    #
    # Alice has a surface and publishes it
    #
    surface = SurfaceFactory(creator=user_alice, name="Alice's Surface")
    topo = Topography2DFactory(surface=surface)
    publication = surface.publish('cc0-1.0', 'Alice')

    #
    # When browsing to the surface, the current surface is shown as "Work in progress"
    #
    goto_select_page(browser)
    press_view_for_item_by_name(browser, surface.name)

    assert browser.is_text_present("Work in progress")
    assert not browser.is_text_present("Version 1")

    # She could edit, if she wanted
    assert browser.is_text_present("Edit meta data")

    #
    # Switching to version 1
    #
    versions_btn = browser.find_by_id('versions-btn')
    versions_btn.click()
    versions_dropdown = browser.find_by_id('versions-dropdown')
    version_links = versions_dropdown.find_by_tag('a')

    assert "Work in progress" in version_links[0].text
    assert "Version 1" in version_links[1].text

    version_links[1].click()

    assert browser.is_text_present(f"{publication.surface.label}", wait_time=1)

    #
    # Alice should be on the page of the new version
    #
    assert publication.surface.get_absolute_url() in browser.url

    # She cannot edit
    assert not browser.is_text_present("Edit meta data")

    #
    # Alice can switch back to editable version (work in progress)
    #
    versions_btn = browser.find_by_id('versions-btn')
    versions_btn.click()
    versions_dropdown = browser.find_by_id('versions-dropdown')
    version_links = versions_dropdown.find_by_tag('a')

    assert "Work in progress" in version_links[0].text
    assert "Version 1" in version_links[1].text

    version_links[0].click()

    assert browser.is_text_present(f"{publication.original_surface.label}",
                                   wait_time=1)
    assert publication.original_surface.get_absolute_url() in browser.url

    assert browser.is_text_present("Edit meta data")
Esempio n. 5
0
def test_see_published_by_others(user_alice_logged_in, user_bob,
                                 handle_usage_statistics, settings):
    browser, user_alice = user_alice_logged_in

    # switch off checks for too fast publication
    settings.MIN_SECONDS_BETWEEN_SAME_SURFACE_PUBLICATIONS = None

    #
    # Alice has a surface, which is not published
    #
    SurfaceFactory(creator=user_alice, name="Alice's Surface")

    #
    # User Bob publishes a surface (here in the background)
    #
    surface_name = "Bob has published this"
    surface_description = "Valuable results."
    surface = SurfaceFactory(creator=user_bob,
                             name=surface_name,
                             description=surface_description)
    Topography2DFactory(surface=surface)
    publication = surface.publish('cc0-1.0', 'Bob')

    # Alice filters for published surfaces - enters
    # "Select" tab and chooses "Only published surfaces"
    #
    goto_select_page(browser)

    assert num_items_in_result_table(
        browser) == 2  # both surfaces are visible by default

    select_sharing_status(browser, 'published')
    assert num_items_in_result_table(browser) == 1  # only published is visible

    # Bobs surface is visible as only surface.
    # The version number is "1".
    data = data_of_item_by_name(browser, surface_name)
    assert data['description'] == surface_description
    assert data['version'] == "1 (2021-07-12)"

    # Alice opens the properties and sees
    # the "published by Bob" badge.
    press_view_for_item_by_name(browser, surface_name)
    assert browser.is_text_present('published by Bob Marley')

    # She opens the permissions and sees that Everyone has read permissions
    # and nothing else.
    # The individual names are NOT listed.
    assert_only_permissions_everyone(browser)

    #
    # She sees a dropdown with only this version
    #
    assert browser.is_text_present('Version 1')
    assert not browser.is_text_present('Version 2')

    #
    # Bob publishes again, Alice reloads the page
    #
    publication = surface.publish('cc0-1.0', 'Bob')
    browser.reload()

    #
    # Now also the second version is visible
    #
    assert browser.is_text_present('Version 1')
    assert not browser.is_text_present('Version 2')

    #
    # Alice can switch to the new version
    #
    versions_btn = browser.find_by_id('versions-btn')
    versions_btn.click()
    versions_dropdown = browser.find_by_id('versions-dropdown')
    version_links = versions_dropdown.find_by_tag('a')

    assert "Version 1" in version_links[0].text
    assert "Version 2" in version_links[1].text

    version_links[1].click()

    assert browser.is_text_present(f"{publication.original_surface.label}",
                                   wait_time=1)

    #
    # Alice should be on the page of the new version
    #
    assert publication.surface.get_absolute_url() in browser.url