コード例 #1
0
 def test_force_overwriting_artifact_does_not_raise_error(self):
     host = FakeHost()
     output_dir = '%stmp' % host.sep
     ar = artifacts.Artifacts(output_dir,
                              host,
                              iteration=0,
                              test_name='a.b.c',
                              intial_results_base_dir=True)
     file_rel_path = host.join('stdout', 'test.txt')
     ar.CreateArtifact('artifact_name',
                       file_rel_path,
                       'contents',
                       write_as_text=True)
     self.assertEqual(
         host.read_text_file(
             host.join(output_dir, 'a.b.c', 'initial', 'stdout',
                       'test.txt')), 'contents')
     ar.CreateArtifact('artifact_name',
                       file_rel_path,
                       'overwritten contents',
                       force_overwrite=True,
                       write_as_text=True)
     self.assertEqual(
         host.read_text_file(
             host.join(output_dir, 'a.b.c', 'initial', 'stdout',
                       'test.txt')), 'overwritten contents')
コード例 #2
0
 def test_duplicate_artifact_raises_error_when_added_to_list(self):
     host = FakeHost()
     output_dir = '%stmp' % host.sep
     ar = artifacts.Artifacts(output_dir, host, iteration=0)
     ar.AddArtifact('artifact_name', 'foo.txt')
     with self.assertRaises(ValueError) as ve:
         ar.AddArtifact('artifact_name', 'foo.txt')
     self.assertIn('already exists', str(ve.exception))
コード例 #3
0
 def test_create_artifact_writes_to_disk_iteration_0_no_test_dir(self):
     host = FakeHost()
     output_dir = '%stmp' % host.sep
     ar = artifacts.Artifacts(output_dir, host)
     file_rel_path = host.join('stdout', 'test.jpg')
     ar.CreateArtifact('artifact_name', file_rel_path, b'contents')
     self.assertEqual(
         host.read_binary_file(host.join(output_dir, 'stdout', 'test.jpg')),
         b'contents')
コード例 #4
0
 def test_dont_raise_value_error_for_dupl_in_add_artifacts(self):
     host = FakeHost()
     output_dir = '%stmp' % host.sep
     ar = artifacts.Artifacts(output_dir, host, iteration=0)
     ar.AddArtifact('artifact_name', 'foo.txt')
     ar.AddArtifact('artifact_name',
                    'foo.txt',
                    raise_exception_for_duplicates=False)
     self.assertEqual(ar.artifacts['artifact_name'], ['foo.txt'])
コード例 #5
0
 def test_file_manager_writes_file(self):
     host = FakeHost()
     output_dir = '%stmp' % host.sep
     ar = artifacts.Artifacts(output_dir, host, iteration=0)
     file_path = host.join('failures', 'stderr.txt')
     ar.CreateArtifact('artifact_name',
                       file_path,
                       'exception raised',
                       write_as_text=True)
     self.assertEqual(host.read_text_file(file_path), 'exception raised')
コード例 #6
0
 def test_overwriting_artifact_raises_value_error(self):
     host = FakeHost()
     output_dir = '%stmp' % host.sep
     ar = artifacts.Artifacts(output_dir,
                              host,
                              iteration=0,
                              test_name='retry_1')
     file_rel_path = host.join('stdout', 'test.jpg')
     ar.CreateArtifact('artifact_name', file_rel_path, b'contents')
     ar1 = artifacts.Artifacts(output_dir, host, iteration=1)
     with self.assertRaises(ValueError) as ve:
         ar1.CreateArtifact('artifact_name', file_rel_path,
                            b'overwritten contents')
     self.assertIn('already exists', str(ve.exception))
コード例 #7
0
 def test_create_artifact_writes_to_disk_initial_results_dir(self):
     host = FakeHost()
     output_dir = '%stmp' % host.sep
     ar = artifacts.Artifacts(output_dir,
                              host,
                              iteration=0,
                              test_name='a.b.c',
                              intial_results_base_dir=True)
     file_rel_path = host.join('stdout', 'test.jpg')
     ar.CreateArtifact('artifact_name', file_rel_path, b'contents')
     self.assertEqual(
         host.read_binary_file(
             host.join(output_dir, 'a.b.c', 'initial', 'stdout',
                       'test.jpg')), b'contents')
コード例 #8
0
 def test_create_link_newlines(self):
     ar = artifacts.Artifacts('', FakeHost())
     with self.assertRaises(ValueError):
         ar.CreateLink('link', 'https://some\nbadurl.com')
コード例 #9
0
 def test_create_link_non_https(self):
     ar = artifacts.Artifacts('', FakeHost())
     with self.assertRaises(ValueError):
         ar.CreateLink('link', 'http://testsite.com')
コード例 #10
0
 def test_create_link_invalid_url(self):
     ar = artifacts.Artifacts('', FakeHost())
     with self.assertRaises(ValueError):
         ar.CreateLink('link', 'https:/malformedurl.com')
コード例 #11
0
 def test_create_link(self):
     ar = artifacts.Artifacts('', FakeHost())
     ar.CreateLink('link', 'https://testsite.com')
     self.assertEqual(ar.artifacts, {'link': ['https://testsite.com']})
コード例 #12
0
ファイル: host_fake_test.py プロジェクト: sdd330/trace-viewer
 def host(self):
     return FakeHost()