aboutsummaryrefslogtreecommitdiffstats
path: root/test.py
blob: be5d8cbfe027dea96fc0c25682e2ef205f781277 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
###
from supybot.log import info
from supybot.test import *

from local.testing.ExpectationPluginTestCase import *

class GithubTestCase(ExpectationPluginTestCase):
    plugins = ('Github',)
    port    = 27230
    files   = {}
    config  = { 'plugins.github.shortUrl': False,
                'plugins.github.hidePush': False
              }

    def setUp(self):
        # Set a different port from the default one to make testing while a
        # supybot-github instance is running possible - we don't use the config
        # variable because supybot's test framework sets the value after the
        # plugin has been loaded
        conf.supybot.plugins.get("Github").get('port').setValue(self.port)
        PluginTestCase.setUp(self)


    def testMerge(self):
        self.sendRequest('push-merge')

        self.describe('first message',
            it().should.contain('merged 4 commits'),
            it().should.contain('from newTestBranch'),
            it().should.contain('pushed 1 commit'),
            it().should.contain('to master'),
            it().should.contain('https://github.com/username/test/compare/cb12c8e51c8e...f386345fa3c5')
        )

        # By default, merged commits should not be shown
        self.assertError('get 5th message')

    def testV3Push(self):
        self.sendRequest('push-v3')

        self.describe('first message',
            it().should.contain('gh-pages'),
            it().should.contain('baxterthehacker'),
            it().should.contain('pushed 1 commit'),
            it().should.contain('https://github.com/baxterthehacker/public-repo/compare/4d2ab4e76d0d...7700ca29dd05')
        )

        self.describe('second message',
            it().should.contain('7700ca'),
            it().should.contain('kdaigle'),
            it().should.contain('https://github.com/baxterthehacker/public-repo/commit/7700ca29dd050d9adacc0803f866d9b539513535')
        )

        self.describe('third message',
            it().should.contain('Trigger pages build')
        )

    def testNewWikiPage(self):
        self.sendRequest('wiki-new-page')

        self.describe('first message',
            it().should.contain('kongr45gpen'),
            it().should.contain('modified 1 wiki page'),
            it().should.contain('https://github.com/kongr45gpen/supybot-github/wiki/_compare/9941c1a1bb1b2db99ad9aabf10c8f946d808e634')
        )

        self.describe('second message',
            it().should.contain('created Home'),
            it().should.contain('https://github.com/kongr45gpen/supybot-github/wiki/Home')
        )

    def testTravisNotification(self):
        self.sendRequest('travis-notification')

        self.describe('first message',
            it().should.contain('master @ minimal'),
            it().should.contain('passed'),
            it().should.contain('62aae'),
            it().should.contain('Sven Fuchs'),
            it().should.contain('this is a long commit message'),
            it().should_not.contain('this is a long commit message, because we must learn how to lead ever-present lives in the face of turbulence. It is a sign of things to come. The vector of aspiration is now happening'),
            it().should.contain('https://travis-ci.org/svenfuchs/minimal/builds/1')
        )

        self.assertError('get second message')

    def testCreateTag(self):
        self.sendRequest('create-tag')

        self.describe('first message',
            it().should.contain('public-repo'),
            it().should.contain('baxterthehacker'),
            it().should.contain('tagged'),
            it().should.contain('0.0.1'),
            it().should.contain('https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1')
        )

    def testDeleteTag(self):
        self.sendRequest('delete-tag')

        self.describe('first message',
            it().should.contain('public-repo'),
            it().should.contain('baxterthehacker'),
            it().should.contain('deleted tag'),
            it().should.contain('simple-tag'),
            it().should.contain('https://github.com/baxterthehacker/public-repo/tags')
        )

    def testCreateBranch(self):
        self.sendRequest('create-branch')

        self.describe('first message',
            it().should.contain('public-repo'),
            it().should.contain('baxterthehacker'),
            it().should.contain('created branch'),
            it().should.contain('develop'),
            it().should.contain('https://github.com/baxterthehacker/public-repo/tree/develop')
        )

    def testDeleteBranch(self):
        self.sendRequest('delete-branch')

        self.describe('first message',
            it().should.contain('public-repo'),
            it().should.contain('baxterthehacker'),
            it().should.contain('deleted branch'),
            it().should.contain('blue-lights'),
            it().should.contain('https://github.com/baxterthehacker/public-repo/branches')
        )

# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

© 2014-2024 Faster IT GmbH | imprint | privacy policy