Exemple #1
0
    def test_parse_github_payload_tag(self):
        """
        Tests that a db.Commit object is created when passed a create event
        example github webhook payload
        """

        # Set up fake payload
        r = FakeRequest()
        r.data = payload_tag

        c = GithubListener.parse_github_payload(r)
        self.assertEqual(
            c['url'],
            'https://github.com/adsabs/adsws'
        )
        self.assertEqual(
            c['tag'],
            'v1.0.0'
        )

        for key in ['url', 'commit', 'author', 'tag']:
            self.assertIn(
                key,
                c,
                msg='Key "{}" not found in "{}"'.format(key, c)
            )
Exemple #2
0
    def test_parse_github_payload(self):
        """
        Tests that a db.Commit object is created when passed an example
        github webhook payload
        """

        # Set up fake payload
        r = FakeRequest()
        r.data = github_payload.replace('"name": "adsws"', '"name": "mission-control"')

        # Modify the data such that the payload refers to a known repo,
        # assert that the returned models.Commit contains the expected data
        r.data = github_payload
        c = GithubListener.parse_github_payload(r)
        self.assertEqual(
            c['url'],
            u'https://github.com/adsabs/adsws'
        )
        self.assertEqual(
            c['tag'],
            None
        )

        for key in ['url', 'commit', 'author', 'tag']:
            self.assertIn(
                key,
                c,
                msg='Key "{}" not found in "{}"'.format(key, c)
            )
    def test_parse_github_payload_tag(self):
        """
        Tests that a db.Commit object is created when passed a create event
        example github webhook payload
        """

        # Set up fake payload
        r = FakeRequest()
        r.data = payload_tag

        c = GithubListener.parse_github_payload(r)
        self.assertEqual(c["repository"], "adsws")
        self.assertEqual(c["tag"], "v1.0.0")

        for key in ["repository", "environment", "commit", "author", "tag"]:
            self.assertIn(key, c, msg='Key "{}" not found in "{}"'.format(key, c))
    def test_parse_github_payload(self):
        """
        Tests that a db.Commit object is created when passed an example
        github webhook payload
        """

        # Set up fake payload
        r = FakeRequest()
        r.data = github_payload.replace('"name": "adsws"', '"name": "mission-control"')

        # Modify the data such that the payload refers to a known repo,
        # assert that the returned models.Commit contains the expected data
        r.data = github_payload
        c = GithubListener.parse_github_payload(r)
        self.assertEqual(c["repository"], "adsws")
        self.assertEqual(c["tag"], None)

        for key in ["repository", "environment", "commit", "author", "tag"]:
            self.assertIn(key, c, msg='Key "{}" not found in "{}"'.format(key, c))