Example #1
0
    def test_me_resource(self):
        """Загрузка профиля с ресурса /me/.
        Требует авторизации.

        """
        person = pyyaru.yaPerson(resource_uri_me).get()
        self.assertNotEqual(person.id, resource_uri_me)
Example #2
0
    def test_me_resource(self):
        """Загрузка профиля с ресурса /me/.
        Требует авторизации.

        """
        person = pyyaru.yaPerson(resource_uri_me).get()
        self.assertNotEqual(person.id, resource_uri_me)
Example #3
0
    def test_create_delete(self):
        """Проверка создания и удаления публикации.
        Требует авторизации.

        """
        me = pyyaru.yaPerson(resource_uri_me).get()
        entry = pyyaru.yaEntry(
            attributes={
                'type': 'text',
                'title': 'Тестовый заголовок из pyyaru',
                'content': 'Это сообщение является тестовым.',
                'access': 'private',
                'comments_disabled': True,
            }).save(me.links['posts'])
        self.assertNotEqual(entry.id, None)
        entry.delete()
        self.assertEqual(entry.id, None)
Example #4
0
    def test_create_delete(self):
        """Проверка создания и удаления публикации.
        Требует авторизации.

        """
        me = pyyaru.yaPerson(resource_uri_me).get()
        entry = pyyaru.yaEntry(
            attributes={
                "type": "text",
                "title": "Тестовый заголовок из pyyaru",
                "content": "Это сообщение является тестовым.",
                "access": "private",
                "comments_disabled": True,
            }
        ).save(me.links["posts"])
        self.assertNotEqual(entry.id, None)
        entry.delete()
        self.assertEqual(entry.id, None)
Example #5
0
 def test_lazy_load_on_attrib_access(self):
     """Автоматическое наполнение объекта при обращении к отсутствующему свойству."""
     person = pyyaru.yaPerson(resource_url_person)
     city = person.city
     self.assertEqual(person.id, resource_urn_person)
Example #6
0
 def test_chaining_load(self):
     """Загрузка профиля, используя get() в цепи."""
     person = pyyaru.yaPerson(resource_url_person).get()
     self.assertEqual(person.id, resource_urn_person)
Example #7
0
 def test_type(self):
     """Соответствие типа ресура имени класса, заданному строчными буквами без префикса ya."""
     person = pyyaru.yaPerson(resource_urn_person)
     self.assertEqual(person._type, "person")
Example #8
0
 def test_id_isset(self):
     """Запись первого параметра конструктора в свойство id."""
     person = pyyaru.yaPerson(resource_urn_person)
     self.assertEqual(person.id, resource_urn_person)
Example #9
0
 def test_links_list_exists(self):
     """Существование списка со ссылками для данного ресурса."""
     person = pyyaru.yaPerson(resource_url_person).get()
     self.assertEqual('self' in person.links, True)
Example #10
0
 def test_error_typemismatch(self):
     """Крушение в случае несоответствия типа объекта pyyaru."""
     not_a_person = pyyaru.yaPerson(resource_urn_entry)
     self.assertRaises(pyyaru.yaObjectTypeMismatchError, not_a_person.get)
Example #11
0
 def test_lazy_load_on_attrib_access(self):
     """Автоматическое наполнение объекта при обращении к отсутствующему свойству."""
     person = pyyaru.yaPerson(resource_url_person)
     city = person.city
     self.assertEqual(person.id, resource_urn_person)
Example #12
0
 def test_chaining_load(self):
     """Загрузка профиля, используя get() в цепи."""
     person = pyyaru.yaPerson(resource_url_person).get()
     self.assertEqual(person.id, resource_urn_person)
Example #13
0
 def test_type(self):
     """Соответствие типа ресура имени класса, заданному строчными буквами без префикса ya."""
     person = pyyaru.yaPerson(resource_urn_person)
     self.assertEqual(person._type, 'person')
Example #14
0
 def test_id_isset(self):
     """Запись первого параметра конструктора в свойство id."""
     person = pyyaru.yaPerson(resource_urn_person)
     self.assertEqual(person.id, resource_urn_person)
Example #15
0
 def test_error_typemismatch(self):
     """Крушение в случае несоответствия типа объекта pyyaru."""
     not_a_person = pyyaru.yaPerson(resource_urn_entry)
     self.assertRaises(pyyaru.yaObjectTypeMismatchError, not_a_person.get)
Example #16
0
resource_urn_person = "urn:ya.ru:person/96845657"
resource_url_person = "https://api-yaru.yandex.ru/person/96845657/"
resource_url_person_idle = "https://api-yaru.yandex.ru/person/153990/"
resource_url_persons = "https://api-yaru.yandex.ru/person/96845657/friend/"

resource_urn_entry = "urn:ya.ru:post/153990/219"
resource_url_entry = "https://api-yaru.yandex.ru/person/153990/post/219/"
resource_url_entry_imported = "https://api-yaru.yandex.ru/person/153990/post/2116/"
resource_url_entries = "https://api-yaru.yandex.ru/person/153990/post/"

resource_urn_club = "urn:ya.ru:club/4611686018427439760"
resource_url_club = "https://api-yaru.yandex.ru/club/4611686018427439760/"
resource_url_clubs = "https://api-yaru.yandex.ru/person/96845657/club/"

PERSON_FIXTURE = pyyaru.yaPerson(resource_url_person).get()
CLUB_FIXTURE = pyyaru.yaClub(resource_url_club).get()


class yaPersonCheck(unittest.TestCase):
    def test_geitem(self):
        """Проверка возможности доступа к свойстам объекта в нотации self[key]."""
        self.assertEqual(PERSON_FIXTURE["id"], "urn:ya.ru:person/96845657")

    def test_id_isset(self):
        """Запись первого параметра конструктора в свойство id."""
        person = pyyaru.yaPerson(resource_urn_person)
        self.assertEqual(person.id, resource_urn_person)

    def test_id_without_fails(self):
        """Крушение без указания первого параметра конструктора."""
Example #17
0
 def test_links_list_exists(self):
     """Существование списка со ссылками для данного ресурса."""
     person = pyyaru.yaPerson(resource_url_person).get()
     self.assertEqual("self" in person.links, True)
Example #18
0
resource_urn_person = 'urn:ya.ru:person/96845657'
resource_url_person = 'https://api-yaru.yandex.ru/person/96845657/'
resource_url_person_idle = 'https://api-yaru.yandex.ru/person/153990/'
resource_url_persons = 'https://api-yaru.yandex.ru/person/96845657/friend/'

resource_urn_entry = 'urn:ya.ru:post/153990/219'
resource_url_entry = 'https://api-yaru.yandex.ru/person/153990/post/219/'
resource_url_entry_imported = 'https://api-yaru.yandex.ru/person/153990/post/2116/'
resource_url_entries = 'https://api-yaru.yandex.ru/person/153990/post/'

resource_urn_club = 'urn:ya.ru:club/4611686018427439760'
resource_url_club = 'https://api-yaru.yandex.ru/club/4611686018427439760/'
resource_url_clubs = 'https://api-yaru.yandex.ru/person/96845657/club/'

PERSON_FIXTURE = pyyaru.yaPerson(resource_url_person).get()
CLUB_FIXTURE = pyyaru.yaClub(resource_url_club).get()


class yaPersonCheck(unittest.TestCase):
    def test_geitem(self):
        """Проверка возможности доступа к свойстам объекта в нотации self[key]."""
        self.assertEqual(PERSON_FIXTURE['id'], 'urn:ya.ru:person/96845657')

    def test_id_isset(self):
        """Запись первого параметра конструктора в свойство id."""
        person = pyyaru.yaPerson(resource_urn_person)
        self.assertEqual(person.id, resource_urn_person)

    def test_id_without_fails(self):
        """Крушение без указания первого параметра конструктора."""