示例#1
0
class TestDistroCreated(unittest.TestCase):
    """ Tests for anitya_schema.distro_messages.DistroCreated class. """
    def setUp(self):
        """ Set up the tests. """
        self.message = DistroCreated()

    @mock.patch(
        "anitya_schema.distro_messages.DistroCreated.summary",
        new_callable=mock.PropertyMock,
    )
    def test__str__(self, mock_property):
        """ Assert that correct string is returned. """
        mock_property.return_value = "Dummy"

        self.assertEqual(self.message.__str__(), "Dummy")

    @mock.patch(
        "anitya_schema.distro_messages.DistroCreated.name",
        new_callable=mock.PropertyMock,
    )
    def test_summary(self, mock_property):
        """ Assert that correct summary string is returned. """
        mock_property.return_value = "Dummy"

        exp = "A new distribution, Dummy, was added to release-monitoring."
        self.assertEqual(self.message.summary, exp)

    def test_name(self):
        """ Assert that name string is returned. """
        self.message.body = {"distro": {"name": "Dummy"}}

        self.assertEqual(self.message.name, "Dummy")
class TestDistroCreated(unittest.TestCase):
    """ Tests for anitya_schema.distro_messages.DistroCreated class. """

    def setUp(self):
        """ Set up the tests. """
        self.message = DistroCreated()

    @mock.patch(
        "anitya_schema.distro_messages.DistroCreated.summary",
        new_callable=mock.PropertyMock,
    )
    def test__str__(self, mock_property):
        """ Assert that correct string is returned. """
        mock_property.return_value = "Dummy"

        self.assertEqual(self.message.__str__(), "Dummy")

    @mock.patch(
        "anitya_schema.distro_messages.DistroCreated.name",
        new_callable=mock.PropertyMock,
    )
    def test_summary(self, mock_property):
        """ Assert that correct summary string is returned. """
        mock_property.return_value = "Dummy"

        exp = "A new distribution, Dummy, was added to release-monitoring."
        self.assertEqual(self.message.summary, exp)

    def test_name(self):
        """ Assert that name string is returned. """
        self.message.body = {"distro": {"name": "Dummy"}}

        self.assertEqual(self.message.name, "Dummy")
示例#3
0
 def setUp(self):
     """ Set up the tests. """
     self.message = DistroCreated()
 def setUp(self):
     """ Set up the tests. """
     self.message = DistroCreated()