Skip to content

Commit 0800c61

Browse files
committed
get allocations working
1 parent 7bc0094 commit 0800c61

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/djangoproject/alloc/models.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@ def from_domain(self, batch: domain_model.Batch):
2020
return b
2121

2222
def to_domain(self):
23-
return domain_model.Batch(ref=self.reference, sku=self.sku, qty=self.qty)
23+
b = domain_model.Batch(
24+
ref=self.reference, sku=self.sku, qty=self.qty, eta=self.eta
25+
)
26+
b._allocations = set(a.line.to_domain() for a in self.allocation_set.all())
27+
return b
2428

2529

2630
class OrderLine(models.Model):
2731
orderid = models.CharField(max_length=255)
2832
sku = models.CharField(max_length=255)
2933
qty = models.IntegerField()
3034

35+
def to_domain(self):
36+
return domain_model.OrderLine(
37+
orderid=self.orderid, sku=self.sku, qty=self.qty
38+
)
39+
3140

3241
class Allocation(models.Model):
3342
batch = models.ForeignKey(Batch, on_delete=models.CASCADE)

tests/integration/test_repository.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def test_repository_can_save_a_batch(django_models):
2626
assert saved_batch.eta == batch.eta
2727

2828

29-
@pytest.mark.skip("foo")
3029
@pytest.mark.django_db
3130
def test_repository_can_retrieve_a_batch_with_allocations(django_models):
3231
sku = "PONY-STATUE"

0 commit comments

Comments
 (0)