예제 #1
0
    def test_put_agent_updated(self, agent_xml, rf):
        identifier = agent_xml.identifier
        agent = factories.AgentFactory.create(agent_identifier=identifier)

        request = rf.put('/', agent_xml.obj_xml, content_type='application/xml')
        views.app_agent(request, agent.agent_identifier)

        updated_agent = models.Agent.objects.get(agent_identifier=identifier)
        assert updated_agent.agent_name != agent.agent_name
예제 #2
0
    def test_head_and_get_headers_match_without_identifier(self, rf):
        head_request, get_request = rf.head('/'), rf.get('/')

        head_response = views.app_agent(head_request)
        get_response = views.app_agent(get_request)

        expected_headers = get_response.serialize_headers()
        actual_headers = head_response.serialize_headers()

        assert expected_headers == actual_headers, 'The response headers do not match.'
예제 #3
0
    def test_head_and_get_headers_match_with_identifier(self, rf):
        agent = factories.AgentFactory.create()
        head_request, get_request = rf.head('/'), rf.get('/')

        head_response = views.app_agent(head_request, agent.agent_identifier)
        get_response = views.app_agent(get_request, agent.agent_identifier)

        expected_headers = get_response.serialize_headers()
        actual_headers = head_response.serialize_headers()

        assert expected_headers == actual_headers, 'The response headers do not match.'
예제 #4
0
    def test_put_returns_ok(self, agent_xml, rf):
        identifier = agent_xml.identifier
        agent = factories.AgentFactory.create(agent_identifier=identifier)

        request = rf.put('/', agent_xml.obj_xml, content_type='application/xml')
        response = views.app_agent(request, agent.agent_identifier)
        assert response.status_code == 200
예제 #5
0
    def test_put_response_content_type(self, agent_xml, rf):
        identifier = agent_xml.identifier
        agent = factories.AgentFactory.create(agent_identifier=identifier)

        request = rf.put('/', agent_xml.obj_xml, content_type='application/xml')
        response = views.app_agent(request, agent.agent_identifier)
        assert response.get('Content-Type') == self.CONTENT_TYPE
예제 #6
0
 def test_invalid_identifier_returns_not_found(self, rf):
     """Test that a nonexistent Agent identifier results in a
     404 Not Found.
     """
     request = rf.get('/')
     response = views.app_agent(request, 'fake-identifier')
     assert response.status_code == 404
예제 #7
0
 def test_list_returns_ok(self, rf):
     request = rf.get('/')
     response = views.app_agent(request)
     assert response.status_code == 200
예제 #8
0
 def test_head_with_identifier(self, rf):
     agent = factories.AgentFactory.create()
     request = rf.head('/')
     response = views.app_agent(request, agent.agent_identifier)
     assert response.content == '', 'The message body must be empty'
     assert response.status_code == 200
예제 #9
0
 def test_list_with_invalid_page(self, rf):
     request = rf.get('/?page=3')
     views.app_agent(request)
예제 #10
0
 def test_head_without_identifier(self, rf):
     request = rf.head('/')
     response = views.app_agent(request)
     assert response.content == '', 'The message body must be empty'
     assert response.status_code == 200
예제 #11
0
 def test_get_with_identifier_response_content(self, rf):
     agent = factories.AgentFactory.create()
     request = rf.get('/')
     response = views.app_agent(request, agent.agent_identifier)
     assert agent.agent_identifier in response.content
예제 #12
0
 def test_get_with_identifier_response_content_type(self, rf):
     agent = factories.AgentFactory.create()
     request = rf.get('/')
     response = views.app_agent(request, agent.agent_identifier)
     assert response.get('Content-Type') == self.CONTENT_TYPE
예제 #13
0
 def test_get_with_identifier_returns_ok(self, rf):
     agent = factories.AgentFactory.create()
     request = rf.get('/')
     response = views.app_agent(request, agent.agent_identifier)
     assert response.status_code == 200
예제 #14
0
 def test_post_returns_created(self, rf, agent_xml):
     request = rf.post('/', agent_xml.obj_xml, content_type='application/xml')
     response = views.app_agent(request)
     assert response.status_code == 201
예제 #15
0
 def test_list_response_content_type(self, rf):
     request = rf.get('/')
     response = views.app_agent(request)
     assert response.get('Content-Type') == self.CONTENT_TYPE
예제 #16
0
 def test_delete_removes_agent(self, rf):
     agent = factories.AgentFactory.create()
     request = rf.delete('/')
     views.app_agent(request, agent.agent_identifier)
     assert models.Agent.objects.count() == 0
예제 #17
0
 def test_delete_without_identifier_returns_bad_request(self, rf):
     request = rf.delete('/')
     response = views.app_agent(request)
     assert response.status_code == 400
예제 #18
0
 def test_post_without_body_is_handled(self, rf):
     request = rf.post('/')
     views.app_agent(request)
예제 #19
0
    def test_post_response_content(self, rf, agent_xml):
        request = rf.post('/', agent_xml.obj_xml, content_type='application/xml')
        response = views.app_agent(request)

        identifier = agent_xml.identifier
        assert identifier in response.content
예제 #20
0
 def test_post_response_content_type(self, rf, agent_xml):
     request = rf.post('/', agent_xml.obj_xml, content_type='application/xml')
     response = views.app_agent(request)
     assert response.get('Content-Type') == self.CONTENT_TYPE