Пример #1
0
 def put(self, client, user, module_id):
     """Url for this test class."""
     response = client.put(
         f'/api/pod/{user.pod.id}/modules/{module_id}',
         headers=auth_token(user),
     )
     return response
Пример #2
0
    def test_module_creation(self, app, user, client):
        """Simple module creation."""
        # Normal new module request
        data = {
            'module_type': 'PlasmaGenerator',
            'stationary': False,
            'x_pos': 1,
            'y_pos': 1
        }
        response = self.post(client, user, data)

        user = db.session.query(User).get(user.id)
        assert response.status_code == 201
        assert len(user.pod.modules) == 1
        assert len(user.pod.queue.queue_entries) == 1

        assert user.pod.queue.queue_entries[0].type == 'PlasmaGenerator'
        assert user.pod.queue.queue_entries[0].level == 0
        assert user.pod.queue.queue_entries[0].finishes_at is not None

        response = client.get(f'/api/pod/{user.pod.id}/modules',
                              headers=auth_token(user))
        assert response.status_code == 200
        assert response.json[0]
        assert response.json[0]['type'] == 'PlasmaGenerator'
        assert response.json[0]['stationary'] is False
        assert response.json[0]['x_pos'] == 1
        assert response.json[0]['y_pos'] == 1
        assert response.json[0]['level'] == 0
        assert response.json[0]['finished'] is False
Пример #3
0
 def delete_entry(self, client, user, entry):
     """Url for this test class."""
     response = client.delete(
         f'/api/pod/{user.pod.id}/queue/entry/{entry.id}',
         headers=auth_token(user),
     )
     return response
Пример #4
0
 def get_queue(self, client, user):
     """Url for this test class."""
     response = client.get(
         f'/api/pod/{user.pod.id}/queue',
         headers=auth_token(user),
     )
     return response
Пример #5
0
 def post(self, client, user, data):
     """Url for this test class."""
     response = client.post(
         f'/api/pod/{user.pod.id}/modules',
         data=json.dumps(data),
         headers=auth_token(user),
     )
     return response
Пример #6
0
 def post_upgrade(self, client, user, data):
     """Url for this test class."""
     response = client.post(
         self.pod_resource_url(user),
         data=json.dumps(data),
         headers=auth_token(user),
     )
     return response
Пример #7
0
 def test_module_creation(self, app, user, client):
     """Simple research check."""
     response = client.get(self.url(user), headers=auth_token(user))
     assert response.status_code
Пример #8
0
 def get(self, client, user):
     """Url for this test class."""
     return client.get('/api/modules', headers=auth_token(user))