Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Test to ensure that user-profiles are working #29

Merged
merged 3 commits into from

5 participants

@bebef1987
Collaborator

can we add more straight to this test

assert that the articles shown are from that author
assert the name is present on the page title
etc.

pages/author.py
((5 lines not shown))
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+from base import BasePage
+
+
+class AuthorPage(BasePage):
+
+ _page_title = u"Posts by %s | QMO \u2013 quality.mozilla.org"
+
+ def go_to_author_page(self, author):
+ self.selenium.get(self.testsetup.base_url + '/author/' + author)
+
+ def __init__(self, testsetup, author):
+ BasePage.__init__(self, testsetup)
+ self._page_title = self._page_title % author
@klrmn Collaborator
klrmn added a note

why not save the author to self.author as part of init, so that you won't have to specify it in go_to_author_page, just take it from self.author

@teodosia Collaborator
teodosia added a note

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@klrmn klrmn commented on the diff
pages/author.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+from base import BasePage
+
+
+class AuthorPage(BasePage):
+
+ _page_title = u"Posts by %s | QMO \u2013 quality.mozilla.org"
@klrmn Collaborator
klrmn added a note

is is_the_current_page going to know how to fill in that %s?

@teodosia Collaborator
teodosia added a note

The %s is filled in the init

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@teodosia teodosia Code review update
save the author to self.author as part of init
7b79ce3
tests/test_profile.py
((7 lines not shown))
+
+import pytest
+from unittestzero import Assert
+
+from pages.author import AuthorPage
+
+
+class TestUserRegistration:
+
+ @pytest.mark.nondestructive
+ def test_that_accessing_author_profile_works(self, mozwebqa):
+ author_name = "rbillings"
+
+ author_page = AuthorPage(mozwebqa, author_name)
+ author_page.go_to_author_page()
+
@AlinT
AlinT added a note

blank line contains whitespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@AlinT

Beside the pep8 comment the pull looks good to me!
I only wonder if the Assert.greater is enough, or should we also test for other stuff on the author page?

@teodosia
Collaborator

@AlinT The title contains the name of the author and that is checked in is_the_current_page. The purpose of the test was to check that the page doesn't return Internal Server Error (bug 758285), but I'm happy to add other checks if that's needed.

@zacc

LGTM, I'll merge it in.

@zacc zacc merged commit b50d601 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 1, 2012
  1. @teodosia
Commits on Oct 4, 2012
  1. @teodosia

    Code review update

    teodosia authored
    save the author to self.author as part of init
Commits on Oct 8, 2012
  1. @teodosia

    PEP8 fix

    teodosia authored
This page is out of date. Refresh to see the latest.
Showing with 53 additions and 0 deletions.
  1. +29 −0 pages/author.py
  2. +24 −0 tests/test_profile.py
View
29 pages/author.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+from selenium.webdriver.common.by import By
+
+from base import BasePage
+
+
+class AuthorPage(BasePage):
+
+ _page_title = u"Posts by %s | QMO \u2013 quality.mozilla.org"
@klrmn Collaborator
klrmn added a note

is is_the_current_page going to know how to fill in that %s?

@teodosia Collaborator
teodosia added a note

The %s is filled in the init

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ _posted_by_locator = (By.CSS_SELECTOR, 'div.entry-meta .vcard > a')
+
+ def go_to_author_page(self):
+ self.selenium.get(self.testsetup.base_url + '/author/' + self.author)
+
+ def __init__(self, testsetup, author):
+ BasePage.__init__(self, testsetup)
+ self._page_title = self._page_title % author
+ self.author = author
+
+ @property
+ def posted_by(self):
+ return self.selenium.find_elements(*self._posted_by_locator)
View
24 tests/test_profile.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+import pytest
+from unittestzero import Assert
+
+from pages.author import AuthorPage
+
+
+class TestUserRegistration:
+
+ @pytest.mark.nondestructive
+ def test_that_accessing_author_profile_works(self, mozwebqa):
+ author_name = "rbillings"
+
+ author_page = AuthorPage(mozwebqa, author_name)
+ author_page.go_to_author_page()
+
+ Assert.true(author_page.is_the_current_page)
+ Assert.greater(len(author_page.posted_by), 0)
Something went wrong with that request. Please try again.