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

Use Python's properties mechanism on AlertElement #95

Closed
erik-whiting opened this issue Sep 4, 2022 · 1 comment
Closed

Use Python's properties mechanism on AlertElement #95

erik-whiting opened this issue Sep 4, 2022 · 1 comment

Comments

@erik-whiting
Copy link
Owner

Overview

I want to use Python's property construct on the attributes for is_page_element and is_alert_element within the BaseElement sub classes.

Reasoning

Properties let you set getters and setters on attributes. This promotes the idea of encapsulation and is generally considered good practice. In this specific case, I don't want developers to be able to change the value of is_page_element or is_alert_element. A PageElement is always a page element, no matter what, so the setter will hijack any attempts to change those values and simply return false when someone tries to set those values.

This particular issue is for a specific user who said they wanted to get started with open-source. Please don't pick up this issue unless you are Ujjwal.

Step-by-Step Guide

To make this contribution, please follow these steps:

Clone the Repository

The first thing you want to do is get this code onto your local computer. You can do this by running the following command:

$> git@github.com:erik-whiting/LuluTest.git

Note, the $> represents your terminal prompt, it is not actually part of the command you need to run

Make a new Branch

Now that you've cloned the code, you need to make a new branch. CD into the project with

$> cd LuluTest

and create a new branch. This will make all the work you do independent of the development branch until I merge it. Here's a good article about branches in git.

Let's call our branch add-properties-to-alert-element. To create and checkout this branch, run the following command:

$> git checkout -b add-properties-to-alert-element

Make the Code Changes

Now that you've made a new branch, you can start making changes to the code. You will want to work on the AlertElement class. This class is defined in LuluTest/element/alert_element.py. You need to make changes that are nearly identical to the equivalent pull request for PageElement. Look at the files changed in that pull request and do almost the same thing to AlertElement.

Commit Your Changes

Once you're done with the code changes, it's time to commit the changes. You'll do this by running the following command:

$> git commit -am "Some commit message"

Make your commit message a broad statement about what you did. Something like "Add properties to AlertElement".

Push Branch and Create Pull Request

The next thing you have to do is submit your changes for review. This involves pushing your branch to the repository and then making a pull request out of it. To push the branch, run the following command:

$> git push --set-upstream origin add-properties-to-alert-element

Once the branch has been pushed, go to the repository's homepage (https://github.com/erik-whiting/LuluTest) and you should see a prompt with a green button that says "Create pull request." Press that button and follow along.

Await Review

Once you've made a pull-request, I will be alerted that someone wants to merge their work into the repository. I will look it over and if everything is good, I will merge it into the development branch and you will have officially made your first contribution, congratulations!

Usually, you will have to fix any failing automated tests or other PR checks but this repository is currently a little disorganized and its tests are failing for a bunch of unrelated reasons. I plan to fix that in the coming weeks but for now, just ignore the failing tests.

@erik-whiting
Copy link
Owner Author

Closed by #94 and #97

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