def test_question_end_point(self): PF.create_base_project() q = Question.objects.all()[0] url = '%s/api/%s/%s%i/?format=json' % (TEST_SERVER_URL, API_VERSION, 'questions/', q.pk) response = urllib2.urlopen(url) json = response.read() self.assertGreaterEqual(json.count('"title":'), 1, "Question api end point not working!")
def test_project_part_end_point(self): PF.create_base_project() pp = ProjectPart.objects.all()[0] url = '%s/api/%s/%s%i/?format=json' % (TEST_SERVER_URL, API_VERSION, 'project_parts/', pp.pk) response = urllib2.urlopen(url) json = response.read() self.assertGreaterEqual(json.count('"name":'), 1, "Project part end point not working!")
def test_document_with_page_select_page(self): PF.create_base_project() d = Document.objects.all()[0] self.selenium.get('%s/%s%i/?page=2' % (self.live_server_url, _('documents_url'), d.pk)) time.sleep(SELENIUM_SLEEP_TIME + 2) elem = self.selenium.find_element_by_xpath('//input[@id="page_num"]') self.assertEqual(elem.get_attribute('value'), '2', "Page on document page not selected/displayed correctly!")
def test_documents_feed(self): PF.create_base_project() response = urllib2.urlopen('%s/%srss/' % (TEST_SERVER_URL, _('documents_url'))) xml = response.read() self.assertGreaterEqual(xml.count('<item>'), 1, "Documents rss feed not working!")
def test_comments_of_content_object_feed(self): PF.create_base_project() p1 = Participant.objects.all()[0] c1 = Comment.objects.all()[0] response = urllib2.urlopen('%s/%s%i/%srss/' % (TEST_SERVER_URL, _('participants_url'), c1.pk, _('comments_url'))) xml = response.read() self.assertGreaterEqual(xml.count('<item>'), 1, "Comments of content object rss feed not working!")
def test_main_page(self): PF.create_base_project() self.selenium.get('%s/' % (self.live_server_url)) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//div[@id="site_intro_text"]') except NoSuchElementException: self.assertTrue(0, "No main page displayed!")
def test_events_page(self): PF.create_base_project() self.selenium.get('%s/%s' % (self.live_server_url, _('events_url'))) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//h2[contains(text(),"' + _("Events") + '")]') except NoSuchElementException: self.assertTrue(0, "No process page displayed!")
def test_contact_page(self): PF.create_base_project() self.selenium.get('%s/%s' % (self.live_server_url, _('contact_url'))) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//h2[contains(text(),"' + _('Contact') + '")]') except NoSuchElementException: self.assertTrue(0, "Contact page not displayed correctly!")
def test_research_requests_feed(self): PF.create_base_project() response = urllib2.urlopen( '%s/%s%srss/' % (TEST_SERVER_URL, _('questions_url'), _('research_requests_url'))) xml = response.read() self.assertGreaterEqual(xml.count('<item>'), 1, "Research Requests rss feed not working!")
def test_search_page(self): PF.create_base_project() q = '1' self.selenium.get('%s/%s?q=%s' % (self.live_server_url, _('search_url'), q)) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//h2[contains(text(),"' + q + '")]') except NoSuchElementException: self.assertTrue(0, "Search page not displayed correctly!")
def test_question_page(self): PF.create_base_project() q = Question.objects.all()[0] self.selenium.get('%s/%s%i/' % (self.live_server_url, _('questions_url'), q.pk)) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//h3[contains(text(),"' + q.title + '")]') except NoSuchElementException: self.assertTrue(0, "Question page not displayed correctly!")
def test_participant_page(self): PF.create_base_project() p = Participant.objects.all()[0] self.selenium.get('%s/%s%i/' % (self.live_server_url, _('participants_url'), p.pk)) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//h3[contains(text(),"' + p.name + '")]') except NoSuchElementException: self.assertTrue(0, "Participant page not displayed correctly!")
def test_comments_page(self): PF.create_base_project() self.selenium.get('%s/%s' % (self.live_server_url, _('comments_url'))) time.sleep(SELENIUM_SLEEP_TIME) try: x_path = '//div[@class="comment_header"]' self.selenium.find_element_by_xpath(x_path) except NoSuchElementException: self.assertTrue(0, "Comments page not displayed correctly!")
def test_questions_page(self): PF.create_base_project() self.selenium.get('%s/%s' % (self.live_server_url, _('questions_url'))) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//h2[contains(text(),"' + _("Questions") + '")]') except NoSuchElementException: self.assertTrue(0, "No questions page displayed!")
def test_expand_collapse(self): PF.create_base_project() self.selenium.get('%s/%s' % (self.live_server_url, _('participants_url'))) time.sleep(SELENIUM_SLEEP_TIME) self.selenium.find_element_by_xpath('//button[@id="bg_expand"]').click() time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//div[@id="pt_ec_box_1" and contains(@style,"display: block")]') except NoSuchElementException: self.assertTrue(0, "Expand/collapse UI element not working!")
def test_document_with_page_select_page(self): PF.create_base_project() d = Document.objects.all()[0] self.selenium.get('%s/%s%i/?page=2' % (self.live_server_url, _('documents_url'), d.pk)) time.sleep(SELENIUM_SLEEP_TIME + 2) elem = self.selenium.find_element_by_xpath('//input[@id="page_num"]') self.assertEqual( elem.get_attribute('value'), '2', "Page on document page not selected/displayed correctly!")
def test_research_requests_of_question_feed(self): PF.create_base_project() q = Question.objects.all()[0] response = urllib2.urlopen('%s/%s%i/%srss/' % (TEST_SERVER_URL, _('questions_url'), q.pk, _('research_requests_url'))) xml = response.read() self.assertGreaterEqual( xml.count('<item>'), 1, "Research Requests of question rss feed not working!")
def test_comments_of_content_object_page(self): PF.create_base_project() p1 = Participant.objects.all()[0] c1 = Comment.objects.all()[0] self.selenium.get('%s/%s%i/%s' % (self.live_server_url, _('participants_url'), p1.pk, _('comments_url'))) time.sleep(SELENIUM_SLEEP_TIME) try: x_path = '//h3[contains(text(),"' + p1.name + '")]' self.selenium.find_element_by_xpath(x_path) except NoSuchElementException: self.assertTrue(0, "Comments of content object page not displayed correctly!")
def test_display_comment_on_content_object_page(self): PF.create_base_project() p1 = Participant.objects.all()[0] c1 = Comment.objects.all()[0] self.selenium.get('%s/%s%i/?comment_id=%i' % (self.live_server_url, _('participants_url'), p1.pk, c1.pk)) time.sleep(SELENIUM_SLEEP_TIME) try: x_path = '//div[@class="modal-header"]/h3[contains(text(),"' + _("Comment") + '")]' self.selenium.find_element_by_xpath(x_path) except NoSuchElementException: self.assertTrue(0, "Comment on content object page not displayed correctly!")
def test_display_research_request_on_question_page(self): PF.create_base_project() q = Question.objects.all()[0] rr = ResearchRequest.objects.all()[0] self.selenium.get('%s/%s%i/?research_request_id=%i' % (self.live_server_url, _('questions_url'), q.pk, rr.pk)) time.sleep(SELENIUM_SLEEP_TIME) try: x_path = '//div[@class="modal-header"]/h3[contains(text(),"' + _("Research Request") + '")]' self.selenium.find_element_by_xpath(x_path) except NoSuchElementException: self.assertTrue(0, "Research Request on question page not displayed correctly!")
def test_comments_of_content_object_feed(self): PF.create_base_project() p1 = Participant.objects.all()[0] c1 = Comment.objects.all()[0] response = urllib2.urlopen( '%s/%s%i/%srss/' % (TEST_SERVER_URL, _('participants_url'), c1.pk, _('comments_url'))) xml = response.read() self.assertGreaterEqual( xml.count('<item>'), 1, "Comments of content object rss feed not working!")
def test_search_box_autocomplete_universal_search(self): PF.create_base_project() self.selenium.get('%s/' % (self.live_server_url)) elem = self.selenium.find_element_by_xpath('//input[@id="q"]') elem.send_keys("Tes") time.sleep(1) elem.send_keys("t") time.sleep(SELENIUM_SLEEP_TIME) elem.send_keys(Keys.RETURN) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//div[@id="info_box_participants"]') except NoSuchElementException: self.assertTrue(0, "No search page with participant(s) displayed!")
def test_comments_of_content_object_page(self): PF.create_base_project() p1 = Participant.objects.all()[0] c1 = Comment.objects.all()[0] self.selenium.get('%s/%s%i/%s' % (self.live_server_url, _('participants_url'), p1.pk, _('comments_url'))) time.sleep(SELENIUM_SLEEP_TIME) try: x_path = '//h3[contains(text(),"' + p1.name + '")]' self.selenium.find_element_by_xpath(x_path) except NoSuchElementException: self.assertTrue( 0, "Comments of content object page not displayed correctly!")
def test_events_topic_selector(self): PF.create_base_project() self.selenium.get('%s/%s' % (self.live_server_url, _('events_url'))) time.sleep(SELENIUM_SLEEP_TIME) elem = self.selenium.find_element_by_xpath('//select[@id="mpp_events_select"]') elem.click() time.sleep(1) elem.send_keys(Keys.ARROW_DOWN) time.sleep(SELENIUM_SLEEP_TIME) elem.send_keys(Keys.RETURN) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//div[@id="events_4" and contains(@style,"display: block")]//a[contains(text(),"2")]') except NoSuchElementException: self.assertTrue(0, "Events topic selector not working!")
def test_display_comment_on_content_object_page(self): PF.create_base_project() p1 = Participant.objects.all()[0] c1 = Comment.objects.all()[0] self.selenium.get( '%s/%s%i/?comment_id=%i' % (self.live_server_url, _('participants_url'), p1.pk, c1.pk)) time.sleep(SELENIUM_SLEEP_TIME) try: x_path = '//div[@class="modal-header"]/h3[contains(text(),"' + _( "Comment") + '")]' self.selenium.find_element_by_xpath(x_path) except NoSuchElementException: self.assertTrue( 0, "Comment on content object page not displayed correctly!")
def test_search_box_autocomplete_navigate(self): PF.create_base_project() self.selenium.get('%s/' % (self.live_server_url)) elem = self.selenium.find_element_by_xpath('//input[@id="q"]') elem.send_keys("Tes") time.sleep(1) elem.send_keys("t") time.sleep(1) elem.send_keys(Keys.ARROW_DOWN) time.sleep(SELENIUM_SLEEP_TIME) elem.send_keys(Keys.RETURN) time.sleep(SELENIUM_SLEEP_TIME) try: self.selenium.find_element_by_xpath('//h3[contains(text(),"Test Corporation")]') except NoSuchElementException: self.assertTrue(0, "No participant detail page displayed!")
def test_display_research_request_on_question_page(self): PF.create_base_project() q = Question.objects.all()[0] rr = ResearchRequest.objects.all()[0] self.selenium.get( '%s/%s%i/?research_request_id=%i' % (self.live_server_url, _('questions_url'), q.pk, rr.pk)) time.sleep(SELENIUM_SLEEP_TIME) try: x_path = '//div[@class="modal-header"]/h3[contains(text(),"' + _( "Research Request") + '")]' self.selenium.find_element_by_xpath(x_path) except NoSuchElementException: self.assertTrue( 0, "Research Request on question page not displayed correctly!")
def handle(self, *args, **options): pf = ProjectFactory() pf.create_base_project()
def test_main_feed(self): PF.create_base_project() response = urllib2.urlopen('%s/rss/' % (TEST_SERVER_URL)) xml = response.read() self.assertGreaterEqual(xml.count('<item>'), 5, "Main rss feed not working!")
def test_research_requests_of_question_feed(self): PF.create_base_project() q = Question.objects.all()[0] response = urllib2.urlopen('%s/%s%i/%srss/' % (TEST_SERVER_URL, _('questions_url'), q.pk, _('research_requests_url'))) xml = response.read() self.assertGreaterEqual(xml.count('<item>'), 1, "Research Requests of question rss feed not working!")
def test_research_requests_feed(self): PF.create_base_project() response = urllib2.urlopen('%s/%s%srss/' % (TEST_SERVER_URL, _('questions_url'), _('research_requests_url'))) xml = response.read() self.assertGreaterEqual(xml.count('<item>'), 1, "Research Requests rss feed not working!")
def test_project_parts_end_point(self): PF.create_base_project() url = '%s/api/%s/%s?format=json' % (TEST_SERVER_URL, API_VERSION, 'project_parts/') response = urllib2.urlopen(url) json = response.read() self.assertGreaterEqual(json.count('"name":'), 1, "Project parts api end point not working!")