~mars/tarmac/move-pre-merge-hook

« back to all changes in this revision

Viewing changes to tarmac/plugins/tests/test_votes.py

  • Committer: Tarmac
  • Author(s): Rodney Dawes
  • Date: 2010-10-13 04:54:58 UTC
  • mfrom: (370.2.1 fix-votes)
  • Revision ID: paul@eventuallyanyway.com-20101013045458-nfynkzkk2ka9n8u3
Expose [Tarmac] options as attributes on the TarmacConfig object
Wrap set and remove_option so that we can manage TarmacConfig attributes
Fix the global config Votes tests to not set the attributes directly

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
 
109
109
    def test_run_global_config(self):
110
110
        target = Thing()
111
 
        command = Thing(
112
 
            config=Thing(
113
 
                voting_criteria="Approve >= 2, Disapprove == 0"))
 
111
        self.config.set('Tarmac', 'voting_criteria',
 
112
                        'Approve >= 2, Disapprove == 0')
 
113
        command = Thing(config=self.config)
 
114
        self.called = False
 
115
        old_count_votes = self.plugin.count_votes
 
116
 
 
117
        def count_votes(proposal):
 
118
            """OVerride for count_votes to validate it was called."""
 
119
            self.called = True
 
120
            return old_count_votes(proposal)
 
121
 
 
122
        self.plugin.count_votes = count_votes
114
123
        self.plugin.run(command=command, target=target,
115
124
                        source=None, proposal=self.proposal)
 
125
        if not self.called:
 
126
            self.fail('No voting_criteria configuration found')
116
127
 
117
128
    def test_run_global_config_failure(self):
118
129
        target = Thing()
119
 
        command = Thing(
120
 
            config=Thing(
121
 
                voting_criteria="Approve >= 2, Needs Information == 0"))
 
130
        self.config.set('Tarmac', 'voting_criteria',
 
131
                        'Approve >= 2, Needs Information == 0')
 
132
        command = Thing(config=self.config)
122
133
        try:
123
134
            self.plugin.run(
124
135
                command=command, target=target, source=None,