Beispiel #1
0
    def test_request_command_collection_wrong_type_put(self):
        """Test the CommandCollection endpoint PUT with wrong type ."""
        state = gen_State("-1000", "50", "North", "1,1", "Active", "100")
        command = gen_Command("-1000", state)
        command["@type"] = "Dummy"

        request_put = requests.put(CS_URL + 'api/CommandCollection',
                                   data=json.dumps(command))
        assert request_put.status_code == 400
Beispiel #2
0
    def test_command_data(self):
        """Test if command data submitted is same as command received back."""
        state = gen_State('-1000', "50", "North", "1,1", "Active", '100')
        command = gen_Command('123', state)
        request_put = requests.put(CS_URL + 'api/CommandCollection/',
                                   data=json.dumps(command))

        id_ = request_put.headers["Location"].split("/")[-1]
        request_get = requests.get(CS_URL + 'api/CommandCollection/' + id_)
        received_command = request_get.json()
        received_command.pop("@id", None)
        received_command.pop("@context", None)
        assert ordered(command) == ordered(received_command)
Beispiel #3
0
    def test_request_command_collection(self):
        """Test the CommandCollection endpoint."""
        state = gen_State("-1000", "50", "North", "1,1", "Active", "100")
        command = gen_Command("-1000", state)

        request_get = requests.get(CS_URL + 'api/CommandCollection')
        request_put = requests.put(CS_URL + 'api/CommandCollection',
                                   data=json.dumps(command))
        request_post = requests.post(CS_URL + 'api/CommandCollection',
                                     data=json.dumps(command))
        request_delete = requests.delete(CS_URL + 'api/CommandCollection')
        assert request_get.status_code == 200
        assert request_put.status_code == 201
        assert request_post.status_code == 405
        assert request_delete.status_code == 405
def generate_command(drone_id, prop, value):
    """Generate a command object given a property and value."""
    state = {"@type": 'State', prop: value}
    command = gen_Command(drone_id, state)
    return command