Esempio n. 1
0
 def test_if_related_object_does_not_exist_validation_error_is_raised(self):
     from waldur_core.structure.tests.factories import CustomerFactory
     customer = CustomerFactory()
     valid_url = CustomerFactory.get_url(customer)
     customer.delete()
     self.assertRaises(serializers.ValidationError,
                       self.field.to_internal_value, valid_url)
Esempio n. 2
0
    def setUp(self):
        from waldur_core.structure.tests.factories import CustomerFactory

        self.customer = CustomerFactory()
        self.url = CustomerFactory.get_url(self.customer)

        self.customer_filter = core_filters.URLFilter(
            view_name='customer-detail', field_name='customer__uuid')
Esempio n. 3
0
 def test_if_user_does_not_have_permissions_for_related_object_validation_error_is_raised(
         self):
     from waldur_core.structure.tests.factories import CustomerFactory
     customer = CustomerFactory()
     valid_url = CustomerFactory.get_url(customer)
     self.user.is_staff = False
     self.user.save()
     self.assertRaises(serializers.ValidationError,
                       self.field.to_internal_value, valid_url)
Esempio n. 4
0
    def test_user_can_not_create_submission_for_unrelated_customer(self):
        self.client.force_authenticate(self.user)

        del self.payload['customer_create_request']
        self.payload['customer'] = CustomerFactory.get_url(
            self.fixture.customer)

        response = self.client.post(self.list_url, self.payload)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
Esempio n. 5
0
 def get_valid_payload(self):
     return {
         'name': 'Azure service',
         'customer': CustomerFactory.get_url(self.fixture.customer),
         'tenant_id': uuid.uuid4(),
         'client_id': uuid.uuid4(),
         'client_secret': uuid.uuid4(),
         'subscription_id': uuid.uuid4(),
     }
Esempio n. 6
0
 def get_valid_payload(self):
     return {
         'type': 'SLURM',
         'name': 'SLURM service',
         'customer': CustomerFactory.get_url(self.fixture.customer),
         'options': {
             'username': '******',
             'hostname': 'slurm.waldur.com',
             'default_account': 'waldur_user',
             'port': 22,
             'use_sudo': True,
             'gateway': '8.8.8.8',
         },
     }
Esempio n. 7
0
 def setUp(self):
     self.fixture = ProjectFixture()
     self.url = ServiceSettingsFactory.get_list_url()
     self.valid_payload = {
         'type': 'Azure',
         'name': 'Azure service',
         'customer': CustomerFactory.get_url(self.fixture.customer),
         'options': {
             'tenant_id': uuid.uuid4().hex,
             'client_id': uuid.uuid4().hex,
             'client_secret': uuid.uuid4().hex,
             'subscription_id': uuid.uuid4().hex,
         },
     }
Esempio n. 8
0
    def test_user_can_create_submission_for_existing_customer(self):
        self.client.force_authenticate(self.user)

        del self.payload['customer_create_request']
        self.payload['customer'] = CustomerFactory.get_url(
            self.fixture.customer)
        self.fixture.project.add_user(self.user, ProjectRole.MEMBER)

        response = self.client.post(self.list_url, self.payload)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED,
                         response.data)

        flow = FlowTracker.objects.get(uuid=response.data['uuid'])
        self.assertEqual(flow.customer_create_request, None)
        self.assertEqual(flow.customer, self.fixture.customer)
Esempio n. 9
0
 def test_if_related_object_exists_it_is_deserialized(self):
     from waldur_core.structure.tests.factories import CustomerFactory
     customer = CustomerFactory()
     valid_url = CustomerFactory.get_url(customer)
     self.assertEqual(self.field.to_internal_value(valid_url), customer)