import unittest
from modelverse_state.main import ModelverseState

class TestReadKeys(unittest.TestCase):
    def setUp(self):
        self.mvs = ModelverseState()

    def test_read_dict_keys_no_exists(self):
        l = self.mvs.read_dict_keys(100000)
        assert l == None

    def test_read_dict_keys_simple(self):
        a = self.mvs.create_node()
        b = self.mvs.create_node()
        c = self.mvs.create_nodevalue("f")
        d = self.mvs.create_edge(a, b)
        e = self.mvs.create_edge(d, c)
        assert a != None
        assert b != None
        assert c != None
        assert d != None
        assert e != None

        l = self.mvs.read_dict_keys(a)
        assert l != None
        assert set(l) == set([c])

    def test_read_dict_keys_multi(self):
        a = self.mvs.create_node()
        b = self.mvs.create_node()
        c = self.mvs.create_nodevalue("f")
        d = self.mvs.create_edge(a, b)
        e = self.mvs.create_edge(d, c)
        assert a != None
        assert b != None
        assert c != None
        assert d != None
        assert e != None

        g = self.mvs.create_node()
        h = self.mvs.create_nodevalue("k")
        i = self.mvs.create_edge(a, g)
        j = self.mvs.create_edge(i, h)
        assert g != None
        assert h != None
        assert i != None
        assert j != None

        l = self.mvs.read_dict_keys(a)
        assert l != None
        assert set(l) == set([c, h])
