• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #4767

13 Oct 2023 01:27AM CUT coverage: 22.091%. Remained the same
#4767

push

coveralls-python

suhaibmujahid
Format the .pre-commit-config.yaml file

716 of 3558 branches covered (0.0%)

1925 of 8714 relevant lines covered (22.09%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.87
/bugbot/config.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
import json
1✔
6
import os
1✔
7

8
from libmozdata import config
1✔
9

10

11
class MyConfig(config.Config):
1✔
12
    PATH = "configs/config.json"
1✔
13

14
    def __init__(self):
1✔
15
        super(MyConfig, self).__init__()
1✔
16
        if not os.path.exists(MyConfig.PATH):
1!
17
            self.conf = {"bz_api_key": "", "bz_api_key_nomail": "", "socorro_token": ""}
1✔
18
        else:
19
            with open(MyConfig.PATH) as In:
×
20
                self.conf = json.load(In)
×
21

22
        if "bz_api_key" not in self.conf:
1!
23
            raise Exception("Your config.json file must contain a Bugzilla token")
×
24

25
        if "bz_api_key_nomail" not in self.conf:
1!
26
            raise Exception(
×
27
                "Your config.json file must contain a Bugzilla token for an account that doesn't trigger bugmail (for testing, you can use the same token as bz_api_key)"
28
            )
29

30
        if "socorro_token" not in self.conf:
1!
31
            raise Exception("Your config.json file must contain a Socorro token")
×
32

33
    def get(self, section, option, default=None, type=str):
1✔
34
        if section == "Bugzilla":
1✔
35
            if option == "token":
1✔
36
                return self.conf["bz_api_key"]
1✔
37
            if option == "nomail-token":
1✔
38
                return self.conf["bz_api_key_nomail"]
1✔
39
        elif section == "Socorro":
1✔
40
            if option == "token":
1✔
41
                return self.conf["socorro_token"]
1✔
42
        elif section == "User-Agent":
1✔
43
            return "bugbot"
1✔
44
        return default
1✔
45

46

47
def load():
1✔
48
    config.set_config(MyConfig())
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc