Пример #1
0
    def test(self, mock_gmp: GmpMockFactory):
        mock_gmp.mock_response(gmp_cmd,
                               compose_mock_response(gmp_name, no_plural))

        self.login('foo', 'bar')

        response = self.query(compose_mock_query(plural_selene_name))
        self.assertResponseNoErrors(response)

        json = response.json()

        edges = json['data'][plural_selene_name]['edges']

        edge1 = edges[0]
        edge2 = edges[1]

        self.assertEqual(edge1['cursor'], get_cursor(edge_name, 0))
        self.assertEqual(edge2['cursor'], get_cursor(edge_name, 1))

        entity1 = edge1['node']
        entity2 = edge2['node']

        self.assertEqual(entity1['id'], 'e9b98e26-9fff-4ee8-9378-bc44fe3d6f2b')

        self.assertEqual(entity2['id'], '85787cbb-a737-463d-94b8-fcc348225f3b')
    def test_should_prefer_after_for_before(self):
        after = get_cursor('foo', 100)
        before = get_cursor('foo', 200)
        filter_string1 = FilterString('first=1 rows=10')
        filter_string2 = get_filter_string_for_pagination(filter_string1,
                                                          after=after,
                                                          first=5,
                                                          last=15,
                                                          before=before)

        self.assertEqual(str(filter_string2), 'rows=5 first=102')
    def test_should_update_first_for_after(self):
        cursor = get_cursor('foo', 123)
        filter_string1 = FilterString('first=1 rows=10')
        filter_string2 = get_filter_string_for_pagination(filter_string1,
                                                          after=cursor)

        self.assertEqual(str(filter_string2), 'rows=10 first=125')
    def test_should_update_first_for_before(self):
        cursor = get_cursor('foo', 123)
        filter_string1 = FilterString('first=1 rows=10')
        filter_string2 = get_filter_string_for_pagination(filter_string1,
                                                          before=cursor,
                                                          last=10)

        self.assertEqual(str(filter_string2), 'rows=10 first=114')
Пример #5
0
    def test_get_offset(self):
        cursor = get_cursor('foo', 123)
        offset = get_offset_from_cursor(cursor)

        self.assertEqual(offset, 123)
Пример #6
0
    def test_create_cursor(self):
        # not sure if the implementation details should be tested here
        cursor = get_cursor('foo', 123)

        encoded_cursor = b64encode(b'foo:123').decode('utf-8')
        self.assertEqual(encoded_cursor, cursor)