Skip to content

Commit

Permalink
Fix Playwright locators in test
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Dec 22, 2023
1 parent a2eb6f1 commit 75c7272
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pcloud-test.yml
Expand Up @@ -57,6 +57,6 @@ jobs:
-Dsonar.organization=tomgross-github
-Dsonar.python.version=3
-Dsonar.python.coverage.reportPaths=coverage.xml
-Dsonar.python.coverage.exclusions=**/tests/**/*
-Dsonar.python.coverage.exclusions=**/tests/*


2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -48,7 +48,7 @@
install_requires=[
"requests",
"requests-toolbelt",
"setuptools"
"setuptools>=68.0.0"
],
extras_require={"pyfs": ["fs"]},
entry_points={
Expand Down
4 changes: 2 additions & 2 deletions src/pcloud/oauth2.py
Expand Up @@ -59,12 +59,12 @@ def get_access_token(self):
http_server = HTTPServerWithAttributes(("localhost", PORT), HTTPServerHandler)

def start_server():
http_server.serve_forever()
http_server.handle_request()

_thread.start_new_thread(start_server, ())
self.open_browser()
while not (http_server.access_token and http_server.pc_hostname):
time.sleep(1)
self.close_browser()
http_server.shutdown()
http_server.server_close()
return http_server.access_token, http_server.pc_hostname
17 changes: 12 additions & 5 deletions src/pcloud/tests/test_api.py
Expand Up @@ -53,6 +53,9 @@ def test_getfolderpublink():

@pytest.mark.usefixtures("start_mock_server")
class TestPcloudApi(object):

noop_dummy_file = "/test.txt"

def test_getdigest(self):
api = DummyPyCloud("foo", "bar")
assert api.getdigest() == b"YGtAxbUpI85Zvs7lC7Z62rBwv907TBXhV2L867Hkh"
Expand Down Expand Up @@ -89,27 +92,27 @@ def test_extractarchive(self):
def test_getfilelink(self):
papi = DummyPyCloud("foo", "bar")
with pytest.raises(api.OnlyPcloudError):
papi.getfilelink(file="/test.txt")
papi.getfilelink(file=self.noop_dummy_file)

def test_getvideolink(self):
papi = DummyPyCloud("foo", "bar")
with pytest.raises(api.OnlyPcloudError):
papi.getvideolink(file="/test.txt")
papi.getvideolink(file=self.noop_dummy_file)

def test_getvideolinks(self):
papi = DummyPyCloud("foo", "bar")
with pytest.raises(api.OnlyPcloudError):
papi.getvideolinks(file="/test.txt")
papi.getvideolinks(file=self.noop_dummy_file)

def test_getfilepublink(self):
papi = DummyPyCloud("foo", "bar")
with pytest.raises(api.OnlyPcloudError):
papi.getfilepublink(file="/test.txt")
papi.getfilepublink(file=self.noop_dummy_file)

def test_getpublinkdownload(self):
papi = DummyPyCloud("foo", "bar")
with pytest.raises(api.OnlyPcloudError):
papi.getpublinkdownload(file="/test.txt")
papi.getpublinkdownload(file=self.noop_dummy_file)

def test_server_security(self):
api = DummyPyCloud("", "")
Expand All @@ -127,3 +130,7 @@ def test_write(self, capsys):
fs_f.write(data)
captured = capsys.readouterr()
assert captured.out == "File: b'hello pcloud fs unittest', Size: 24"

def test_repr(self):
with DummyPCloudFS(username="foo", password="bar") as fs:
assert repr(fs) == "<pCloudFS>"
4 changes: 2 additions & 2 deletions src/pcloud/tests/test_oauth2.py
Expand Up @@ -25,9 +25,9 @@ def open_browser(self):
log.info(self.auth_url)
page.goto(self.auth_url)
page.get_by_placeholder("Email").fill(os.environ.get("PCLOUD_USERNAME"))
page.get_by_text("Continue").click()
page.get_by_text("Continue", exact=True).click()
page.get_by_placeholder("Password").fill(os.environ.get("PCLOUD_PASSWORD"))
page.get_by_text("Log in").click()
page.get_by_text("Login").click()
expect(page.get_by_text("You may now close this window.")).to_be_visible()


Expand Down

0 comments on commit 75c7272

Please sign in to comment.