コード例 #1
0
def test_heures_creuses():
    myE = myEnedis.myEnedis("myToken", "myPDL")
    heureCreusesCh = eval("[['00:00','05:00'], ['22:00', '24:00']]")
    heuresCreusesON = True
    myE = myEnedis.myEnedis("myToken",
                            "myPDL",
                            heuresCreuses=heureCreusesCh,
                            heuresCreusesON=heuresCreusesON)
    dataJson = loadJsonFile("tests/Json/Contract/contract1.json")
    myE.updateContract(dataJson)
    myE.updateHCHP()
    dataCompare = [['00:00', '05:00'], ['22:00', '24:00']]
    assert myE.getHeuresCreuses() == dataCompare, "erreur format HC/HP 1"
    #***********
    heureCreusesCh = None
    heuresCreusesON = False
    myE = myEnedis.myEnedis("myToken",
                            "myPDL",
                            heuresCreuses=heureCreusesCh,
                            heuresCreusesON=heuresCreusesON)
    dataJson = loadJsonFile("tests/Json/Contract/contract1.json")
    myE.updateContract(dataJson)
    myE.updateHCHP()
    dataCompare = []
    assert myE.getHeuresCreuses() == dataCompare, "erreur format HC/HP 2"
コード例 #2
0
def test_update_last7days():
    myE = myEnedis.myEnedis("myToken", "myPDL")
    dataJson = loadJsonFile("tests/Json/Week/week1.json")
    myE.updateLast7Days(dataJson)
    dataCompare = [{
        'date': '2020-12-09',
        'niemejour': 1,
        'value': 42951
    }, {
        'date': '2020-12-08',
        'niemejour': 2,
        'value': 35992
    }, {
        'date': '2020-12-07',
        'niemejour': 3,
        'value': 46092
    }, {
        'date': '2020-12-06',
        'niemejour': 4,
        'value': 37753
    }, {
        'date': '2020-12-05',
        'niemejour': 5,
        'value': 38623
    }, {
        'date': '2020-12-04',
        'niemejour': 6,
        'value': 38633
    }, {
        'date': '2020-12-03',
        'niemejour': 7,
        'value': 33665
    }]
    assert myE.getLast7Days() == dataCompare, "Error last7Days"
コード例 #3
0
def test_update_yesterday_error():
    myE = myEnedis.myEnedis("myToken", "myPDL")
    dataJson = loadJsonFile("tests/Json/Error/error1.json")
    try:
        myE.updateYesterday(dataJson)
    except Exception as e:
        assert e.args[2] == "UNKERROR_001", "Erreur UNKERROR_001"
コード例 #4
0
def test_horaire_surcharge():
    hc = [['23:30', '23:59'], ['00:00', '07:35']]
    myE = myEnedis.myEnedis("myToken", "myPDL", heuresCreuses=hc)
    dataJson = loadJsonFile("tests/Json/Contract/contract1.json")
    myE.updateContract(dataJson)
    myE.updateHCHP()
    dataCompare = hc
    assert myE._heuresCreuses == dataCompare, "erreur format HC/HP"
コード例 #5
0
def test_update_contract():
    myE = myEnedis.myEnedis("myToken", "myPDL")
    dataJson = loadJsonFile("tests/Json/Contract/contract1.json")
    myE.updateContract(dataJson)
    assert myE.getsubscribed_power() == "9 kVA", "bad subscribed"
    assert myE.getoffpeak_hours() == "HC (23H30-7H30)", "bad hour"
    assert myE.getLastActivationDate() == "2007-07-06", "bad date activation"
    dataCompare = [['23:30', '23:59'], ['00:00', '07:30']]
    assert myE.getcleanoffpeak_hours() == dataCompare, "erreur format HC/HP"
コード例 #6
0
def call_update_yesterdayHCHP(filename):
    myE = myEnedis.myEnedis("myToken", "myPDL")
    dataJson = loadJsonFile("tests/Json/Contract/contract1.json")
    myE.updateContract(dataJson)
    dataJson = loadJsonFile(filename)
    yesterdayDate = (datetime.date.today() -
                     datetime.timedelta(1)).strftime("%Y-%m-%d")
    myE.updateDataYesterdayHCHP(dataJson, yesterdayDate)
    return myE
コード例 #7
0
def call_update_current_month(fileName):
    myE = myEnedis.myEnedis("myToken", "myPDL")
    dataJson = loadJsonFile(fileName)
    myE.updateCurrentMonth(dataJson)
    return myE
コード例 #8
0
def test_update_last_month():
    myE = myEnedis.myEnedis("myToken", "myPDL")
    dataJson = loadJsonFile("tests/Json/Month/month1.json")
    myE.updateLastMonth(dataJson)
    assert myE.getLastMonth() == 876699, "Error LastMonthData"
コード例 #9
0
def test_updateProductionYesterday():
    myE = myEnedis.myEnedis("myToken", "myPDL")
    dataJson = loadJsonFile("tests/Json/Production/error1.json")
    myE.updateProductionYesterday(dataJson)
    assert myE.getProductionYesterday() == 0, "Erreur production Value"
コード例 #10
0
def call_update_yesterday(filename):
    myE = myEnedis.myEnedis("myToken", "myPDL")
    dataJson = loadJsonFile(filename)
    myE.updateYesterday(dataJson)
    return myE