From 6d9cfdcd22baded38216da7153b04125a4ac6aae Mon Sep 17 00:00:00 2001 From: Alessandro Verdura Date: Wed, 27 May 2015 21:59:29 +0200 Subject: [PATCH] Add timestamp value test TNL-925 --- .../acceptance/pages/studio/import_export.py | 11 ++++++++++ .../tests/studio/test_import_export.py | 20 +++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/common/test/acceptance/pages/studio/import_export.py b/common/test/acceptance/pages/studio/import_export.py index ddefb484ed..15859af15e 100644 --- a/common/test/acceptance/pages/studio/import_export.py +++ b/common/test/acceptance/pages/studio/import_export.py @@ -3,6 +3,7 @@ Import/Export pages. """ from bok_choy.promise import EmptyPromise import os +import re import requests from .utils import click_css from .library import LibraryPage @@ -118,6 +119,16 @@ class ImportMixin(object): url_path = "import" + @property + def timestamp(self): + """ + The timestamp is displayed on the page as "(MM/DD/YYYY at HH:mm)" + It parses the timestamp and returns a (date, time) tuple + """ + string = self.q(css='.item-progresspoint-success-date').text[0] + + return re.match(r'\(([^ ]+).+?(\d{2}:\d{2})', string).groups() + def is_browser_on_page(self): """ Verify this is the export page diff --git a/common/test/acceptance/tests/studio/test_import_export.py b/common/test/acceptance/tests/studio/test_import_export.py index 8e25525b62..8319829911 100644 --- a/common/test/acceptance/tests/studio/test_import_export.py +++ b/common/test/acceptance/tests/studio/test_import_export.py @@ -3,6 +3,7 @@ Acceptance tests for the Import and Export pages """ from abc import abstractmethod from bok_choy.promise import EmptyPromise +from datetime import datetime from .base_studio_test import StudioLibraryTest, StudioCourseTest from ...fixtures.course import XBlockFixtureDesc from ...pages.studio.import_export import ExportLibraryPage, ExportCoursePage, ImportLibraryPage, ImportCoursePage @@ -183,10 +184,25 @@ class ImportTestMixin(object): self.import_page.upload_tarball(self.tarball_name) self.import_page.wait_for_upload() - def test_successful_import_timestamp(self): + def test_import_timestamp_value(self): """ Scenario: I perform a course / library import - On import success, the page displays its UTC timestamp previously not visible + On import success, the page displays a UTC timestamp + """ + self.import_page.upload_tarball(self.tarball_name) + self.import_page.wait_for_upload() + + utc_now = datetime.utcnow() + import_date, import_time = self.import_page.timestamp + + self.assertTrue(self.import_page.is_timestamp_visible()) + self.assertEqual(utc_now.strftime('%m/%d/%Y'), import_date) + self.assertEqual(utc_now.strftime('%H:%M'), import_time) + + def test_import_timestamp_visibility(self): + """ + Scenario: I perform a course / library import + On import success, the page displays a timestamp previously not visible And if I refresh the page, the timestamp is still displayed """ self.assertFalse(self.import_page.is_timestamp_visible())