Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataclass are not supported #25

Open
arkadyzalko opened this issue Oct 16, 2020 · 3 comments
Open

dataclass are not supported #25

arkadyzalko opened this issue Oct 16, 2020 · 3 comments

Comments

@arkadyzalko
Copy link

@dataclass is a pretty good feature and unfortunatelly is not supported.

# Object with __init__ that carries required non-default arguments are not supported

Example

class ObjectMapperTest(unittest.TestCase):
    """
    Unit tests for the `ObjectMapper` module.
    """
    @dataclass
    class FromTestDataClass:
        a: int
        b: str

    @dataclass
    class ToTestDataClass:
        a: int
        b: str

    def test_mapping_creation_without_mappings_correct_using_dataclass(self):
        """ Test mapping creation without mappings with dataclass"""

        # Arrange
        from_class = FromTestClass()
        mapper = ObjectMapper()
        mapper.create_map(FromTestDataClass, ToTestDataClass)

        # Act
        result = mapper.map(FromTestDataClass(a=1, b='2'))

        # Assert
        self.assertTrue(isinstance(result, ToTestDataClass), "Target types must be same")
        self.assertEqual(result.name, from_class.name, "Name mapping must be equal")
        self.assertEqual(result, ToTestDataClass(a=1, b='2'), "Class instance must be equal")
@raman-nbg
Copy link

There is a pull request for this: #26

@arisliang
Copy link

Nice addition, when would we publish it?

@arkadyzalko
Copy link
Author

The PR is not merged yet. @marazt could you merge this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants