Esempio n. 1
0
def does_topic_with_url_fragment_exist(url_fragment):
    """Checks if topic with provided url fragment exists.

    Args:
        url_fragment: str. The url fragment for the topic.

    Returns:
        bool. Whether the the url fragment for the topic exists.

    Raises:
        Exception. Topic URL fragment is not a string.
    """
    if not isinstance(url_fragment, python_utils.BASESTRING):
        raise utils.ValidationError('Topic URL fragment should be a string.')
    existing_topic = (topic_fetchers.get_topic_by_url_fragment(url_fragment))
    return existing_topic is not None
Esempio n. 2
0
 def test_get_topic_by_url_fragment(self) -> None:
     topic: Optional[topic_domain.Topic] = (
         topic_fetchers.get_topic_by_url_fragment('name-one'))
     # Ruling out the possibility of None for mypy type checking.
     assert topic is not None
     self.assertEqual(topic.url_fragment, 'name-one')
Esempio n. 3
0
 def test_get_topic_by_url_fragment(self):
     topic = topic_fetchers.get_topic_by_url_fragment('name-one')
     self.assertEqual(topic.url_fragment, 'name-one')