Esempio n. 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')
Esempio n. 2
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')
Esempio n. 3
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')
Esempio n. 4
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')
Esempio n. 5
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))