Skip to content

Commit

Permalink
fix(#75): Test changes to fix GitHub Actions bugs
Browse files Browse the repository at this point in the history
Tests run by GitHub Actions were not correctly accessing the value of the user password environment variable.
A user has been added in the initial.json file for tests that require login.
Remove an environment variable from the Github Actions file as it will no longer be used.
  • Loading branch information
mrarjona committed Dec 8, 2022
1 parent de02868 commit 8ff78ae
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
PRODUCTION_DB_USER: ${{ secrets.PRODUCTION_DB_USER }}
PRODUCTION_DB_PASSWORD: ${{ secrets.PRODUCTION_DB_PASSWORD }}
USER_PASSWORD: ${{ secrets.USER_PASSWORD }}

jobs:
build:
Expand Down
19 changes: 19 additions & 0 deletions fixtures/initial.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@
"user_permissions": []
}
},
{
"model": "participant.participant",
"pk": 7,
"fields": {
"password": "pbkdf2_sha256$390000$K7C37FYo1xl58LFBYZvX3x$0RUW6QalTkM5uE7xHlhSFegJUJv6t9t+sA9BsVWxoyw=",
"last_login": null,
"is_superuser": false,
"username": "userTest",
"is_staff": false,
"is_active": true,
"date_joined": "2022-12-08T20:28:49.431Z",
"first_name": "User",
"last_name": "Test",
"email": "[email protected]",
"photo": "http://cdn.onlinewebfonts.com/svg/img_569204.png",
"groups": [],
"user_permissions": []
}
},
{
"model": "event.event",
"pk": 1,
Expand Down
23 changes: 10 additions & 13 deletions innoweb/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
from score.models import Score
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
from decouple import config

USER_PASSWORD = config('USER_PASSWORD')

class HomeViewTest(StaticLiveServerTestCase):
fixtures = ['fixtures/initial.json']
Expand Down Expand Up @@ -131,8 +128,8 @@ def tearDownClass(cls):

def test_login_success(self):

username = "tomcambor"
password = USER_PASSWORD
username = "userTest"
password = "Testpassword17"
PORT = self.live_server_url.split(":")[2]
self.browser.get(self.live_server_url)
self.browser.get("http://localhost:" + PORT + "/login")
Expand All @@ -149,7 +146,7 @@ def test_login_success(self):

def test_login_username_fail(self):
username = "incorrectusername"
password = USER_PASSWORD
password = "Testpassword17"
PORT = self.live_server_url.split(":")[2]
self.browser.get(self.live_server_url)
self.browser.get("http://localhost:" + PORT + "/login")
Expand All @@ -164,7 +161,7 @@ def test_login_username_fail(self):
assert len(self.browser.find_elements("id","error-form")) == 1

def test_login_password_fail(self):
username = "tomcambor"
username = "userTest"
password = "incorrectpassword"
PORT = self.live_server_url.split(":")[2]
self.browser.get(self.live_server_url)
Expand Down Expand Up @@ -196,8 +193,8 @@ def tearDownClass(cls):
super(EventViewTest, cls).tearDownClass()

def test_register_event(self):
username = "tomcambor"
password = USER_PASSWORD
username = "userTest"
password = "Testpassword17"
PORT = self.live_server_url.split(":")[2]
self.browser.get(self.live_server_url)
self.browser.get("http://localhost:" + PORT + "/login")
Expand All @@ -217,8 +214,8 @@ def test_register_event(self):
assert self.browser.find_element(By.CLASS_NAME,"alert-success").is_enabled() == True

def test_register_event_already_registered(self):
username = "tomcambor"
password = USER_PASSWORD
username = "userTest"
password = "Testpassword17"
PORT = self.live_server_url.split(":")[2]
self.browser.get(self.live_server_url)
self.browser.get("http://localhost:" + PORT + "/login")
Expand Down Expand Up @@ -266,8 +263,8 @@ def tearDownClass(cls):
super(ProfileViewTest, cls).tearDownClass()

def test_next_events_are_shown(self):
username = "tomcambor"
password = USER_PASSWORD
username = "userTest"
password = "Testpassword17"
PORT = self.live_server_url.split(":")[2]
self.browser.get(self.live_server_url)
self.browser.get("http://localhost:" + PORT + "/login")
Expand Down

0 comments on commit 8ff78ae

Please sign in to comment.