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

winter-telescope / wintertoo / 5204407286

pending completion
5204407286

Pull #5

github-actions

web-flow
Merge 2ddc15d53 into 3ec90a668
Pull Request #5: Prep for v0.4

249 of 249 new or added lines in 11 files covered. (100.0%)

245 of 423 relevant lines covered (57.92%)

1.74 hits per line

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

87.1
/wintertoo/models/program.py
1
"""
2
Base model for the program database
3

4
Duplicated (sorry) from mirar/pipelines/summer/models/program.py, to avoid
5
an elaborate web of imports for WSP.
6
"""
7
from datetime import date
3✔
8

9
from pydantic import BaseModel, Extra, Field, validator
3✔
10

11
_LEN_PROG_KEY = 60
3✔
12

13

14
class ProgramCredentials(BaseModel):
3✔
15
    """
16
    Program credentials to access a program
17
    """
18

19
    progname: str = Field(min_length=8, max_length=8, example="2020A000")
3✔
20
    prog_key: str = Field(min_length=_LEN_PROG_KEY, max_length=_LEN_PROG_KEY)
3✔
21

22

23
class Program(ProgramCredentials):
3✔
24
    """
25
    A pydantic model for a program database entry
26
    """
27

28
    progid: int = Field(default=1)
3✔
29
    pi_name: str = Field(min_length=1, example="Hubble", default=None)
3✔
30
    pi_email: str = Field(min_length=1, example="someone@institute.com", default=None)
3✔
31
    startdate: date = Field()
3✔
32
    enddate: date = Field()
3✔
33
    hours_allocated: float = Field(ge=0.0, default=None)
3✔
34
    hours_remaining: float = Field(ge=0.0, default=None)
3✔
35
    maxpriority: float = Field(description="Max priority")
3✔
36
    progtitle: str = Field(min_length=1, example="A program title", default=None)
3✔
37

38
    @validator("enddate")
3✔
39
    @classmethod
3✔
40
    def check_date(cls, field_value, values):
3✔
41
        """
42
        Ensure dates are correctly formatted
43

44
        """
45
        startdate = values["startdate"]
3✔
46
        assert field_value > startdate
3✔
47
        return field_value
3✔
48

49
    @validator("hours_remaining")
3✔
50
    @classmethod
3✔
51
    def validate_time_allocation(cls, field_value, values):
3✔
52
        """
53
        Ensure that time remaining has a sensible value
54

55
        :param field_value: field value
56
        :param values: values
57
        :return: field value
58
        """
59
        total_time = values["hours_allocated"]
×
60
        assert not field_value > total_time
×
61
        assert not field_value < 0.0
×
62
        return field_value
×
63

64
    class Config:  # pylint: disable=missing-class-docstring,too-few-public-methods
3✔
65
        extra = Extra.forbid
3✔
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

© 2026 Coveralls, Inc