def test_Routine(self): person = mysql.Person(name="unit") self.session.add(person) self.session.commit() self.session.add( mysql.Routine(person_id=person.id, name='Unit Test', data={"a": 1})) self.session.commit() routine = self.session.query(mysql.Routine).one() self.assertEqual( str(routine), "<Routine(name='Unit Test',person='unit',created=7)>") self.assertEqual(routine.person_id, person.id) self.assertEqual(routine.name, "Unit Test") self.assertEqual(routine.status, "opened") self.assertEqual(routine.created, 7) self.assertEqual(routine.updated, 7) self.assertEqual(routine.data, {"a": 1}) routine.data["a"] = 2 self.session.commit() routine = self.session.query(mysql.Routine).one() self.assertEqual(routine.data, {"a": 2})
def person(self, name, data=None): people = self.session.query(mysql.Person).filter_by(name=name).all() if people: return people[0] person = mysql.Person(name=name, data=data) self.session.add(person) self.session.commit() return person
def test_Person(self): self.session.add(mysql.Person(name="unit", data={"a": 1})) self.session.commit() person = self.session.query(mysql.Person).one() self.assertEqual(str(person), "<Person(name='unit')>") self.assertEqual(person.name, "unit") self.assertEqual(person.data, {"a": 1}) person.data["a"] = 2 self.session.commit() person = self.session.query(mysql.Person).one() self.assertEqual(person.data, {"a": 2})
def test_Area(self): person = mysql.Person(name="unit") self.session.add(person) self.session.commit() self.session.add( mysql.Area(person_id=person.id, name='Unit Test', data={"a": 1})) self.session.commit() area = self.session.query(mysql.Area).one() self.assertEqual(str(area), "<Area(name='Unit Test')>") self.assertEqual(area.person_id, person.id) self.assertEqual(area.name, "Unit Test") self.assertEqual(area.status, "positive") self.assertEqual(area.created, 7) self.assertEqual(area.updated, 7) self.assertEqual(area.data, {"a": 1}) area.data["a"] = 2 self.session.commit() area = self.session.query(mysql.Area).one() self.assertEqual(area.data, {"a": 2})
def test_Todo(self): person = mysql.Person(name="unit") self.session.add(person) self.session.commit() self.session.add( mysql.ToDo(person_id=person.id, name='Unit Test', data={"a": 1})) self.session.commit() todo = self.session.query(mysql.ToDo).one() self.assertEqual(str(todo), "<ToDo(name='Unit Test',person='unit',created=7)>") self.assertEqual(todo.person_id, person.id) self.assertEqual(todo.name, "Unit Test") self.assertEqual(todo.status, "opened") self.assertEqual(todo.created, 7) self.assertEqual(todo.updated, 7) self.assertEqual(todo.data, {"a": 1}) todo.data["a"] = 2 self.session.commit() todo = self.session.query(mysql.ToDo).one() self.assertEqual(todo.data, {"a": 2})
def test_Act(self): person = mysql.Person(name="unit") self.session.add(person) self.session.commit() self.session.add( mysql.Act(person_id=person.id, name='Unit Test', data={"a": 1})) self.session.commit() act = self.session.query(mysql.Act).one() self.assertEqual(str(act), "<Act(name='Unit Test',person='unit',created=7)>") self.assertEqual(act.person_id, person.id) self.assertEqual(act.name, "Unit Test") self.assertEqual(act.status, "positive") self.assertEqual(act.created, 7) self.assertEqual(act.updated, 7) self.assertEqual(act.data, {"a": 1}) act.data["a"] = 2 self.session.commit() act = self.session.query(mysql.Act).one() self.assertEqual(act.data, {"a": 2})