File: test_summarystate.py

package info (click to toggle)
opm-common 2025.10%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 96,920 kB
  • sloc: cpp: 291,772; python: 3,609; sh: 198; xml: 174; pascal: 136; makefile: 12
file content (46 lines) | stat: -rw-r--r-- 1,387 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import datetime
import unittest

import opm.io.sim

class TestSummaryState(unittest.TestCase):

    def setUp(self):
        pass

    def test_create(self):
        st = opm.io.sim.SummaryState(int(datetime.datetime.now().timestamp()))
        st.update("FOPT", 100)
        self.assertEqual(st["FOPT"], 100)
        self.assertTrue("FOPT" in st)
        self.assertFalse("FWPR" in st)

        with self.assertRaises(IndexError):
            x = st["FWPR"]

        st.update_well_var("OP1", "WOPR", 100)
        st.update_well_var("OP2", "WOPR", 200)
        st.update_well_var("OP3", "WOPR", 300)
        self.assertEqual(st.well_var("OP1", "WOPR"), 100)

        st.update_group_var("G1", "GOPR", 100)
        st.update_group_var("G2", "GOPR", 200)
        st.update_group_var("G3", "GOPR", 300)
        self.assertEqual(st.group_var("G3", "GOPR"), 300)

        self.assertTrue(st.has_group_var("G1", "GOPR"))
        self.assertFalse(st.has_well_var("OP1", "GOPR"))

        groups = st.groups
        self.assertEqual(len(groups), 3)
        self.assertTrue( "G1" in groups )
        self.assertTrue( "G2" in groups )
        self.assertTrue( "G3" in groups )

        wells = st.wells
        self.assertEqual(len(wells), 3)
        self.assertTrue( "OP1" in wells )
        self.assertTrue( "OP2" in wells )
        self.assertTrue( "OP3" in wells )

        el = st.elapsed()