def test_release_added(self):
     release = c.Release(
         self.component,
         "1.0.0",
         "0000000000000000000000000000000000000000",
         "first",
     )
     self.assertEqual(release, self.component.get_release(release.version))
    def test_yaml(self):
        release = c.Release(
            self.component,
            "1.0.0",
            "0000000000000000000000000000000000000000",
            "first",
        )

        release_yaml = yaml.dump(release, default_flow_style=False)

        expected = ("is_product: false\n"
                    "name: test1\n"
                    "release:\n"
                    "  series: first\n"
                    "  sha: '0000000000000000000000000000000000000000'\n"
                    "  version: 1.0.0\n"
                    "repo_url: https://github.com/rcbops/test1\n")

        self.assertEqual(expected, release_yaml)
    def test_dict(self):
        release = c.Release(
            self.component,
            "1.0.0",
            "0000000000000000000000000000000000000000",
            "first",
        )

        expected = {
            "is_product": False,
            "name": "test1",
            "release": {
                "series": "first",
                "sha": "0000000000000000000000000000000000000000",
                "version": "1.0.0",
            },
            "repo_url": "https://github.com/rcbops/test1",
        }

        self.assertEqual(expected, release.to_dict())
 def test_ordering(self):
     versions = ("1.1.10", "1.0.0", "2.0.0", "1.1.2", "1.1.0")
     sorted_versions = ("1.0.0", "1.1.0", "1.1.2", "1.1.10", "2.0.0")
     releases = (c.Release(self.component, v, "", "") for v in versions)
     sorted_releases = sorted(releases)
     self.assertEqual(sorted_versions, tuple(map(str, sorted_releases)))
 def test_str_is_version(self):
     self.assertEqual("1.0.0",
                      str(c.Release(self.component, "1.0.0", "", "")))