예제 #1
0
class TestDatabase(unittest.TestCase):
    def setUp(self):
        prepare_db_for_tests()

        self.depute = Depute(test_depute)
        self.depute = self.depute.save()

    def tearDown(self):
        Depute.collection.remove()
        Extra.collection.remove()

    def test_for_memopol(self):
        self.assertEqual(self.depute.for_memopol, u"EricCiotti")

    def test_an_id(self):
        self.assertEqual(self.depute.an_id, '330240')

    def test_get_extra(self):
        self.assertTrue(isinstance(self.depute.extra, Extra))

    def test_extra_saved(self):
        self.depute.extra
        self.assertEqual(Extra.collection.count(), 1)

    def test_extra_save_depute_id(self):
        self.assertEqual(self.depute.extra.depute_id, self.depute._id)

    def test_extra_the_same(self):
        extra = self.depute.extra
        self.assertEqual(extra, self.depute.extra)

    def test_extra_get_depute(self):
        self.assertEqual(self.depute, self.depute.extra.depute)
예제 #2
0
class TestDatabase(unittest.TestCase):
    def setUp(self):
        prepare_db_for_tests()

        self.depute = Depute(test_depute)
        self.depute = self.depute.save()

    def tearDown(self):
        Depute.collection.remove()
        Extra.collection.remove()

    def test_for_memopol(self):
        self.assertEqual(self.depute.for_memopol, u"EricCiotti")

    def test_an_id(self):
        self.assertEqual(self.depute.an_id, '330240')

    def test_get_extra(self):
        self.assertTrue(isinstance(self.depute.extra, Extra))

    def test_extra_saved(self):
        self.depute.extra
        self.assertEqual(Extra.collection.count(), 1)

    def test_extra_save_depute_id(self):
        self.assertEqual(self.depute.extra.depute_id, self.depute._id)

    def test_extra_the_same(self):
        extra = self.depute.extra
        self.assertEqual(extra, self.depute.extra)

    def test_extra_get_depute(self):
        self.assertEqual(self.depute, self.depute.extra.depute)
예제 #3
0
 def setUp(self):
     prepare_db_for_tests()
     self.app = FlaskClient(app, response_wrapper=FormWrapper)
     self.app.application.config["CSRF_ENABLED"] = False
     self.depute = Depute(test_depute).save()
     self.user = create_user("test", "test")
     self.ctx = app.test_request_context()
     self.ctx.push()
예제 #4
0
 def setUp(self):
     prepare_db_for_tests()
     self.user = create_user("pouet", "pouet")
     self.depute = Depute(test_depute).save()
예제 #5
0
    def setUp(self):
        prepare_db_for_tests()

        self.depute = Depute(test_depute)
        self.depute = self.depute.save()
예제 #6
0
from json import load
from urllib import urlopen
from database import Depute

if __name__ == '__main__':
    for depute in load(
            urlopen(
                "http://www.nosdeputes.fr/deputes/enmandat/json"))["deputes"]:
        dep = depute["depute"]
        if not Depute.collection.find_one({"id": dep["id"]}):
            print "add new dep:", dep["nom"]
            Depute(dep).save()
예제 #7
0
    def setUp(self):
        prepare_db_for_tests()

        self.depute = Depute(test_depute)
        self.depute = self.depute.save()