def test_registration_comment_has_usable_node_relationship_link(self):
     self._set_up_registration_with_comment()
     res = self.app.get(self.registration_url, auth=self.user.auth)
     assert_equal(res.status_code, 200)
     comments_url = res.json['data']['relationships']['comments']['links']['related']['href']
     comments_uri = test_utils.urlparse_drop_netloc(comments_url)
     comments_res = self.app.get(comments_uri, auth=self.user.auth)
     assert_equal(comments_res.status_code, 200)
     node_url = comments_res.json['data'][0]['relationships']['node']['links']['related']['href']
     node_uri = test_utils.urlparse_drop_netloc(node_url)
     node_res = self.app.get(node_uri, auth=self.user.auth)
     assert_in(self.registration._id, node_res.json['data']['id'])
Exemple #2
0
 def test_registration_comment_has_usable_node_relationship_link(self):
     self._set_up_registration_with_comment()
     res = self.app.get(self.registration_url, auth=self.user.auth)
     assert_equal(res.status_code, 200)
     comments_url = res.json['data']['relationships']['comments']['links'][
         'related']['href']
     comments_uri = test_utils.urlparse_drop_netloc(comments_url)
     comments_res = self.app.get(comments_uri, auth=self.user.auth)
     assert_equal(comments_res.status_code, 200)
     node_url = comments_res.json['data'][0]['relationships']['node'][
         'links']['related']['href']
     node_uri = test_utils.urlparse_drop_netloc(node_url)
     node_res = self.app.get(node_uri, auth=self.user.auth)
     assert_in(self.registration._id, node_res.json['data']['id'])
 def test_registration_comment_has_usable_node_relationship_link(
         self, app, user, registration, registration_url,
         registration_comment_reply
 ):
     res = app.get(registration_url, auth=user.auth)
     assert res.status_code == 200
     comments_url = res.json['data']['relationships']['comments']['links']['related']['href']
     comments_uri = test_utils.urlparse_drop_netloc(comments_url)
     comments_res = app.get(comments_uri, auth=user.auth)
     assert comments_res.status_code == 200
     node_url = comments_res.json['data'][0]['relationships']['node']['links']['related']['href']
     node_uri = test_utils.urlparse_drop_netloc(node_url)
     node_res = app.get(node_uri, auth=user.auth)
     assert registration._id in node_res.json['data']['id']
 def test_registration_comment_has_usable_node_relationship_link(
         self, app, user, registration, registration_url,
         registration_comment_reply
 ):
     res = app.get(registration_url, auth=user.auth)
     assert res.status_code == 200
     comments_url = res.json['data']['relationships']['comments']['links']['related']['href']
     comments_uri = test_utils.urlparse_drop_netloc(comments_url)
     comments_res = app.get(comments_uri, auth=user.auth)
     assert comments_res.status_code == 200
     node_url = comments_res.json['data'][0]['relationships']['node']['links']['related']['href']
     node_uri = test_utils.urlparse_drop_netloc(node_url)
     node_res = app.get(node_uri, auth=user.auth)
     assert registration._id in node_res.json['data']['id']
Exemple #5
0
 def test_comment_has_replies_link(self):
     self._set_up_public_project_with_comment()
     res = self.app.get(self.public_url)
     url = res.json['data']['relationships']['replies']['links']['related']['href']
     uri = test_utils.urlparse_drop_netloc(url)
     expected_url = '/{}nodes/{}/comments/?filter[target]={}'.format(API_BASE, self.public_project._id, self.public_comment._id)
     assert_equal(res.status_code, 200)
     assert_in(expected_url, uri)
 def test_comment_has_replies_link(self):
     self._set_up_public_project_with_comment()
     res = self.app.get(self.public_url)
     assert_equal(res.status_code, 200)
     url = res.json['data']['relationships']['replies']['links']['related']['href']
     uri = test_utils.urlparse_drop_netloc(url)
     res = self.app.get(uri)
     assert_equal(res.status_code, 200)
     assert_equal(res.json['data'][0]['type'], 'comments')
Exemple #7
0
 def test_comment_has_replies_link(self):
     self._set_up_public_project_with_comment()
     res = self.app.get(self.public_url)
     assert_equal(res.status_code, 200)
     url = res.json['data']['relationships']['replies']['links']['related'][
         'href']
     uri = test_utils.urlparse_drop_netloc(url)
     res = self.app.get(uri)
     assert_equal(res.status_code, 200)
     assert_equal(res.json['data'][0]['type'], 'comments')
Exemple #8
0
    def test_comment_has_multiple_links(self, app, user, public_url,
                                        public_project, public_comment,
                                        public_comment_reply, comment_url,
                                        registration):
        res = app.get(public_url)
        assert res.status_code == 200
        # test_comment_has_user_link
        url_user = res.json['data']['relationships']['user']['links'][
            'related']['href']
        expected_url = '/{}users/{}/'.format(API_BASE, user._id)
        assert urlparse(url_user).path == expected_url

        # test_comment_has_node_link
        url_node = res.json['data']['relationships']['node']['links'][
            'related']['href']
        expected_url = '/{}nodes/{}/'.format(API_BASE, public_project._id)
        assert urlparse(url_node).path == expected_url

        # test_comment_has_replies_link
        url_replies = res.json['data']['relationships']['replies']['links'][
            'related']['href']
        uri = test_utils.urlparse_drop_netloc(url_replies)
        res_uri = app.get(uri)
        assert res_uri.status_code == 200
        assert res_uri.json['data'][0]['type'] == 'comments'

        # test_comment_has_reports_link
        url_reports = res.json['data']['relationships']['reports']['links'][
            'related']['href']
        expected_url = '/{}comments/{}/reports/'.format(
            API_BASE, public_comment._id)
        assert urlparse(url_reports).path == expected_url

        # test_registration_comment_has_node_link
        res = app.get(comment_url, auth=user.auth)
        url = res.json['data']['relationships']['node']['links']['related'][
            'href']
        expected_url = '/{}registrations/{}/'.format(API_BASE,
                                                     registration._id)
        assert res.status_code == 200
        assert urlparse(url).path == expected_url
    def test_comment_has_multiple_links(
            self, app, user, public_url, public_project, public_comment,
            public_comment_reply, comment_url, registration
    ):
        res = app.get(public_url)
        assert res.status_code == 200
        # test_comment_has_user_link
        url_user = res.json['data']['relationships']['user']['links']['related']['href']
        expected_url = '/{}users/{}/'.format(API_BASE, user._id)
        assert urlparse(url_user).path == expected_url

        # test_comment_has_node_link
        url_node = res.json['data']['relationships']['node']['links']['related']['href']
        expected_url = '/{}nodes/{}/'.format(API_BASE, public_project._id)
        assert urlparse(url_node).path == expected_url

        # test_comment_has_replies_link
        url_replies = res.json['data']['relationships']['replies']['links']['related']['href']
        uri = test_utils.urlparse_drop_netloc(url_replies)
        res_uri = app.get(uri)
        assert res_uri.status_code == 200
        assert res_uri.json['data'][0]['type'] == 'comments'

        # test_comment_has_reports_link
        url_reports = res.json['data']['relationships']['reports']['links']['related']['href']
        expected_url = '/{}comments/{}/reports/'.format(
            API_BASE, public_comment._id)
        assert urlparse(url_reports).path == expected_url

        # test_registration_comment_has_node_link
        res = app.get(comment_url, auth=user.auth)
        url = res.json['data']['relationships']['node']['links']['related']['href']
        expected_url = '/{}registrations/{}/'.format(
            API_BASE, registration._id)
        assert res.status_code == 200
        assert urlparse(url).path == expected_url