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

mendersoftware / mender-auth-azure-iot / 8278283814

17 Nov 2021 07:12PM UTC coverage: 34.239%. Remained the same
8278283814

push

coveralls-python

web-flow
Merge pull request #7 from oleorhagen/MEN-5141-bak

MEN-5141: Implement the Device Twin sync with IoT Hub

63 of 181 new or added lines in 5 files covered. (34.81%)

63 of 184 relevant lines covered (34.24%)

0.34 hits per line

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

96.15
/src/daemon/config/config.py
1
# Copyright 2021 Northern.tech AS
2
#
3
#    Licensed under the Apache License, Version 2.0 (the "License");
4
#    you may not use this file except in compliance with the License.
5
#    You may obtain a copy of the License at
6
#
7
#        http://www.apache.org/licenses/LICENSE-2.0
8
#
9
#    Unless required by applicable law or agreed to in writing, software
10
#    distributed under the License is distributed on an "AS IS" BASIS,
11
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
#    See the License for the specific language governing permissions and
13
#    limitations under the License.
14
import json
1✔
15
import logging
1✔
16

17
log = logging.getLogger(__name__)
1✔
18

19

20
class NoConfigurationFileError(Exception):
1✔
21
    pass
1✔
22

23

24
class Config:
1✔
25
    """A dictionary for storing Mender configuration values"""
26

27
    ConnectionString = ""
1✔
28

29
    def __init__(self, local_conf: dict):
1✔
30
        vals = {**local_conf}
1✔
31
        log.debug("mender-auth-azure-iot configuration values:")
1✔
32
        for k, v in vals.items():
1✔
33
            if k == "ConnectionString":
1✔
34
                log.debug(f"ConnectionString: {v}")
1✔
35
                self.ConnectionString = v
1✔
36
            else:
NEW
37
                log.error(f"The key {k} is not recognized by the azure auth daemon")
×
38

39

40
def load(local_path: str):
1✔
41
    """Read and return the merged configuration from the config file"""
42
    log.info("Loading the configuration file...")
1✔
43
    log.debug(f"From path: {local_path}")
1✔
44
    local_conf = None
1✔
45
    try:
1✔
46
        with open(local_path, "r") as fh:
1✔
47
            local_conf = json.load(fh)
1✔
48
    except FileNotFoundError as e:
1✔
49
        log.info(f"Configuration file: '{local_path}' not found")
1✔
50
        raise NoConfigurationFileError from e
1✔
51
    return Config(local_conf=local_conf or {})
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