-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from repo-2017/abacus-parser-tests
Abacus parser tests
- Loading branch information
Showing
20 changed files
with
799 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
import logging | ||
import os | ||
|
||
import xmlschema | ||
|
||
from sl_util.sl_util.file_utils import get_file_type_by_content | ||
from slp_base import ProviderValidator, DiagramFileNotValidError, DiagramType | ||
from slp_base.slp_base.provider_validator import generate_size_error, generate_content_type_error, generate_schema_error | ||
from slp_base.slp_base.provider_validator import generate_size_error, generate_content_type_error | ||
|
||
logger = logging.getLogger(__name__) | ||
path = os.path.dirname(__file__) | ||
|
||
class AbacusValidator(ProviderValidator): | ||
MAX_SIZE = 10 * 1024 * 1024 | ||
MIN_SIZE = 10 | ||
|
||
def __init__(self): | ||
super(AbacusValidator, self).__init__() | ||
path = os.path.dirname(__file__) | ||
|
||
|
||
# def validate(self): | ||
# logger.info('Validating Abacus file') | ||
class AbacusValidator(ProviderValidator): | ||
|
||
def __init__(self, data): | ||
super(AbacusValidator, self).__init__() | ||
self.data = data | ||
self.provider = DiagramType.ABACUS | ||
|
||
def validate(self): | ||
logger.info('Validating Abacus file') | ||
self.__validate_size() | ||
self.__validate_content_type() | ||
|
||
def __validate_size(self): | ||
size = len(self.data) | ||
if size > MAX_SIZE or size < MIN_SIZE: | ||
raise generate_size_error(self.provider, 'diag_file', DiagramFileNotValidError) | ||
|
||
def __validate_content_type(self): | ||
mime = get_file_type_by_content(self.data) | ||
if mime not in self.provider.valid_mime: | ||
raise generate_content_type_error(self.provider, 'diag_file', DiagramFileNotValidError) |
Oops, something went wrong.