コード例 #1
0
ファイル: url.py プロジェクト: VladTurbureanu/Zeeguu-API
 def find(cls, url, title=""):
     try:
         d = DomainName.find(Url.get_domain(url))
         return (cls.query.filter(cls.path == Url.get_path(url)).filter(
             cls.domain == d).one())
     except sqlalchemy.orm.exc.NoResultFound:
         return cls(url, title)
コード例 #2
0
ファイル: url.py プロジェクト: MrAlexDeluxe/Zeeguu-API
 def find(cls, url, title = ""):
     try:
         d = DomainName.find(Url.get_domain(url))
         return (cls.query.filter(cls.path == Url.get_path(url))
                          .filter(cls.domain == d)
                          .one())
     except sqlalchemy.orm.exc.NoResultFound:
         return cls(url, title)
コード例 #3
0
def set_default_exercise_based_prob():
    zeeguu.app.test_request_context().push()
    zeeguu.db.session.commit()

    urls = Url.query.all()

    for url in urls:
        url.path = Url.get_path(url.url)
        d = DomainName.find(Url.get_domain(url.url))
        url.domain = d

        zeeguu.db.session.add(url)
        zeeguu.db.session.add(d)
        zeeguu.db.session.commit()
コード例 #4
0
def set_default_exercise_based_prob():
    zeeguu.app.test_request_context().push()
    zeeguu.db.session.commit()

    urls = Url.query.all()

    for url in urls:
        url.path = Url.get_path(url.url)
        d = DomainName.find(Url.get_domain(url.url))
        url.domain = d

        zeeguu.db.session.add(url)
        zeeguu.db.session.add(d)
        zeeguu.db.session.commit()
コード例 #5
0
    def test_one_domain_multiple_urls(self):
        """
        Tests that if multiple URLs are added to the database that their
        DomainName is not added to the database more than once
        """
        # Create an 'original' URL, which is saved to the Database
        url_random_obj_origin = UrlRule().url

        # Create a random number of URLs, each with the same DomainName
        random_num = random.randint(0, 10)
        for _ in range(0, random_num):
            url_random_extended = url_random_obj_origin.as_string() + self.faker.word()
            _ = Url(url_random_extended, self.faker.word())

        domain_for_query = url_random_obj_origin.domain_name()

        try:
            assert DomainName.find(domain_for_query)
        except NoResultFound:
            assert False, "No domains found in database"
        except MultipleResultsFound:
            assert False, "There were multiple DomainNames in the database"
コード例 #6
0
ファイル: url.py プロジェクト: alinbalutoiu/Zeeguu-Core
 def find(cls, url, title=""):
     d = DomainName.find(Url.get_domain(url))
     return (cls.query.filter(cls.path == Url.get_path(url)).filter(
         cls.domain == d).one())
コード例 #7
0
ファイル: url.py プロジェクト: VladTurbureanu/Zeeguu-API
 def __init__(self, url, title):
     self.path = Url.get_path(url)
     self.domain = DomainName.find(Url.get_domain(url))
     self.title = title
コード例 #8
0
ファイル: url.py プロジェクト: MrAlexDeluxe/Zeeguu-API
 def __init__(self, url, title):
     self.path = Url.get_path(url)
     self.domain = DomainName.find(Url.get_domain(url))
     self.title = title