Esempio n. 1
0
    def test_non_existed_directory(self, monkeypatch, tmpdir):
        def export_entry(self):
            return Response(200, None, b'123', 'application/epub')

        monkeypatch.setattr(ExportEntry, 'request', export_entry)

        tmpdir = tmpdir + '/new_dir/'
        result, msg = ExportCommand(
            self.config,
            ExportCommandParams(10, FormatType.get('epub'),
                                PurePath(tmpdir))).execute()
        assert result
        assert re.search(f'Exported to: {PurePath(tmpdir)}/.+.epub', msg)
Esempio n. 2
0
    def test_empty_output_cdisposition(self, monkeypatch):
        def export_entry(self):
            return Response(200, None, b'123', 'application/epub',
                            'attachment; filename="file.epub"')

        monkeypatch.setattr(ExportEntry, 'request', export_entry)

        result, msg = ExportCommand(
            self.config,
            ExportCommandParams(10, FormatType.get('epub'))).execute()
        assert result
        assert msg == f'Exported to: {Path.cwd()}/10. file.epub'

        os.remove(f'{Path.cwd()}/10. file.epub')
Esempio n. 3
0
    def test_empty_output(self, monkeypatch, tmpdir):
        def export_entry(self):
            return Response(200, None, b'123', 'application/epub')

        def get_entry(self):
            return Response(
                200, '{"id": 10, "title": "title", "content": "content",\
                            "url": "url", "is_archived": 0, "is_starred": 1}')

        monkeypatch.setattr(ExportEntry, 'request', export_entry)
        monkeypatch.setattr(GetEntry, 'request', get_entry)

        result, msg = ExportCommand(
            self.config,
            ExportCommandParams(10, FormatType.get('epub'),
                                PurePath(tmpdir))).execute()
        assert result
        assert f'Exported to: {PurePath(tmpdir)}/10. title.epub' == msg
Esempio n. 4
0
    def test_format_not_specified(self):
        result, msg = ExportCommand(self.config,
                                    ExportCommandParams(10, None)).execute()

        assert not result
        assert msg == 'Type not specified'