Exemplo n.º 1
0
    def setUp(self):
        self.nemo = Fish("Nemo")
        self.dory = Fish("Dory")
        self.marlin = Fish("Marlin")

        self.nile = River("Nile")

        self.baloo = Bear("Baloo")

        self.nile.add_fish(self.nemo)
        self.nile.add_fish(self.dory)
Exemplo n.º 2
0
class TestBear(TestCase):
    def setUp(self):
        self.nemo = Fish("Nemo")
        self.dory = Fish("Dory")
        self.marlin = Fish("Marlin")

        self.nile = River("Nile")

        self.baloo = Bear("Baloo")

        self.nile.add_fish(self.nemo)
        self.nile.add_fish(self.dory)

    def test_can_get_name(self):
        self.assertEqual(self.baloo.get_name(), "Baloo")

    def test_can_count_stomach_contents(self):
        self.assertEqual(self.baloo.count_stomach_contents(), 0)

    def test_can_add_fish_to_stomach(self):
        self.baloo.eat_fish(self.marlin)
        self.assertEqual(self.baloo.count_stomach_contents(), 1)

    def test_can_see_stomach_contents(self):
        self.baloo.eat_fish(self.marlin)
        self.assertEqual(self.baloo.get_stomach_contents(), [self.marlin])

    def test_can_be_sick(self):
        self.baloo.eat_fish(self.marlin)
        self.baloo.be_sick()
        self.assertEqual(self.baloo.count_stomach_contents(), 0)

    def test_bear_can_eat_fish_from_river(self):
        self.baloo.eat_fish(self.marlin)
        self.baloo.eat_fish_from_river(self.nemo, self.nile)
        self.assertEqual(self.baloo.get_stomach_contents(),
                         [self.marlin, self.nemo])
        self.assertEqual(self.nile.count_fish(), 1)
Exemplo n.º 3
0
from ex1 import mlab_connect
from models.river import River

mlab_connect()

rivers = River.objects(continent = 'Africa')

if len(rivers) == 0:
    print("Not found")
else:
    for river in rivers:
        print(river)
def s_america():
    all_rivers = River.objects(continent="S. America", lenght__lt=1000)
    return render_template('rivers.html', all_rivers=all_rivers)
Exemplo n.º 5
0
from pymongo import *
import mlab
from models.river import River
mlab.connect()

all_rivers_in_africa = River.objects()

for river in all_rivers_in_africa:
    if river['continent'] == 'S. America' and river['length'] < 1000:
        print(river['name'])
Exemplo n.º 6
0
def river_america():
    name_list = River.objects(continent="S. America", length__lt=1000)
    return render_template("ex23.html", name_list=name_list)
def africa():
    all_rivers = River.objects(continent="Africa")
    return render_template('rivers.html', all_rivers=all_rivers)
def rivers1():
    africa_river_list = River.objects(continent__icontains="S. America",
                                      length__lt=1000)
    return render_template("rivers1.html", africa_river_list=africa_river_list)
def river_africa():
    river_list = River.objects(continent='Africa')
    return render_template("river.html",river_list=river_list)
Exemplo n.º 10
0
from models.river import River
import mlab7

mlab7.connect()

SA_river = River.objects(continent = "S. America")

for river in SA_river:
    if river["length"] <= 1000:
        print(river["name"])
        print("- "*10)
Exemplo n.º 11
0
from models.river import River
import mlab7

mlab7.connect()

Africa_river = River.objects(continent="Africa")

for river in Africa_river:
    print(river["name"])
    print(river["length"])
    print("- " * 10)
 def setUp(self):
     self.nile = River("Nile")
     self.nemo = Fish("Nemo")
     self.dory = Fish("Dory")
Exemplo n.º 13
0
from models.river import River
import river.mlab

river.mlab.connect()

river_SA_1000 = River.objects(continent = "S. America", length__lt=1000) 

for river in river_SA_1000:
    print(river.name)
    print(river.length)
    print("*" * 10)
class TestRiver(TestCase):
    def setUp(self):
        self.nile = River("Nile")
        self.nemo = Fish("Nemo")
        self.dory = Fish("Dory")

    def test_can_get_name(self):
        self.assertEqual(self.nile.get_name(), "Nile")

    def test_can_add_fish(self):
        self.nile.add_fish(self.nemo)
        self.assertEqual(self.nile.count_fish(), 1)

    def test_can_remove_fish(self):
        self.nile.add_fish(self.nemo)
        self.nile.remove_fish(self.nemo)
        self.assertEqual(self.nile.count_fish(), 0)

    def test_can_remove_all_fish(self):
        self.nile.add_fish(self.nemo)
        self.nile.add_fish(self.dory)
        self.nile.remove_all_fish()
        self.assertEqual(self.nile.count_fish(), 0)
from models.river import River
import mlab7

mlab7.connect()

river_in_SAmerica_lt1000km = River.objects(continent="S. America",
                                           length__lt=1000)

for river in river_in_SAmerica_lt1000km:
    print(river.name)
    print(river.length)
    print("* " * 20)
from mlab import mlab_connect
from models.river import River

mlab_connect()

african_rivers = River.objects(continent="Africa")
for river in african_rivers:
    print(river)

samerican_rivers_1000 = River.objects(continent='S. America', length__lt=1000)
for river in samerican_rivers_1000:
    print(river)
Exemplo n.º 17
0
import mlab
from models.river import River

mlab.connect()

print("ex2")
river_list = River.objects(continent__iexact="Africa")
for river in river_list:
    print(river.name)

print("ex3")
river_list = River.objects(continent__iexact="S. America", length__lt=1000)
for river in river_list:
    print(river.name, river.length)
Exemplo n.º 18
0
import mlab
from models.river import River

mlab.connect()

Africa_river_list = River.objects(continent__icontains="Africa")
print("all river in Africa: ", end="")
for river in Africa_river_list:
    print(river.name, end=", ")
print()
print()

S_America_river_list = River.objects(continent__icontains="S. America",
                                     length__lt=1000)
print("all river in S.America with length less than 1000km: ", end="")
for river in S_America_river_list:
    print(river.name, end=", ")
Exemplo n.º 19
0
import mlab
from models.river import River

mlab7.connect()

#Ex8

river_in_Africa = River.objects(continent="Africa")

print(river_in_Africa)

#Ex9

river_less_than_1000 = River.objects(continent="S. America", length__lt=1000)

print(river_less_than_1000)
Exemplo n.º 20
0
from models.river import River
import mlab7

mlab7.connect()

all_river_s = River.objects(continent="S. America", length=1000)

for river2 in all_river_s:
    print(river2.name)
    print()
Exemplo n.º 21
0
def rivers():
    africa_river_list = River.objects(continent__icontains="Africa")
    return render_template("rivers.html", africa_river_list=africa_river_list)
from models.river import River
import mlab1

mlab1.connect()

rivers = River.objects(continent = "Africa")
print ("All river in Africa")
for item in rivers:
    print(item.name)
    
print("-" * 20)
print ("All river in S.America with length less than 1000km")
short_river = River.objects(continent ="S. America",length__lt = 1000)
for item in short_river:
    print(item.name,':',item.length)
    

def river_samerica():
    river_list = River.objects(continent='S.America',length__lt=100)
    return render_template('river.html',river_list=river_list)
from ex1 import mlab_connect
from models.river import River

mlab_connect()

rivers = River.objects(continent='S. America', length__lt=1000)

if len(rivers) == 0:
    print("Not found")
else:
    for river in rivers:
        print(river, river.length)
Exemplo n.º 25
0
from models.river import River
import mlab7

mlab7.connect()

river_in_Africa = River.objects(continent="Africa")

for river in river_in_Africa:
    print(river.name)
    print(river.length)
    print("* " * 20)
Exemplo n.º 26
0
def river():
    name_list = River.objects(continent="Africa")
    return render_template("ex23.html", name_list=name_list)