Skip to content

Commit

Permalink
[ci] Correct pylint findings
Browse files Browse the repository at this point in the history
  • Loading branch information
dennis6p committed Dec 1, 2024
1 parent 763232b commit 5bc0035
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions examples/simple_card/simple_card.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Example: simple card"""

from requests import Response
from adaptive_cards.elements import TextBlock

import adaptive_cards.card_types as types
from adaptive_cards.card import AdaptiveCard
from adaptive_cards.validation import SchemaValidator, Result
from adaptive_cards.client import TeamsClient

from adaptive_cards.elements import TextBlock
from adaptive_cards.validation import CardValidator, CardValidatorFactory, Result

text_block: TextBlock = TextBlock(
text="It's your second card",
Expand All @@ -20,7 +20,7 @@
card: AdaptiveCard = AdaptiveCard.new().version(version).add_item(text_block).create()

# validate card
validator: SchemaValidator = SchemaValidator()
validator: CardValidator = CardValidatorFactory.create_validator_microsoft_teams()
result: Result = validator.validate(card)

print(f"Validation was successful: {result == Result.SUCCESS}")
Expand Down
17 changes: 13 additions & 4 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# test_math_operations.py
"""Tests for validation module"""

import unittest
from dataclasses import dataclass, field

from dataclasses_json import dataclass_json

import adaptive_cards.card_types as types
import adaptive_cards.utils as utils
from adaptive_cards import (
AdaptiveCard,
TextBlock,
utils,
)
from adaptive_cards.validation import (
CardValidator,
Expand All @@ -18,9 +19,11 @@
)


class TestAdaptiveCard(unittest.TestCase):
class TestAdaptiveCardValidation(unittest.TestCase):
"""Test class for Adaptive Card validaiton"""

def test_card_validator_ms_teams_validate_success(self) -> None:
"""Run test for simple card"""
"""Test validation for ms teams"""
validator: CardValidator = (
CardValidatorFactory.create_validator_microsoft_teams()
)
Expand All @@ -31,6 +34,7 @@ def test_card_validator_ms_teams_validate_success(self) -> None:
self.assertEqual(len(validator.details()), 0)

def test_validate_failure_empty_body(self) -> None:
"""Test validation for ms teams"""
validator: CardValidator = (
CardValidatorFactory.create_validator_microsoft_teams()
)
Expand All @@ -40,6 +44,7 @@ def test_validate_failure_empty_body(self) -> None:
self.assertEqual(validator.details()[0].failure, ValidationFailure.EMPTY_CARD)

def test_validate_failure_invalid_field_version(self) -> None:
"""Test validation for ms teams"""
validator: CardValidator = (
CardValidatorFactory.create_validator_microsoft_teams()
)
Expand All @@ -56,13 +61,16 @@ def test_validate_failure_invalid_field_version(self) -> None:
)

def test_validate_failure_invalid_schema(self) -> None:
"""Test validation for ms teams"""
validator: CardValidator = (
CardValidatorFactory.create_validator_microsoft_teams()
)

@dataclass_json
@dataclass
class InvalidClass:
"""Invalid class"""

some_field: int | None = field(
default=None, metadata=utils.get_metadata("1.0")
)
Expand All @@ -77,6 +85,7 @@ class InvalidClass:
)

def test_validate_failure_size_limit_exceeded(self) -> None:
"""Test validation for ms teams"""
validator: CardValidator = (
CardValidatorFactory.create_validator_microsoft_teams()
)
Expand Down

0 comments on commit 5bc0035

Please sign in to comment.