예제 #1
0
    def test_create_from_string_content(self):
        file = File.from_content("some_content")
        self.assertEqual(None, file.path)
        self.assertEqual("some_content".encode("utf-8"), file.content)
        self.assertEqual("txt", file.extension)

        file = File.from_content("some_content", extension="png")
        self.assertEqual(None, file.path)
        self.assertEqual("some_content".encode("utf-8"), file.content)
        self.assertEqual("png", file.extension)
예제 #2
0
    def test_create_from_bytes_content(self):
        file = File.from_content(b"some_content")
        self.assertEqual(None, file.path)
        self.assertEqual(b"some_content", file.content)
        self.assertEqual("bin", file.extension)

        file = File.from_content(b"some_content", extension="png")
        self.assertEqual(None, file.path)
        self.assertEqual(b"some_content", file.content)
        self.assertEqual("png", file.extension)
예제 #3
0
    def test_assign_raise_not_image(self):
        # given
        path = self._random_path()
        op_processor = MagicMock()
        exp = self._create_run(processor=op_processor)
        attr = FileSeries(exp, path)

        file = File.from_content("some text")
        with create_file(file.content, binary_mode=True) as tmp_filename:
            saved_file = File(tmp_filename)

            # when
            with self.assertRaises(OperationNotSupported):
                attr.assign([file])
            with self.assertRaises(OperationNotSupported):
                attr.assign([saved_file])