Skip to content

Commit

Permalink
python: add tests for the format module
Browse files Browse the repository at this point in the history
  • Loading branch information
vanyauhalin committed Aug 16, 2023
1 parent 373733a commit 7b569a1
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions web/documentserver-example/python/src/format/format_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#
# (c) Copyright Ascensio System SIA 2023
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from __future__ import annotations
from unittest import TestCase
from . import Format, FormatManager

class FormatTests(TestCase):
json = \
'''
{
"name": "djvu",
"type": "word",
"actions": ["view"],
"convert": ["bmp", "gif", "jpg", "pdf", "pdfa", "png"],
"mime": ["image/vnd.djvu"]
}
'''

def test_generates_extension(self):
form = Format.decode(self.json)
self.assertEqual(form.extension(), '.djvu')

class FormatManagerAllTests(TestCase):
def test_loads(self):
format_manager = FormatManager()
formats = format_manager.all()
empty = len(formats) == 0
self.assertFalse(empty)

class FormatManagerDocumentsTests(TestCase):
def test_loads(self):
format_manager = FormatManager()
formats = format_manager.documents()
empty = len(formats) == 0
self.assertFalse(empty)

class FormatManagerPresentationsTests(TestCase):
def test_loads(self):
format_manager = FormatManager()
formats = format_manager.presentations()
empty = len(formats) == 0
self.assertFalse(empty)

class FormatManagerSpreadsheetsTests(TestCase):
def test_loads(self):
format_manager = FormatManager()
formats = format_manager.spreadsheets()
empty = len(formats) == 0
self.assertFalse(empty)

class FormatManagerConvertibleTests(TestCase):
def test_loads(self):
format_manager = FormatManager()
formats = format_manager.convertible()
empty = len(formats) == 0
self.assertFalse(empty)

class FormatManagerEditableTests(TestCase):
def test_loads(self):
format_manager = FormatManager()
formats = format_manager.editable()
empty = len(formats) == 0
self.assertFalse(empty)

class FormatManagerViewableTests(TestCase):
def test_loads(self):
format_manager = FormatManager()
formats = format_manager.viewable()
empty = len(formats) == 0
self.assertFalse(empty)

class FormatManagerFillableTests(TestCase):
def test_loads(self):
format_manager = FormatManager()
formats = format_manager.fillable()
empty = len(formats) == 0
self.assertFalse(empty)

0 comments on commit 7b569a1

Please sign in to comment.