Esempio n. 1
0
 def test_add_empty_name_ingredients(self):
     m = Mock()
     d = Dish("", [])
     m.merge_one = Mock(return_value = Node("Dish", name = "Dish"))
     m.cypher.execute_one = Mock(return_value = Node("Ingredient", name = "Ingredient"))
     m.create = Mock(return_value = tuple())
     self.assertEqual(d.add(m), None)
Esempio n. 2
0
 def test_add_create_fail(self):
     m = Mock()
     d = Dish("Dish", ["Ingredient"])
     m.merge_one = Mock(return_value = Node("Dish", name = "Dish"))
     m.cypher.execute_one = Mock(return_value = Node("Ingredient", name = "Ingredient"))
     m.create.side_effect = Exception()
     self.assertEqual(d.add(m), 0)
Esempio n. 3
0
 def test_initialize_merge_create_fail(self):
     m = Mock()
     c = Cookbook()
     m.merge_one = Mock(return_value = Node("Dish", name = "Dish"))
     m.cypher.execute_one.side_effect = Exception()
     m.create.side_effect = Exception()
     self.assertEqual(c.initialize(m), 0)
Esempio n. 4
0
 def test_initialize(self):
     m = Mock()
     c = Cookbook()
     m.merge_one = Mock(return_value = Node("Dish", name = "Dish"))
     m.cypher.execute_one = Mock(return_value = Node("Ingredient", name = "Ingredient"))
     m.create = Mock(return_value = tuple())
     self.assertEqual(c.initialize(m), 1)
Esempio n. 5
0
    def test_initialize_empty_name_ingredient(self):
        m = Mock()
        c = Cookbook()
        m.merge_one = Mock(return_value = Node("Dish", name = "Dish"))
        m.cypher.execute_one = Mock(return_value = Node("Ingredient", name = "Ingredient"))
        m.create = Mock(return_value = tuple())

        def initialize(client = neo4j.Graph("http://localhost:7474/db/data/")):
            d = Dish("", [])
            return d.add(client)

        c.initialize = initialize

        self.assertEqual(c.initialize(m), None)
Esempio n. 6
0
 def test_add_emtpy_name(self):
     m = Mock()
     i = Ingredient("")
     m.merge_one = Mock(return_value = Node("", name = i.name))
     self.assertEqual(i.add(m), None)
Esempio n. 7
0
 def test_add(self):
     m = Mock()
     i = Ingredient("Ingredient")
     m.merge_one = Mock(return_value = Node("Ingredient", name = i.name))
     self.assertEqual(i.add(m)["name"], i.name)