Exemple #1
0
    def test_throttled_consumer(self):

        s = Source(PipedWater, 0.5) + Sink(PipedWater, 1.0)
        s.balance()
        a, b = s.subsystems
        assert_almost_equal(a.uptime, 1)
        assert_almost_equal(b.uptime, 0.5)
Exemple #2
0
    def test_full_throughput_balance(self):

        s = Source(PipedWater, 1) + Sink(PipedWater, 1)
        s.balance()
        a, b = s.subsystems
        assert_almost_equal(a.uptime, 1)
        assert_almost_equal(b.uptime, 1)
Exemple #3
0
    def test_balance_idempotence(self):

        s = Source(PipedWater, 0.5) + Sink(PipedWater, 1.0)
        s.balance()
        s.balance()

        a, b = s.subsystems
        assert_almost_equal(a.uptime, 1)
        assert_almost_equal(b.uptime, 0.5)
Exemple #4
0
    def test_missing_consumer(self):

        # Gives but doesn't need heat
        s = Source(Power, 10) + CeilingLight()
        s.balance()

        a, b = s.subsystems
        assert_almost_equal(a.uptime, 1)
        assert_almost_equal(b.uptime, 1)
Exemple #5
0
    def test_rmul(self):

        machine = Source(PipedWater, 1)
        s = 3 * machine

        assert len(s.subsystems) == 1
        assert s.gives()[PipedWater] == 3
Exemple #6
0
 def test_impute_sink(self):
     s = System(Source(PipedWater, 5)).impute()
     assert len(s) == 2
     assert isinstance(s[1], Sink)
     assert s[1].resource == PipedWater
     assert s[1].qty == 5
Exemple #7
0
 def test_index(self):
     s = Electrolyzer() + Source(PipedWater, 1)
     assert isinstance(s[0], Electrolyzer)
     assert isinstance(s[1], Source)
Exemple #8
0
    def test_system_machine_addition(self):
        machines = Electrolyzer(), Source(PipedWater, 1), Source(Power, 120)

        s = (machines[0] + machines[1]) + machines[2]
        assert s.subsystems == machines
Exemple #9
0
    def test_addition(self):
        machines = Electrolyzer(), Source(PipedWater, 1)

        s = machines[0] + machines[1]
        assert s.subsystems == machines
Exemple #10
0
 def test_source_name(self):
     e = Source(Power, 10)
     assert str(e) == "Source(Power, 10) [100.0% Uptime]"
Exemple #11
0
 def test_heavy_consumer(self):
     s = Source(Power, 1) + Sink(Power, 1e3)
     s.balance()
     print(s)
     assert_almost_equal(s[0].uptime, 1, 6)
     assert_almost_equal(s[1].uptime, 1e-3, 6)
Exemple #12
0
 def test_heavy_producer(self):
     s = Source(Power, 1e3) + Sink(Power, 1)
     s.balance()
     assert_almost_equal(s[0].uptime, 1, 6)
     assert_almost_equal(s[1].uptime, 1, 6)
Exemple #13
0
    def test_neutralize(self):

        s = System(Source(PipedWater, 0.5))
        s.balance(neutralize=PipedWater)
        assert_almost_equal(s[0].uptime, 0)
Exemple #14
0
 def test_neutralize_all(self):
     s = Source(PipedWater, 2) + Source(Oxygen, 2)
     s.balance(neutralize='all')
     assert_almost_equal(s[0].uptime, 0)
     assert_almost_equal(s[1].uptime, 0)
Exemple #15
0
 def test_overlapping_gives(self):
     """Multiple subsystems with overlapping gives combine"""
     s = Source(PipedWater, 1) * 2
     assert s.gives()[PipedWater] == 2