summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorThomi Richards <thomi.richards@canonical.com>2013-11-25 18:01:46 +1300
committerThomi Richards <thomi.richards@canonical.com>2013-11-25 18:01:46 +1300
commit6b500b82b94d335e497ef83982c2db4a4b9b1e72 (patch)
tree7bd7c822ca2a6412cfed918787386feec5286880 /python
parent707f8967badcd7fb81144c13083f88710dcd35fd (diff)
downloadsubunit-6b500b82b94d335e497ef83982c2db4a4b9b1e72.tar.gz
Add a few missing tests.
Diffstat (limited to 'python')
-rw-r--r--python/subunit/_output.py1
-rw-r--r--python/subunit/tests/test_output_filter.py34
2 files changed, 33 insertions, 2 deletions
diff --git a/python/subunit/_output.py b/python/subunit/_output.py
index 49b5e81..24d63dc 100644
--- a/python/subunit/_output.py
+++ b/python/subunit/_output.py
@@ -11,6 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# license you chose for the specific language governing permissions and
# limitations under that license.
+#
import datetime
from functools import partial
diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py
index 401ec08..f3000ad 100644
--- a/python/subunit/tests/test_output_filter.py
+++ b/python/subunit/tests/test_output_filter.py
@@ -292,6 +292,17 @@ class StatusStreamResultTests(WithScenarios, TestCase):
])
)
+ def test_file_is_sent_with_test_status(self):
+ with temp_file_contents(b"Hello") as f:
+ result = get_result_for([self.option, self.test_id, '--attach-file', f.name])
+
+ self.assertThat(
+ result._events,
+ MatchesListwise([
+ MatchesStatusCall(test_status=self.status, file_bytes=b'Hello', eof=True),
+ ])
+ )
+
def test_file_chunk_size_is_honored(self):
with temp_file_contents(b"Hello") as f:
self.patch(_o, '_CHUNK_SIZE', 1)
@@ -419,7 +430,7 @@ class StatusStreamResultTests(WithScenarios, TestCase):
)
-class GlobalFileDataTests(TestCase):
+class FileDataTests(TestCase):
def test_can_attach_file_without_test_id(self):
with temp_file_contents(b"Hello") as f:
@@ -450,7 +461,8 @@ class GlobalFileDataTests(TestCase):
'--attach-file',
f.name,
'--file-name',
- specified_file_name])
+ specified_file_name
+ ])
self.assertThat(
result._events,
@@ -459,6 +471,24 @@ class GlobalFileDataTests(TestCase):
])
)
+ def test_files_have_timestamp(self):
+ _dummy_timestamp = datetime.datetime(2013, 1, 1, 0, 0, 0, 0, UTC)
+ self.patch(_o, 'create_timestamp', lambda: self._dummy_timestamp)
+
+ with temp_file_contents(b"Hello") as f:
+ specified_file_name = self.getUniqueString()
+ result = get_result_for([
+ '--attach-file',
+ f.name,
+ ])
+
+ self.assertThat(
+ result._events,
+ MatchesListwise([
+ MatchesStatusCall(file_bytes=b'Hello', timestamp=self._dummy_timestamp),
+ ])
+ )
+
class MatchesStatusCall(Matcher):