Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
scrungus committed Jul 16, 2024
1 parent b50b40d commit f8944e3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion coral_credits/api/business_objects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass, field
from typing import List, Dict, Any
from datetime import datetime
from typing import Any, Dict, List
from uuid import UUID


Expand Down
17 changes: 9 additions & 8 deletions coral_credits/api/db_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.db.models import F
from django.shortcuts import get_object_or_404
from django.utils import timezone

from coral_credits.api import models, db_exceptions
from coral_credits.api import db_exceptions, models


def get_current_lease(current_lease):
Expand Down Expand Up @@ -34,8 +33,8 @@ def get_credit_allocations(resource_provider_account):


def get_credit_allocation_resources(credit_allocations, resource_classes):
"""
Returns a dictionary of the form:
"""Returns a dictionary of the form:
{
"resource_class": "credit_resource_allocation"
}
Expand All @@ -55,8 +54,8 @@ def get_credit_allocation_resources(credit_allocations, resource_classes):


def get_resource_requests(lease, current_resource_requests=None):
"""
Returns a dictionary of the form:
"""Returns a dictionary of the form:
{
"resource_class": "resource_hours"
}
Expand Down Expand Up @@ -113,9 +112,11 @@ def calculate_delta_resource_hours(


def check_credit_allocations(resource_requests, credit_allocations):
"""Subtracts resources requested from credit allocations.
Fails if any result is negative.
"""
Subtracts resources requested from credit allocations and ensures all results are non-negative.
"""

result = {}
for resource_class in credit_allocations:
result[resource_class] = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Generated by Django 5.0.6 on 2024-07-04 16:20

from django.db import migrations, models

import uuid

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
Expand Down
10 changes: 9 additions & 1 deletion coral_credits/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from rest_framework import serializers

from coral_credits.api import models
from coral_credits.api.business_objects import *
from coral_credits.api.business_objects import (
Allocation,
ConsumerRequest,
Context,
Inventory,
Lease,
Reservation,
ResourceRequest,
)


class ResourceClassSerializer(serializers.HyperlinkedModelSerializer):
Expand Down
5 changes: 3 additions & 2 deletions coral_credits/api/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import json
from datetime import datetime, timedelta
import uuid
from datetime import datetime, timedelta

import coral_credits.api.models as models
from django.urls import reverse
from django.utils.timezone import make_aware
import pytest
from rest_framework import status
from rest_framework.test import APIClient

import coral_credits.api.models as models

PROJECT_ID = "20354d7a-e4fe-47af-8ff6-187bca92f3f9"
USER_REF = "caa8b54a-eb5e-4134-8ae2-a3946a428ec7"
START_DATE = make_aware(datetime.now())
Expand Down
2 changes: 1 addition & 1 deletion coral_credits/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rest_framework import permissions, status, viewsets
from rest_framework.response import Response

from coral_credits.api import models, serializers, db_utils, db_exceptions
from coral_credits.api import db_exceptions, db_utils, models, serializers


class ResourceClassViewSet(viewsets.ModelViewSet):
Expand Down
3 changes: 1 addition & 2 deletions coral_credits/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

import logging
import os
from pathlib import Path

from django.core.management.utils import get_random_secret_key

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

Expand Down

0 comments on commit f8944e3

Please sign in to comment.