Skip to content

Commit

Permalink
Reproduced bug in tests
Browse files Browse the repository at this point in the history
This reproduces the issue described in #97, when saving an unpopulated
object apparently triggers population before sending the PUT request.
Fix coming soon.
  • Loading branch information
Dorthu committed Feb 3, 2018
1 parent ab3eb03 commit cbd6155
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/fixtures/nodebalancers_123456_configs_65432_nodes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"data": [
{
"status": "Unknown",
"nodebalancer_id": 123456,
"weight": 50,
"address": "192.168.12.34:999",
"mode": "accept",
"label": "test",
"config_id": 65432,
"id": 24680
}
],
"results": 1,
"page": 1,
"pages": 1
}
13 changes: 13 additions & 0 deletions test/objects/linode/linode_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ def test_get_linode(self):
self.assertTrue(isinstance(linode.image, Image))
self.assertEqual(linode.image.label, "Ubuntu 17.04")

def test_update_not_populated_saves(self):
"""
Tests that updating an unpopulated object sends the correct request
"""
linode = Linode(self.client, 123)

with self.mock_put('/linode/instances/123') as m:
linode.label = 'new_label'
self.assertEqual(linode._populated, False)
linode.save()

self.assertEqual(m.call_data['label'], 'new_label')

def test_rebuild(self):
"""
Tests that you can rebuild with an image
Expand Down
26 changes: 26 additions & 0 deletions test/objects/nodebalancers/nodes_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from datetime import datetime

from test.base import ClientBaseCase
from linode.objects.base import MappedObject

from linode.objects import NodeBalancerNode


class NodeBalancerConfigTest(ClientBaseCase):
"""
Tests methods of the NodeBalancerNode class
"""
def test_update_not_populated_saves(self):
"""
Tests that updating an unpopulated object sends the correct request
"""
node = NodeBalancerNode(self.client, 24680, 65432, 123456)

with self.mock_put('/nodebalancers/123456/configs/65432/nodes/24680') as m:
node.weight = 100
self.assertEqual(node._populated, False)
node.save()

self.assertEqual(m.call_data['weight'], 100)


0 comments on commit cbd6155

Please sign in to comment.