diff options
| author | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 11:16:41 +1300 |
|---|---|---|
| committer | Thomi Richards <thomi.richards@canonical.com> | 2013-11-19 11:16:41 +1300 |
| commit | 66ed68e1d151baf71e63d11a44ce773b6f40b427 (patch) | |
| tree | 91fb4e9a4cadcccf0dd0478deabe80da47e9075f /python/subunit/tests | |
| parent | 56063023c343ee0f25be349edab11eecbbc22e5a (diff) | |
| download | subunit-66ed68e1d151baf71e63d11a44ce773b6f40b427.tar.gz | |
Add support for passing mime-type on the command-line.
Diffstat (limited to 'python/subunit/tests')
| -rw-r--r-- | python/subunit/tests/test_output_filter.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py index ef6dc9a..72ede6a 100644 --- a/python/subunit/tests/test_output_filter.py +++ b/python/subunit/tests/test_output_filter.py @@ -83,6 +83,13 @@ class OutputFilterArgumentTests(TestCase): self.assertThat(args.attach_file, IsInstance(file)) self.assertThat(args.attach_file.name, Equals(tmp_file.name)) + def test_all_commands_accept_mimetype_argument(self): + for command in self._all_supported_commands: + args = safe_parse_arguments( + args=[command, 'foo', '--mimetype', "text/plain"] + ) + self.assertThat(args.mimetype, Equals("text/plain")) + class ByteStreamCompatibilityTests(TestCase): @@ -193,7 +200,7 @@ class ByteStreamCompatibilityTests(TestCase): class FileChunkingTests(TestCase): - def _write_chunk_file(self, file_data, chunk_size): + def _write_chunk_file(self, file_data, chunk_size, mimetype=None): """Write chunked data to a subunit stream, return a StreamResult object.""" stream = BytesIO() output_writer = StreamResultToBytes(output_stream=stream) @@ -202,7 +209,7 @@ class FileChunkingTests(TestCase): f.write(file_data) f.seek(0) - write_chunked_file(f, 'foo_test', output_writer, chunk_size) + write_chunked_file(f, 'foo_test', output_writer, chunk_size, mimetype) stream.seek(0) @@ -225,6 +232,17 @@ class FileChunkingTests(TestCase): ]) ) + def test_file_mimetype_is_honored(self): + result = self._write_chunk_file("SomeData", 1024, "text/plain") + self.assertThat( + result._events, + MatchesListwise([ + MatchesCall(call='status', file_bytes='SomeData', mime_type="text/plain"), + MatchesCall(call='status', file_bytes='', mime_type="text/plain"), + ]) + ) + + class MatchesCall(Matcher): _position_lookup = { @@ -253,8 +271,9 @@ class MatchesCall(Matcher): def match(self, call_tuple): for k,v in self._filters.items(): try: - if call_tuple[self._position_lookup[k]] != v: - return Mismatch("Value for key is %r, not %r" % (self._position_lookup[k], v)) + pos = self._position_lookup[k] + if call_tuple[pos] != v: + return Mismatch("Value for key is %r, not %r" % (call_tuple[pos], v)) except IndexError: return Mismatch("Key %s is not present." % k) |
