def test_missing_file_with_refs(self): expected = { 'type': 'COMMAND', 'type_data': 'process_log', 'data': {'error': "Output 'src' set to a missing file: 'foo.py'."}, } self.assertEqual( save_file_list('src', 'foo.py:ref1.gz,ref2.gz', 'bar.py'), expected )
def test_file_with_missing_refs(self, isfile_mock, path_mock, copy_mock, size_mock): path_mock.is_file.return_value = True expected = { 'type': 'COMMAND', 'type_data': 'process_log', 'data': { 'error': "Output 'src' set to missing references: 'ref1.gz, ref2.gz'." }, } self.assertEqual(save_file_list('src', 'foo.py:ref1.gz,ref2.gz'), expected)
def test_files_invalid_format(self): expected = { 'type': 'COMMAND', 'type_data': 'process_log', 'data': {'error': "Only one colon ':' allowed in file-refs specification."}, } self.assertEqual( save_file_list('src', 'foo.py:ref1.gz:ref2.gz', 'bar.py'), expected, )
def test_file_with_refs(self, isfile_mock, path_mock, copy_mock, size_mock): path_mock.is_file.return_value = True expected = { 'type': 'COMMAND', 'type_data': 'update_output', 'data': { 'src': [ {'file': 'foo.py', 'size': 1, 'refs': ['ref1.gz', 'ref2.gz']}, {'file': 'bar.py', 'size': 2}, ] }, } self.assertEqual( save_file_list('src', 'foo.py:ref1.gz,ref2.gz', 'bar.py'), expected )
def test_files(self, path_mock, copy_mock, size_mock): path_mock.is_file.return_value = True expected = { 'type': 'COMMAND', 'type_data': 'update_output', 'data': { 'src': [ {'file': 'foo.py', 'size': 1}, {'file': 'bar 2.py', 'size': 2}, {'file': 'baz/3.py', 'size': 3}, ] }, } self.assertEqual( save_file_list('src', 'foo.py', 'bar 2.py', 'baz/3.py'), expected )
def test_files_invalid_format(self): self.assertEqual( save_file_list('src', 'foo.py:ref1.gz:ref2.gz', 'bar.py'), '{"proc.error": "Only one colon \':\' allowed in file-refs specification."}' )
def test_file_with_missing_refs(self, isfile_mock): self.assertEqual( save_file_list('src', 'foo.py:ref1.gz,ref2.gz'), '{"proc.error": "Output \'src\' set to missing references: \'ref1.gz, ref2.gz\'."}' )
def test_missing_file_with_refs(self): self.assertEqual(save_file_list('src', 'foo.py:ref1.gz,ref2.gz', 'bar.py'), '{"proc.error": "Output \'src\' set to a missing file: \'foo.py\'."}')
def test_file_with_refs(self, isfile_mock): self.assertJSONEqual( save_file_list('src', 'foo.py:ref1.gz,ref2.gz', 'bar.py'), '{"src": [{"file": "foo.py", "refs": ["ref1.gz", "ref2.gz"]}, {"file": "bar.py"}]}' )
def test_files(self, isfile_mock): self.assertEqual( save_file_list('src', 'foo.py', 'bar 2.py', 'baz/3.py'), '{"src": [{"file": "foo.py"}, {"file": "bar 2.py"}, {"file": "baz/3.py"}]}' )
def test_missing_file_with_refs(self): self.assertEqual( save_file_list('src', 'foo.py:ref1.gz,ref2.gz', 'bar.py'), '{"proc.error": "Output \'src\' set to a missing file: \'foo.py\'."}' )
def test_missing_file(self): self.assertEqual( save_file_list('src', 'foo.py', 'bar 2.py', 'baz/3.py'), '{"proc.error": "Output \'src\' set to a missing file: \'foo.py\'."}' )
def test_missing_file(self): self.assertEqual(save_file_list('src', 'foo.py', 'bar 2.py', 'baz/3.py'), '{"proc.error": "Output \'src\' set to a missing file: \'foo.py\'."}')