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

CiscoDevNet / virlutils / 9818589903

06 Jul 2024 10:28AM UTC coverage: 75.863% (+0.03%) from 75.835%
9818589903

push

github

web-flow
Merge pull request #154 from sgherdao/bugfix-152-wrong-owner-name-alt

 fix(152): cml ls --all-users display wrong owner

10 of 10 new or added lines in 2 files covered. (100.0%)

1 existing line in 1 file now uncovered.

1955 of 2577 relevant lines covered (75.86%)

3.79 hits per line

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

90.7
/virl/api/cml.py
1
import os
5✔
2

3
from yaml import load
5✔
4

5
try:
5✔
6
    from yaml import CLoader as Loader
5✔
7
except ImportError:
×
8
    from yaml import Loader
×
9

10

11
class CachedLab(object):
5✔
12
    """
13
    This is a stub class to represent a pseudo-lab that is cached locally.
14
    Only enough of the lab model is implemented for the required virlutils functions.
15
    """
16

17
    __id = None
5✔
18
    __title = None
5✔
19
    __description = None
5✔
20
    __stats = {
5✔
21
        "nodes": 0,
22
        "links": 0,
23
        "interfaces": 0,
24
    }
25

26
    def __init__(self, lab_id, cache_file):
5✔
27
        if not os.path.exists(cache_file):
5✔
28
            raise FileNotFoundError("Cached lab {} not found".format(cache_file))
×
29

30
        self.__id = lab_id
5✔
31

32
        with open(cache_file, "rb") as fd:
5✔
33
            lab = load(fd, Loader=Loader)
5✔
34

35
            self.__title = lab["lab"]["title"]
5✔
36
            self.__description = lab["lab"]["description"]
5✔
37
            self.__stats["nodes"] = len(lab["nodes"])
5✔
38
            self.__stats["links"] = len(lab["links"])
5✔
39
            for n in lab["nodes"]:
5✔
40
                self.__stats["interfaces"] += len(n["interfaces"])
5✔
41

42
    @property
5✔
43
    def id(self):
5✔
44
        return self.__id
5✔
45

46
    @property
5✔
47
    def title(self):
5✔
48
        return self.__title
5✔
49

50
    @property
5✔
51
    def description(self):
5✔
52
        return self.__description
5✔
53

54
    def state(self):
5✔
55
        return "CACHED"
5✔
56

57
    @property
5✔
58
    def statistics(self):
5✔
59
        return self.__stats
5✔
60

61
    @property
5✔
62
    def owner(self):
5✔
63
        return "N/A"
5✔
64

65
    @property
5✔
66
    def username(self):
5✔
UNCOV
67
        return "N/A"
×
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