File: test_vote.py

package info (click to toggle)
dosage 3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,400 kB
  • sloc: python: 12,703; sh: 55; makefile: 6
file content (40 lines) | stat: -rw-r--r-- 1,174 bytes parent folder | download
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
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: © 2004 Tristan Seligmann and Jonathan Jacobs
# SPDX-FileCopyrightText: © 2012 Bastian Kleineidam
# SPDX-FileCopyrightText: © 2015 Tobias Gruetzmacher
import pytest
import requests
import responses

from dosagelib import cmd, scraper


class ATestScraper(scraper.BasicScraper):
    pass


class TestVote(object):
    @responses.activate
    def test_vote(self):
        responses.add(responses.POST, 'https://buildbox.23.gs/count/')

        ATestScraper('Test_Test').vote()

    @responses.activate
    def test_vote_err(self):
        responses.add(responses.POST, 'https://buildbox.23.gs/count/', status=500)

        with pytest.raises(requests.exceptions.HTTPError):
            ATestScraper('Test_Test').vote()

    @responses.activate
    def test_run_vote(self):
        responses.add(responses.POST, 'https://buildbox.23.gs/count/')

        assert cmd.main(('-v', '--vote', 'xkcd')) == 0

    @responses.activate
    def test_run_vote_err(self):
        responses.add(responses.POST, 'https://buildbox.23.gs/count/', status=500)

        assert cmd.main(('-v', '--allow-multiple', '--vote', 'xkcd')) == 1